Updated env file and kube config file handling
New:
- Imported kaas/* repositories (1100+)
- Options for use of specific configs (env and kaas)
Fixes:
- updated header index search
- fixed package name handling
- fixed --force-tag option
Change-Id: Ib51ea9a47db93d6dd0868c32cb389d70053af26c
Related-PROD: PROD-35903
diff --git a/cfg_checker/common/const.py b/cfg_checker/common/const.py
index 2ae41f6..d17db08 100644
--- a/cfg_checker/common/const.py
+++ b/cfg_checker/common/const.py
@@ -80,7 +80,7 @@
"unk": "uknown"
}
-ubuntu_releases = ["trusty", "xenial", "ubuntu", "bionic"]
+ubuntu_releases = ["trusty", "xenial", "ubuntu", "bionic", "focal"]
all_arch = ["amd64"]
repo_types = {
"main": "Officially supported software",
@@ -134,5 +134,6 @@
"20": "train",
"19": "stein",
"18": "rocky",
- "17": "queens"
+ "17": "queens",
+ "00": "not installed"
}
diff --git a/cfg_checker/common/settings.py b/cfg_checker/common/settings.py
index 1a30ac0..b01d684 100644
--- a/cfg_checker/common/settings.py
+++ b/cfg_checker/common/settings.py
@@ -232,7 +232,7 @@
None
)
# Warn user only if Kube env is detected locally
- if self.env_name == "local":
+ if self.env_name == ENV_LOCAL:
if not os.path.exists(self.kube_config_path):
logger_cli.warn(
"Kube config path not found on local env: '{}'".format(
@@ -265,7 +265,7 @@
self.kube_node_keypath = self.ssh_key
self.kube_node_homepath = self.homepath
- def _init_env(self, env_name=None):
+ def _init_env(self, config_path, env_name=None):
"""Inits the environment vars from the env file
Uses simple validation for the values and names
@@ -279,23 +279,18 @@
ConfigException -- on env file failed validation
"""
# load env file as init os.environment with its values
- if env_name is None:
- _env_name = ENV_LOCAL
- else:
- _env_name = env_name
- _config_path = os.path.join(pkg_dir, 'etc', _env_name + '.env')
- if os.path.isfile(_config_path):
- with open(_config_path) as _f:
+ if os.path.isfile(config_path):
+ with open(config_path) as _f:
_list = _f.read().splitlines()
logger_cli.info(
"# Loading env vars from '{}'".format(
- _config_path
+ config_path
)
)
else:
raise ConfigException(
"# Failed to load enviroment vars from '{}'".format(
- _config_path
+ config_path
)
)
self.vars = []
@@ -327,13 +322,13 @@
len(_list)
)
)
- self.env_name = _env_name
+ self.env_name = env_name
def __init__(self, args):
"""Base configuration class. Only values that are common for all scripts
"""
self.ssh_uses_sudo = args.sudo
- self.kube_config_path = args.kube_config_path
+ self.kube_config_path = args.kube_config
self.debug = args.debug
self.force_no_key = args.force_no_key
# Make sure we running on Python 3
@@ -346,10 +341,15 @@
sys.version_info[1]
))
- _env = os.getenv('MCP_ENV', None)
+ # if env name is default, check var too
+ if args.env_name == ENV_LOCAL:
+ _env = os.getenv('MCP_ENV', None)
+ _env = _env if _env else args.env_name
+ else:
+ _env = args.env_name
# Init environment variables from file, validate
- self._init_env(_env)
+ self._init_env(args.env_config, env_name=_env)
# Load Common vars for any type of the env
self._init_mcp_values()
# Detect env types present
@@ -374,11 +374,8 @@
self.mcp_host
)
)
- # Init vars that is specific to detected envs only
- self._init_env_values()
-
# initialize path to folders
- if self.env_name == "local":
+ if self.env_name == ENV_LOCAL:
# names and folders
self.user = self.pw_user.pw_name
self.homepath = self.pw_user.pw_dir
@@ -386,3 +383,6 @@
# names and folders in case of remote env
self.user = self.ssh_user
self.homepath = os.path.join('/home', self.ssh_user)
+
+ # Init vars that is specific to detected envs only
+ self._init_env_values()