|
11 | 11 |
|
12 | 12 | import logging |
13 | 13 | import os |
14 | | -import six |
15 | 14 | import sys |
16 | 15 |
|
17 | | -from kubernetes import config |
18 | 16 | from ops.cli.parser import SubParserConfig |
19 | 17 | from ops.hierarchical.composition_config_generator import CompositionConfigGenerator |
20 | 18 |
|
@@ -76,32 +74,16 @@ def run(self, args, extra_args): |
76 | 74 | return dict(command=command) |
77 | 75 |
|
78 | 76 | 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'] |
83 | 81 | file_location = self.generate_eks_kube_config( |
84 | 82 | cluster_name, aws_profile, region) |
85 | 83 | os.environ['KUBECONFIG'] = file_location |
86 | 84 | 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) |
105 | 87 |
|
106 | 88 | def generate_eks_kube_config(self, cluster_name, aws_profile, region): |
107 | 89 | file_location = self.get_tmp_file() |
|
0 commit comments