Skip to content

[RFC] Add option to validate only current env in validators.validate #734

@UgoBena

Description

@UgoBena

Problem
I currently have a problem in a project when trying to validate a configuration. I have some variables in production that I do not have in development environment, and that are contained in a .secrets file not present in my project. I would like to validate the presence of the production variables when I run the project in production environment. However when running the validators, they go through all environments, and thus fail when trying to validate my production environment in development because some variables are missing as the .secrets.yml file is not present.

Proposed Solution
I just wanted to know if you had considered this issue. I did a quick fix on my side by adding a check_only_current_env: bool = False var to all validate functions in validators.py and simply add a check in Validator.validate before the validate_items lines:

if check_only_current_env:
    if settings.current_env in self.envs:
         this._validate_items(...)
    return

I am open to any other solutions and can also make a pull request with this small change.

Thank you very much for the project it's really nice !

Metadata

Metadata

Assignees

No one assigned

    Labels

    Not a BugNot a Problem, expected behaviorRFC

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions