Skip to content

Commit

Permalink
Add environment variable for skipping schema update (#3835)
Browse files Browse the repository at this point in the history
  • Loading branch information
audgirka authored Oct 11, 2023
1 parent 4a36d80 commit 3c90628
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/ansiblelint/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
log_entries,
options,
)
from ansiblelint.constants import RC
from ansiblelint.constants import RC, SKIP_SCHEMA_UPDATE
from ansiblelint.loaders import load_ignore_txt
from ansiblelint.runner import get_matches
from ansiblelint.skip_utils import normalize_tag
Expand Down Expand Up @@ -305,7 +305,22 @@ def main(argv: list[str] | None = None) -> int:
_logger.debug("Options: %s", options)
_logger.debug("CWD: %s", Path.cwd())

if not options.offline:
# checks if we have `ANSIBLE_LINT_SKIP_SCHEMA_UPDATE` set to bypass schema
# update. Also skip if in offline mode.
# env var set to skip schema refresh
skip_schema_update = (
bool(
int(
os.environ.get(
SKIP_SCHEMA_UPDATE,
"0",
),
),
)
or options.offline
)

if not skip_schema_update:
# pylint: disable=import-outside-toplevel
from ansiblelint.schemas.__main__ import refresh_schemas

Expand Down
2 changes: 2 additions & 0 deletions src/ansiblelint/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
DEFAULT_RULESDIR = Path(__file__).parent / "rules"
CUSTOM_RULESDIR_ENVVAR = "ANSIBLE_LINT_CUSTOM_RULESDIR"
RULE_DOC_URL = "https://ansible-lint.readthedocs.io/rules/"
SKIP_SCHEMA_UPDATE = "ANSIBLE_LINT_SKIP_SCHEMA_UPDATE"

ENV_VARS_HELP = {
CUSTOM_RULESDIR_ENVVAR: "Used for adding another folder into the lookup path for new rules.",
"ANSIBLE_LINT_IGNORE_FILE": "Define it to override the name of the default ignore file `.ansible-lint-ignore`",
"ANSIBLE_LINT_WRITE_TMP": "Tells linter to dump fixes into different temp files instead of overriding original. Used internally for testing.",
SKIP_SCHEMA_UPDATE: "Tells ansible-lint to skip schema refresh.",
}

EPILOG = (
Expand Down

0 comments on commit 3c90628

Please sign in to comment.