4040 ALPHA_API ,
4141]
4242
43+ ERROR_MSG_TPL = (
44+ "{0} KUBERNETES_EXEC_INFO, defaulting to {1}. This is likely a "
45+ "bug in your Kubernetes client. Please update your Kubernetes "
46+ "client."
47+ )
48+ UNRECOGNIZED_MSG_TPL = (
49+ "Unrecognized API version in KUBERNETES_EXEC_INFO, defaulting to "
50+ "{0}. This is likely due to an outdated AWS "
51+ "CLI. Please update your AWS CLI."
52+ )
53+ DEPRECATION_MSG_TPL = (
54+ "Kubeconfig user entry is using deprecated API version {0}. Run "
55+ "'aws eks update-kubeconfig' to update."
56+ )
57+
4358# Presigned url timeout in seconds
4459URL_TIMEOUT = 60
4560
@@ -131,27 +146,12 @@ def discover_api_version(self):
131146 "empty" : "Empty" ,
132147 }
133148
134- error_msg_tpl = (
135- "{0} KUBERNETES_EXEC_INFO, defaulting to {1}. This is likely a "
136- "bug in your Kubernetes client. Please update your Kubernetes "
137- "client."
138- )
139- unrecognized_msg = (
140- "Unrecognized API version in KUBERNETES_EXEC_INFO, defaulting to "
141- f"{ fallback_api_version } . This is likely due to an outdated AWS "
142- "CLI. Please update your AWS CLI."
143- )
144- deprecation_msg_tpl = (
145- "Kubeconfig user entry is using deprecated API version {0}. Run "
146- "'aws eks update-kubeconfig' to update."
147- )
148-
149149 exec_info_raw = os .environ .get ("KUBERNETES_EXEC_INFO" , "" )
150150 if not exec_info_raw :
151151 # All kube clients should be setting this. Otherewise, we'll return
152152 # the fallback and write an error.
153153 uni_print (
154- error_msg_tpl .format (
154+ ERROR_MSG_TPL .format (
155155 error_prefixes ["empty" ],
156156 fallback_api_version ,
157157 ),
@@ -164,7 +164,7 @@ def discover_api_version(self):
164164 except json .JSONDecodeError :
165165 # The environment variable was malformed
166166 uni_print (
167- error_msg_tpl .format (
167+ ERROR_MSG_TPL .format (
168168 error_prefixes ["error" ],
169169 fallback_api_version ,
170170 ),
@@ -177,12 +177,14 @@ def discover_api_version(self):
177177 if api_version_raw in FULLY_SUPPORTED_API_VERSIONS :
178178 return api_version_raw
179179 elif api_version_raw in DEPRECATED_API_VERSIONS :
180- uni_print (deprecation_msg_tpl .format (ALPHA_API ), sys .stderr )
180+ uni_print (DEPRECATION_MSG_TPL .format (ALPHA_API ), sys .stderr )
181181 uni_print ("\n " , sys .stderr )
182182 return api_version_raw
183183 else :
184- # write unrecognized api version message
185- uni_print (unrecognized_msg , sys .stderr )
184+ uni_print (
185+ UNRECOGNIZED_MSG_TPL .format (fallback_api_version ),
186+ sys .stderr ,
187+ )
186188 uni_print ("\n " , sys .stderr )
187189 return fallback_api_version
188190
0 commit comments