def get_simple_cli_version(binary_name: str) -> Optional[VersionInfo]: raw_version = get_stdout(f"{binary_name} --version") if raw_version: version = try_parse_semver(raw_version) logging.debug(f"{binary_name} version: {version}") return version return None
def check(self) -> CheckResult: output = get_stdout("helm repo list -o json") if not output: return self.failed( "No helm repos appear to be configured for the current user.") repo_json = json.loads(output) repo = next( filter( lambda repo_details: repo_details.get("name") == self. repo_name, repo_json), None) if repo is None: return self.failed( f"{self.repo_name} is not configured for the current user") installed_url = repo["url"].strip("/") logging.debug( f"{self.repo_name} helm repo is installed with URL {installed_url}." ) if installed_url != self.repo_url: return self.failed( f"{self.repo_name} is configured to use the wrong URL. Expected {self.repo_url}, got {installed_url}" ) return self.passed( f"{self.repo_name} is configured for the current user")
def get_helm_version() -> Optional[VersionInfo]: raw_version = get_stdout("helm version --short") if raw_version: match = helm_version_pattern.search(raw_version) if match: version = try_parse_semver(match.group(1)) logging.debug(f"Helm Version: {version}") return version return None
def get_kubectl_version() -> Optional[VersionInfo]: raw_version = get_stdout("kubectl version --client=true --short") if raw_version: match = version_pattern.search(raw_version) if match: version = try_parse_semver(match.group(1)) logging.debug(f"Kubectl version: {version}") return version return None
def get_terraform_version() -> Optional[VersionInfo]: raw_version = get_stdout("terraform version") if raw_version: match = version_pattern.search(raw_version) if match: version = try_parse_semver(match.group(1)) logging.debug(f"Terraform version: {version}") return version return None
def check(self) -> CheckResult: output = get_stdout("git lfs ls-files") or "" files_not_downloaded = [ line.split()[2] for line in output.splitlines() if line.split()[1] == "-" ] for file in files_not_downloaded: logging.info(f"Git LFS file not downloaded: {file}") passed = len(files_not_downloaded) == 0 return self.verify(passed, "Git LFS files have <not/> been downloaded")
def get_flutter_version() -> Optional[VersionInfo]: version_output = get_stdout("flutter --version") return parse_flutter_version_output(version_output)
def check(self) -> CheckResult: output = get_stdout("kubectl config get-contexts") passed = bool(output and self.context_name in output) return self.verify( passed, f"{self.context_name} is <not/> configured for the current user")
def get_nodejs_version() -> Optional[VersionInfo]: version_output = get_stdout("node --version") version_output = None if version_output is None else version_output.lstrip( "v") return try_parse_semver(version_output)
def check(self) -> CheckResult: output = get_stdout("git lfs env") passed = bool(output and "git-lfs filter-process" in output) return self.verify(passed, "Git LFS is <not/> set up for the current user")
def is_ascii(path: str) -> bool: file_output = get_stdout(["file", path]) or "" parts = file_output.strip().split(": ") return parts[1] == "ASCII text"