Skip to content

Commit 4de48ad

Browse files
authored
added exception when cluster.fqdn missing (#85)
* added exception when cluster.fqdn missing * [RELEASE] - Release version 1.11.8 * added option to continue with current context * added exception error msg * Revert "[RELEASE] - Release version 1.11.8" This reverts commit 29a5c57.
1 parent 03abc80 commit 4de48ad

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/ops/cli/helmfile.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111

1212
import logging
1313
import os
14+
import six
15+
import sys
1416

17+
from kubernetes import config
1518
from ops.cli.parser import SubParserConfig
1619
from ops.hierarchical.composition_config_generator import CompositionConfigGenerator
1720

@@ -87,6 +90,25 @@ def setup_kube_config(self, data):
8790
file_location = self.generate_eks_kube_config(
8891
cluster_name, aws_profile, region)
8992
os.environ['KUBECONFIG'] = file_location
93+
else:
94+
logger.info('cluster.fqdn key missing in cluster definition'
95+
'\n unable to generate EKS kubeconfig\n '
96+
'looking for system kubernetes context')
97+
98+
try:
99+
contexts, active_context = config.list_kube_config_contexts()
100+
except Exception as ex:
101+
logger.error('could not find system kubeconfig context')
102+
logger.error(ex)
103+
sys.exit()
104+
105+
logger.info('current default context is:\n %s '
106+
'\n do you want to proceed with this context?',
107+
active_context)
108+
answer = six.moves.input("Only 'yes' will be accepted to approve.\n Enter a value:")
109+
if answer != "yes":
110+
sys.exit()
111+
90112

91113
def generate_eks_kube_config(self, cluster_name, aws_profile, region):
92114
file_location = self.get_tmp_file()

0 commit comments

Comments
 (0)