Skip to content

Commit 25febf7

Browse files
Unify helm installation functions
1 parent 30a6067 commit 25febf7

2 files changed

Lines changed: 6 additions & 39 deletions

File tree

codehub/cli/create.py

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from codehub.cli.gcp.helpers import authenticate_k8s_GKE
1414
from codehub.cli.k8s.create import create_k8s_resources
1515
from codehub.cli.helm.create import create_deploy
16-
from codehub.cli.helm.install import install_helm_chart, upgrade_helm_chart
16+
from codehub.cli.helm.install import install_helm_chart
1717
from codehub.cli.helpers import get_cloud_dir, get_latest_deployment, read_yaml
1818
from codehub.cli.manage import wait_for_hub_to_get_ready, get_ip
1919
import kubernetes.client.rest # Add this import for the exception handling
@@ -51,10 +51,8 @@ def create(config: CreateConfig):
5151

5252
__create_k8s_resources(deploy_config)
5353

54-
__install_helm_chart(
55-
deploy_config,
56-
admins=config.admins,
57-
)
54+
__create_deploy(deploy_config, admins=config.admins)
55+
install_helm_chart(deploy_config, upgrade=False)
5856

5957
wait_for_hub_to_get_ready(k8s_dir)
6058

@@ -74,12 +72,13 @@ def upgrade(name, admins, https=None, oauth_config: Optional[OAuthConfig] = None
7472
]
7573
deploy_config = DeployConfig(name, region, helm_dir, hub_dir, k8s_dir, cloud_state)
7674

77-
__upgrade_helm_chart(
75+
__create_deploy(
7876
deploy_config,
7977
admins=admins,
8078
https=https,
8179
oauth_config=oauth_config,
8280
)
81+
install_helm_chart(deploy_config, upgrade=True)
8382

8483
authenticate_k8s_GKE(name)
8584
wait_for_hub_to_get_ready(k8s_dir)
@@ -133,30 +132,6 @@ def __create_k8s_resources(deploy_config: DeployConfig):
133132
raise
134133

135134

136-
def __install_helm_chart(
137-
deploy_config: DeployConfig,
138-
admins,
139-
):
140-
__create_deploy(deploy_config, admins)
141-
install_helm_chart(deploy_config)
142-
143-
144-
def __upgrade_helm_chart(
145-
deploy_config: DeployConfig,
146-
admins,
147-
https=None,
148-
oauth_config: Optional[OAuthConfig] = None,
149-
):
150-
__create_deploy(
151-
deploy_config,
152-
admins=admins,
153-
https=https,
154-
oauth_config=oauth_config,
155-
)
156-
157-
upgrade_helm_chart(deploy_config)
158-
159-
160135
def __create_deploy(
161136
deploy_config: DeployConfig,
162137
admins,

codehub/cli/helm/install.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,7 @@
33
from codehub.cli.config import STRUCTURE, DeployConfig
44

55

6-
def install_helm_chart(deploy_config: DeployConfig):
7-
__upgrade_or_install_helm_chart(deploy_config, upgrade=False)
8-
9-
10-
def upgrade_helm_chart(deploy_config: DeployConfig):
11-
__upgrade_or_install_helm_chart(deploy_config, upgrade=True)
12-
13-
14-
def __upgrade_or_install_helm_chart(deploy_config: DeployConfig, upgrade=False):
6+
def install_helm_chart(deploy_config: DeployConfig, *, upgrade: bool):
157
chart_template_fp = os.path.join(STRUCTURE["templates"]["helm"], "chart.yaml")
168
chart_deploy_fp = os.path.join(deploy_config.helm_dir, "chart.yaml")
179

0 commit comments

Comments
 (0)