runway.env_mgr.kbenv module¶
Kubectl version management.
- class runway.env_mgr.kbenv.KBEnvManager[source]¶
Bases:
EnvManager
kubectl version management.
Designed to be compatible with https://github.com/alexppg/kbenv.
- __init__(path: Path | None = None, *, overlay_path: Path | None = None) None [source]¶
Initialize class.
- Parameters:
path – Module path.
overlay_path – Path to Kustomize overlay.
- get_version_from_file(file_path: Path | None = None) str | None [source]¶
Get kubectl version from a file.
- Parameters:
file_path – Path to file that will be read.
- list_installed() Generator[Path, None, None] [source]¶
List installed versions of kubectl.
Only lists versions of kubectl that have been installed by an instance if this class or by kbenv.
- classmethod parse_version_string(version: str) Version [source]¶
Parse version string into a
Version
.- Parameters:
version – Version string to parse. Must be in the format of
<major>.<minor>.<patch>
with an optional-<prerelease>
.
- runway.env_mgr.kbenv.download_kb_release(version: str, versions_dir: Path, kb_platform: str | None = None, arch: str | None = None) None [source]¶
Download kubectl and return path to it.
- runway.env_mgr.kbenv.verify_kb_release(kb_url: str, download_dir: str, filename: str) None [source]¶
Compare checksum and exit if it doesn’t match.
Different releases provide varying checksum files. To account for this, start at SHA512 and work down to the first available checksum.
requests is used for downloading these small files because of difficulty in getting 404 status from urllib on py2. Once py2 support is dropped, downloads can be moved to urllib.
https://stackoverflow.com/questions/1308542/how-to-catch-404-error-in-urllib-urlretrieve