Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add environment variable for skipping schema update #3835

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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