File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 1111
1212import logging
1313import os
14+ import six
15+ import sys
1416
17+ from kubernetes import config
1518from ops .cli .parser import SubParserConfig
1619from 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 ()
You can’t perform that action at this time.
0 commit comments