Skip to content

Commit 857c1c7

Browse files
Merge branch 'develop' into 'update-v2'
2 parents c5f9865 + 1f6b68f commit 857c1c7

File tree

8 files changed

+290
-48
lines changed

8 files changed

+290
-48
lines changed

.changes/1.27.106.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[
2+
{
3+
"category": "``amplifyuibuilder``",
4+
"description": "Support StorageField and custom displays for data-bound options in form builder. Support non-string operands for predicates in collections. Support choosing client to get token from.",
5+
"type": "api-change"
6+
},
7+
{
8+
"category": "``autoscaling``",
9+
"description": "Documentation updates for Amazon EC2 Auto Scaling",
10+
"type": "api-change"
11+
},
12+
{
13+
"category": "``dataexchange``",
14+
"description": "This release updates the value of MaxResults.",
15+
"type": "api-change"
16+
},
17+
{
18+
"category": "``ec2``",
19+
"description": "C6in, M6in, M6idn, R6in and R6idn bare metal instances are powered by 3rd Generation Intel Xeon Scalable processors and offer up to 200 Gbps of network bandwidth.",
20+
"type": "api-change"
21+
},
22+
{
23+
"category": "``elastic-inference``",
24+
"description": "Updated public documentation for the Describe and Tagging APIs.",
25+
"type": "api-change"
26+
},
27+
{
28+
"category": "``sagemaker-runtime``",
29+
"description": "Update sagemaker-runtime command to latest version",
30+
"type": "api-change"
31+
},
32+
{
33+
"category": "``sagemaker``",
34+
"description": "Amazon SageMaker Asynchronous Inference now allows customer's to receive failure model responses in S3 and receive success/failure model responses in SNS notifications.",
35+
"type": "api-change"
36+
},
37+
{
38+
"category": "``wafv2``",
39+
"description": "This release rolls back association config feature for webACLs that protect CloudFront protections.",
40+
"type": "api-change"
41+
}
42+
]

.changes/1.27.107.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[
2+
{
3+
"category": "eks",
4+
"description": "Fix eks kubeconfig validations closes `#6564 <https://github.com/aws/aws-cli/issues/6564>`__, fixes `#4843 <https://github.com/aws/aws-cli/issues/4843>`__, fixes `#5532 <https://github.com/aws/aws-cli/issues/5532>`__",
5+
"type": "bugfix"
6+
},
7+
{
8+
"category": "``apprunner``",
9+
"description": "App Runner adds support for seven new vCPU and memory configurations.",
10+
"type": "api-change"
11+
},
12+
{
13+
"category": "``config``",
14+
"description": "This release adds resourceType enums for types released in March 2023.",
15+
"type": "api-change"
16+
},
17+
{
18+
"category": "``ecs``",
19+
"description": "This is a document only updated to add information about Amazon Elastic Inference (EI).",
20+
"type": "api-change"
21+
},
22+
{
23+
"category": "``identitystore``",
24+
"description": "Documentation updates for Identity Store CLI command reference.",
25+
"type": "api-change"
26+
},
27+
{
28+
"category": "``ivs-realtime``",
29+
"description": "Fix ParticipantToken ExpirationTime format",
30+
"type": "api-change"
31+
},
32+
{
33+
"category": "``network-firewall``",
34+
"description": "AWS Network Firewall now supports IPv6-only subnets.",
35+
"type": "api-change"
36+
},
37+
{
38+
"category": "``servicecatalog``",
39+
"description": "removed incorrect product type value",
40+
"type": "api-change"
41+
},
42+
{
43+
"category": "``vpc-lattice``",
44+
"description": "This release removes the entities in the API doc model package for auth policies.",
45+
"type": "api-change"
46+
}
47+
]

CHANGELOG.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5161,6 +5161,33 @@ CHANGELOG
51615161
* feature:wizard: Added support for AWS CLI Wizards. See `#3752 <https://github.com/aws/aws-cli/issues/3752>`__.
51625162

51635163

5164+
1.27.107
5165+
========
5166+
5167+
* bugfix:eks: Fix eks kubeconfig validations closes `#6564 <https://github.com/aws/aws-cli/issues/6564>`__, fixes `#4843 <https://github.com/aws/aws-cli/issues/4843>`__, fixes `#5532 <https://github.com/aws/aws-cli/issues/5532>`__
5168+
* api-change:``apprunner``: App Runner adds support for seven new vCPU and memory configurations.
5169+
* api-change:``config``: This release adds resourceType enums for types released in March 2023.
5170+
* api-change:``ecs``: This is a document only updated to add information about Amazon Elastic Inference (EI).
5171+
* api-change:``identitystore``: Documentation updates for Identity Store CLI command reference.
5172+
* api-change:``ivs-realtime``: Fix ParticipantToken ExpirationTime format
5173+
* api-change:``network-firewall``: AWS Network Firewall now supports IPv6-only subnets.
5174+
* api-change:``servicecatalog``: removed incorrect product type value
5175+
* api-change:``vpc-lattice``: This release removes the entities in the API doc model package for auth policies.
5176+
5177+
5178+
1.27.106
5179+
========
5180+
5181+
* api-change:``amplifyuibuilder``: Support StorageField and custom displays for data-bound options in form builder. Support non-string operands for predicates in collections. Support choosing client to get token from.
5182+
* api-change:``autoscaling``: Documentation updates for Amazon EC2 Auto Scaling
5183+
* api-change:``dataexchange``: This release updates the value of MaxResults.
5184+
* api-change:``ec2``: C6in, M6in, M6idn, R6in and R6idn bare metal instances are powered by 3rd Generation Intel Xeon Scalable processors and offer up to 200 Gbps of network bandwidth.
5185+
* api-change:``elastic-inference``: Updated public documentation for the Describe and Tagging APIs.
5186+
* api-change:``sagemaker-runtime``: Update sagemaker-runtime command to latest version
5187+
* api-change:``sagemaker``: Amazon SageMaker Asynchronous Inference now allows customer's to receive failure model responses in S3 and receive success/failure model responses in SNS notifications.
5188+
* api-change:``wafv2``: This release rolls back association config feature for webACLs that protect CloudFront protections.
5189+
5190+
51645191
1.27.105
51655192
========
51665193

awscli/customizations/eks/kubeconfig.py

Lines changed: 46 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ def has_cluster(self, name):
6565
Return true if this kubeconfig contains an entry
6666
For the passed cluster name.
6767
"""
68-
if 'clusters' not in self.content:
68+
if self.content.get('clusters') is None:
6969
return False
7070
return name in [cluster['name']
71-
for cluster in self.content['clusters']]
71+
for cluster in self.content['clusters'] if 'name' in cluster]
7272

7373

7474
class KubeconfigValidator(object):
@@ -86,7 +86,7 @@ def validate_config(self, config):
8686
"""
8787
if not isinstance(config, Kubeconfig):
8888
raise KubeconfigCorruptedError("Internal error: "
89-
"Not a Kubeconfig object.")
89+
f"Not a {Kubeconfig}.")
9090
self._validate_config_types(config)
9191
self._validate_list_entry_types(config)
9292

@@ -99,18 +99,14 @@ def _validate_config_types(self, config):
9999
:type config: Kubeconfig
100100
"""
101101
if not isinstance(config.content, dict):
102-
raise KubeconfigCorruptedError("Content not a dictionary.")
102+
raise KubeconfigCorruptedError(f"Content not a {dict}.")
103103
for key, value in self._validation_content.items():
104104
if (key in config.content and
105105
config.content[key] is not None and
106106
not isinstance(config.content[key], type(value))):
107107
raise KubeconfigCorruptedError(
108-
"{0} is wrong type:{1} "
109-
"(Should be {2})".format(
110-
key,
111-
type(config.content[key]),
112-
type(value)
113-
)
108+
f"{key} is wrong type: {type(config.content[key])} "
109+
f"(Should be {type(value)})"
114110
)
115111

116112
def _validate_list_entry_types(self, config):
@@ -127,14 +123,14 @@ def _validate_list_entry_types(self, config):
127123
for element in config.content[key]:
128124
if not isinstance(element, OrderedDict):
129125
raise KubeconfigCorruptedError(
130-
"Entry in {0} not a dictionary.".format(key))
126+
f"Entry in {key} not a {dict}. ")
131127

132128

133129
class KubeconfigLoader(object):
134-
def __init__(self, validator=None):
130+
def __init__(self, validator = None):
135131
if validator is None:
136-
validator = KubeconfigValidator()
137-
self._validator = validator
132+
validator=KubeconfigValidator()
133+
self._validator=validator
138134

139135
def load_kubeconfig(self, path):
140136
"""
@@ -158,15 +154,15 @@ def load_kubeconfig(self, path):
158154
loaded_content = ordered_yaml_load(stream)
159155
except IOError as e:
160156
if e.errno == errno.ENOENT:
161-
loaded_content = None
157+
loaded_content=None
162158
else:
163159
raise KubeconfigInaccessableError(
164-
"Can't open kubeconfig for reading: {0}".format(e))
160+
f"Can't open kubeconfig for reading: {e}")
165161
except yaml.YAMLError as e:
166162
raise KubeconfigCorruptedError(
167-
"YamlError while loading kubeconfig: {0}".format(e))
163+
f"YamlError while loading kubeconfig: {e}")
168164

169-
loaded_config = Kubeconfig(path, loaded_content)
165+
loaded_config=Kubeconfig(path, loaded_content)
170166
self._validator.validate_config(loaded_config)
171167

172168
return loaded_config
@@ -184,56 +180,58 @@ def write_kubeconfig(self, config):
184180
:raises KubeconfigInaccessableError: if the kubeconfig
185181
can't be opened for writing
186182
"""
187-
directory = os.path.dirname(config.path)
183+
directory=os.path.dirname(config.path)
188184

189185
try:
190186
os.makedirs(directory)
191187
except OSError as e:
192188
if e.errno != errno.EEXIST:
193189
raise KubeconfigInaccessableError(
194-
"Can't create directory for writing: {0}".format(e))
190+
f"Can't create directory for writing: {e}")
195191
try:
196192
with compat_open(
197193
config.path, "w+", access_permissions=0o600) as stream:
198194
ordered_yaml_dump(config.content, stream)
199195
except IOError as e:
200196
raise KubeconfigInaccessableError(
201-
"Can't open kubeconfig for writing: {0}".format(e))
197+
f"Can't open kubeconfig for writing: {e}")
202198

203199

204200
class KubeconfigAppender(object):
205-
def insert_entry(self, config, key, entry):
201+
def insert_entry(self, config, key, new_entry):
206202
"""
207-
Insert entry into the array at content[key]
203+
Insert entry into the entries list at content[key]
208204
Overwrite an existing entry if they share the same name
209205
210206
:param config: The kubeconfig to insert an entry into
211207
:type config: Kubeconfig
212208
"""
213-
if key not in config.content:
214-
config.content[key] = []
215-
array = config.content[key]
216-
if not isinstance(array, list):
217-
raise KubeconfigError("Tried to insert into {0},"
218-
"which is a {1} "
219-
"not a {2}".format(key,
220-
type(array),
221-
list))
222-
found = False
223-
for counter, existing_entry in enumerate(array):
224-
if "name" in existing_entry and\
225-
"name" in entry and\
226-
existing_entry["name"] == entry["name"]:
227-
array[counter] = entry
228-
found = True
229-
230-
if not found:
231-
array.append(entry)
232-
233-
config.content[key] = array
209+
entries=self._setdefault_existing_entries(config, key)
210+
same_name_index=self._index_same_name(entries, new_entry)
211+
if same_name_index is None:
212+
entries.append(new_entry)
213+
else:
214+
entries[same_name_index]=new_entry
234215
return config
235216

236-
def _make_context(self, cluster, user, alias=None):
217+
def _setdefault_existing_entries(self, config, key):
218+
config.content[key]=config.content.get(key) or []
219+
entries=config.content[key]
220+
if not isinstance(entries, list):
221+
raise KubeconfigError(f"Tried to insert into {key}, "
222+
f"which is a {type(entries)} "
223+
f"not a {list}")
224+
return entries
225+
226+
def _index_same_name(self, entries, new_entry):
227+
if "name" in new_entry:
228+
name_to_search=new_entry["name"]
229+
for i, entry in enumerate(entries):
230+
if "name" in entry and entry["name"] == name_to_search:
231+
return i
232+
return None
233+
234+
def _make_context(self, cluster, user, alias = None):
237235
""" Generate a context to associate cluster and user with a given alias."""
238236
return OrderedDict([
239237
("context", OrderedDict([
@@ -243,7 +241,7 @@ def _make_context(self, cluster, user, alias=None):
243241
("name", alias or user["name"])
244242
])
245243

246-
def insert_cluster_user_pair(self, config, cluster, user, alias=None):
244+
def insert_cluster_user_pair(self, config, cluster, user, alias = None):
247245
"""
248246
Insert the passed cluster entry and user entry,
249247
then make a context to associate them
@@ -265,11 +263,11 @@ def insert_cluster_user_pair(self, config, cluster, user, alias=None):
265263
:return: The generated context
266264
:rtype: OrderedDict
267265
"""
268-
context = self._make_context(cluster, user, alias=alias)
266+
context=self._make_context(cluster, user, alias = alias)
269267
self.insert_entry(config, "clusters", cluster)
270268
self.insert_entry(config, "users", user)
271269
self.insert_entry(config, "contexts", context)
272270

273-
config.content["current-context"] = context["name"]
271+
config.content["current-context"]=context["name"]
274272

275273
return context
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v1
2+
clusters: null
3+
contexts:
4+
- context:
5+
cluster: arn:aws:eks:us-west-2:111222333444:cluster/Existing
6+
user: arn:aws:eks:us-west-2:111222333444:cluster/Existing
7+
name: arn:aws:eks:us-west-2:111222333444:cluster/Existing
8+
current-context: arn:aws:eks:us-west-2:111222333444:cluster/Existing
9+
kind: Config
10+
preferences: {}
11+
users:
12+
- name: arn:aws:eks:us-west-2:111222333444:cluster/Existing
13+
user:
14+
exec:
15+
apiVersion: client.authentication.k8s.io/v1alpha1
16+
args:
17+
- --region
18+
- us-west-2
19+
- eks
20+
- get-token
21+
- --cluster-name
22+
- Existing
23+
command: aws
24+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v1
2+
contexts: null
3+
clusters:
4+
- cluster:
5+
certificate-authority-data: DATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATA=
6+
server: https://existingEndpoint.eks.amazonaws.com
7+
name: arn:aws:eks:us-west-2:111222333444:cluster/Existing
8+
current-context: arn:aws:eks:us-west-2:111222333444:cluster/Existing
9+
kind: Config
10+
preferences: {}
11+
users:
12+
- name: arn:aws:eks:us-west-2:111222333444:cluster/Existing
13+
user:
14+
exec:
15+
apiVersion: client.authentication.k8s.io/v1alpha1
16+
args:
17+
- --region
18+
- us-west-2
19+
- eks
20+
- get-token
21+
- --cluster-name
22+
- Existing
23+
command: aws
24+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
clusters:
3+
- cluster:
4+
certificate-authority-data: DATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATA=
5+
server: https://existingEndpoint.eks.amazonaws.com
6+
name: arn:aws:eks:us-west-2:111222333444:cluster/Existing
7+
contexts:
8+
- context:
9+
cluster: arn:aws:eks:us-west-2:111222333444:cluster/Existing
10+
user: arn:aws:eks:us-west-2:111222333444:cluster/Existing
11+
name: arn:aws:eks:us-west-2:111222333444:cluster/Existing
12+
current-context: arn:aws:eks:us-west-2:111222333444:cluster/Existing
13+
users: null
14+
kind: Config
15+
preferences: {}
16+

0 commit comments

Comments
 (0)