Skip to content

Commit ecb70d9

Browse files
authored
Removed default context fallback (#90)
* modified setup_kube_config to not use default kube context * PEP-8 cosmetic * logger.info to logger.warning
1 parent b69d05e commit ecb70d9

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

src/ops/cli/helmfile.py

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111

1212
import logging
1313
import os
14-
import six
1514
import sys
1615

17-
from kubernetes import config
1816
from ops.cli.parser import SubParserConfig
1917
from ops.hierarchical.composition_config_generator import CompositionConfigGenerator
2018

@@ -76,32 +74,16 @@ def run(self, args, extra_args):
7674
return dict(command=command)
7775

7876
def setup_kube_config(self, data):
79-
if 'cluster' in data and 'fqdn' in data['cluster'] and 'eks' in data['cluster']['fqdn']:
80-
cluster_name = data['cluster']['fqdn']
81-
aws_profile = data['account']['name']
82-
region = data['region']['location']
77+
if data['helm']['global']['clusterType'] == 'eks':
78+
cluster_name = data['helm']['global']['fqdn']
79+
aws_profile = data['helm']['global']['aws']['name']
80+
region = data['helm']['global']['region']['location']
8381
file_location = self.generate_eks_kube_config(
8482
cluster_name, aws_profile, region)
8583
os.environ['KUBECONFIG'] = file_location
8684
else:
87-
logger.info('cluster.fqdn key missing in cluster definition'
88-
'\n unable to generate EKS kubeconfig\n '
89-
'looking for system kubernetes context')
90-
91-
try:
92-
contexts, active_context = config.list_kube_config_contexts()
93-
except Exception as ex:
94-
logger.error('could not find system kubeconfig context')
95-
logger.error(ex)
96-
sys.exit()
97-
98-
logger.info('current default context is:\n %s '
99-
'\n do you want to proceed with this context?',
100-
active_context)
101-
answer = six.moves.input("Only 'yes' will be accepted to approve.\n Enter a value:")
102-
if answer != "yes":
103-
sys.exit()
104-
85+
logger.warning('currently only eks type clusters supported')
86+
sys.exit(1)
10587

10688
def generate_eks_kube_config(self, cluster_name, aws_profile, region):
10789
file_location = self.get_tmp_file()

0 commit comments

Comments
 (0)