Skip to content
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
dist/
build/
__pycache__/
pyproject.toml
uv.lock
5 changes: 4 additions & 1 deletion src/github_actions/common/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# github_actions/common/__init__.py

from .actions.init_project import GETTenant, ProjectInitializer, RMKConfigInitCommand
from .actions.init_project import GETTenant, ProjectInitializer, RMKConfigInitCommand, GetRootDomain
from .credentials.cluster_provider_credentials import (
AWSConfig, AzureConfig, ClusterProviders, Credentials, EnvironmentConfig, GCPConfig
)
Expand All @@ -17,6 +17,7 @@
from .utils.cmd import BaseCommand, CMDInterface
from .utils.github_environment_variables import GitHubContext
from .utils.install_rmk import RMKInstaller
from .utils.install_kodjin_cli import KodjinCLIInstaller


__all__ = [
Expand Down Expand Up @@ -45,4 +46,6 @@
"RMKInstaller",
"S3BucketManager",
"SlackNotifier",
"KodjinCLIInstaller",
"GetRootDomain",
]
15 changes: 14 additions & 1 deletion src/github_actions/common/actions/init_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,24 @@ def execute(self) -> str:
return self.run()

def run(self) -> str:
output = self.run_command(f"rmk --log-format=json config view", True)
output = self.run_command("rmk --log-format=json config view", True)
rmk_config = json.loads(output)
return rmk_config["config"]["Tenant"]


class GetRootDomain(BaseCommand, CMDInterface):
def __init__(self, environment: str):
super().__init__(environment)

def execute(self) -> str:
return self.run()

def run(self) -> str:
output = self.run_command("rmk --log-format=json config view", True)
rmk_config = json.loads(output)
return rmk_config["config"]["RootDomain"]


class ProjectInitializer:
GIT_CONFIG = {
"name": "github-actions",
Expand Down
40 changes: 40 additions & 0 deletions src/github_actions/common/utils/install_kodjin_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import subprocess
import requests

from argparse import Namespace
from packaging import version


class KodjinCLIInstaller:
def __init__(self, args: Namespace):
self.version = args.kodjin_cli_version
self.url = args.kodjin_cli_download_url
self.verify_kodjin_cli_version()
self.install_kodjin_cli()

def verify_kodjin_cli_version(self):
print("Verifying Kodjin CLI installation version...")
if self.version != "latest":
if version.parse(self.version) <= version.parse("v0.1.11"):
raise Exception(
f"version {self.version} of Kodjin CLI is not correct, "
+ "the version for Kodjin CLI must be at least v0.1.11 or greater"
)

def install_kodjin_cli(self):
print("Installing Kodjin CLI.")
try:
response = requests.get(self.url)
response.raise_for_status()
except requests.RequestException as err:
raise Exception(f"downloading Kodjin CLI installer file:\n{err}")

try:
subprocess.run(
["bash", "-s", "--", self.version],
check=True,
text=True,
input=response.text,
)
except subprocess.CalledProcessError as err:
raise Exception(f"installing Kodjin CLI:\n{err}")
Loading