Skip to content

Environment variables as objects? #24

@killermoehre

Description

@killermoehre

Hi,

I'm thinking about a dataclass containing all the default variables like

from github_action_utils import vars
# vars.ci == True
# vars.github.event_path == '/github/workflow/event.json'

and so on. So every first _ in a variable name would actually open a new sub-level.
All values would be read-only. With appropriate __doc__ strings this would allow for great integration in any IDE.

The goal would be to reduce boilerplate code like

GITHUB = {
    "SERVER_URL": github_action_utils.get_env("GITHUB_SERVER_URL"),
    "REPOSITORY": github_action_utils.get_env("GITHUB_REPOSITORY"),
    "RUN_NUMBER": github_action_utils.get_env("GITHUB_RUN_NUMBER"),
}

Opinions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions