Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit d2fa53d

Browse files
Fix help text and parameter naming for bucket
1 parent c07cf2f commit d2fa53d

File tree

8 files changed

+75
-61
lines changed

8 files changed

+75
-61
lines changed

src/k8s-configuration/HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Release History
44
===============
55

6+
1.4.1
7+
++++++++++++++++++
8+
* Prepend bucket parameters with "bucket" keyword
9+
* Fix some help text
10+
611
1.4.0
712
++++++++++++++++++
813
* Add `--kind bucket` for creation of S3 bucket as source for fluxConfigurations

src/k8s-configuration/azext_k8s_configuration/_help.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
--name myconfig --scope cluster --namespace my-namespace \\
9494
--kind bucket --url https://bucket-provider.minio.io \\
9595
--bucket-name my-bucket --kustomization name=my-kustomization \\
96-
--access-key my-access-key --secret-key my-secret-key
96+
--bucket-access-key my-access-key --bucket-secret-key my-secret-key
9797
"""
9898

9999
helps[
@@ -108,6 +108,11 @@
108108
--cluster-name mycluster --cluster-type connectedClusters --name myconfig \\
109109
--url https://github.com/Azure/arc-k8s-demo --branch main \\
110110
--kustomization name=my-kustomization path=./my/new-path
111+
- name: Update a Flux v2 Kubernetse configuration with Bucket Source Kind to connect insecurely
112+
text: |-
113+
az k8s-configuration flux update --resource-group my-resource-group \\
114+
--cluster-name mycluster --cluster-type connectedClusters --name myconfig \\
115+
--bucket-insecure
111116
"""
112117

113118
helps[

src/k8s-configuration/azext_k8s_configuration/_params.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,23 +137,23 @@ def load_arguments(self, _):
137137
help="File path to known_hosts contents containing public SSH keys required to access private Git instances",
138138
)
139139
c.argument(
140-
"access_key",
140+
"bucket_access_key",
141141
arg_group="Bucket Auth",
142-
help="Access Key Id used to authenticate with the bucket url",
142+
help="Access Key ID used to authenticate with the bucket",
143143
)
144144
c.argument(
145-
"secret_key",
145+
"bucket_secret_key",
146146
arg_group="Bucket Auth",
147-
help="Secret Key used to authenticate with the bucket url",
147+
help="Secret Key used to authenticate with the bucket",
148148
)
149149
c.argument(
150150
"bucket_name",
151-
help="Name of the S3 bucket at the given url to connect to",
151+
help="Name of the S3 bucket to sync",
152152
)
153153
c.argument(
154-
"insecure",
154+
"bucket_insecure",
155155
arg_type=get_three_state_flag(),
156-
help="Communicate with a bucket without TLS",
156+
help="Communicate with a bucket without TLS. Default: false",
157157
)
158158
c.argument(
159159
"local_auth_ref",
@@ -164,7 +164,7 @@ def load_arguments(self, _):
164164
c.argument(
165165
"suspend",
166166
arg_type=get_three_state_flag(),
167-
help="Suspend the reconciliation of the source and kustomizations associated with this configuration",
167+
help="Suspend the reconciliation of the source and kustomizations associated with this configuration. Default: false",
168168
)
169169
c.argument(
170170
"kustomization",
@@ -333,12 +333,12 @@ def load_arguments(self, _):
333333
c.argument(
334334
"prune",
335335
arg_type=get_three_state_flag(),
336-
help="Garbage collect resources deployed by the kustomization on the cluster",
336+
help="Garbage collect resources deployed by the kustomization on the cluster. Default: false",
337337
)
338338
c.argument(
339339
"force",
340340
arg_type=get_three_state_flag(),
341-
help="Re-create resources that cannot be updated on the cluster (i.e. jobs)",
341+
help="Re-create resources that cannot be updated on the cluster (i.e. jobs). Default: false",
342342
)
343343

344344
with self.argument_context("k8s-configuration flux kustomization delete") as c:

src/k8s-configuration/azext_k8s_configuration/consts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@
209209
"bucket_name",
210210
"sync_interval",
211211
"timeout",
212-
"access_key",
213-
"secret_key",
214-
"insecure",
212+
"bucket_access_key",
213+
"bucket_secret_key",
214+
"bucket_insecure",
215215
"local_auth_ref",
216216
}
217217

src/k8s-configuration/azext_k8s_configuration/providers/FluxConfigurationProvider.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ def create_config(
144144
https_ca_cert_file=None,
145145
known_hosts=None,
146146
known_hosts_file=None,
147-
access_key=None,
148-
secret_key=None,
149-
insecure=False,
147+
bucket_access_key=None,
148+
bucket_secret_key=None,
149+
bucket_insecure=False,
150150
suspend=False,
151151
kustomization=None,
152152
no_wait=False,
@@ -175,9 +175,9 @@ def create_config(
175175
https_ca_cert_file=https_ca_cert_file,
176176
known_hosts=known_hosts,
177177
known_hosts_file=known_hosts_file,
178-
access_key=access_key,
179-
secret_key=secret_key,
180-
insecure=insecure,
178+
bucket_access_key=bucket_access_key,
179+
bucket_secret_key=bucket_secret_key,
180+
bucket_insecure=bucket_insecure,
181181
)
182182

183183
# This update func is a generated update function that modifies
@@ -193,7 +193,7 @@ def create_config(
193193

194194
# Get the protected settings and validate the private key value
195195
protected_settings = get_protected_settings(
196-
ssh_private_key, ssh_private_key_file, https_key, secret_key
196+
ssh_private_key, ssh_private_key_file, https_key, bucket_secret_key
197197
)
198198
if protected_settings and consts.SSH_PRIVATE_KEY_KEY in protected_settings:
199199
validate_private_key(protected_settings["sshPrivateKey"])
@@ -256,9 +256,9 @@ def update_config(
256256
https_ca_cert_file=None,
257257
known_hosts=None,
258258
known_hosts_file=None,
259-
access_key=None,
260-
secret_key=None,
261-
insecure=None,
259+
bucket_access_key=None,
260+
bucket_secret_key=None,
261+
bucket_insecure=None,
262262
suspend=None,
263263
kustomization=None,
264264
no_wait=False,
@@ -293,9 +293,9 @@ def update_config(
293293
https_ca_cert_file=https_ca_cert_file,
294294
known_hosts=known_hosts,
295295
known_hosts_file=known_hosts_file,
296-
access_key=access_key,
297-
secret_key=secret_key,
298-
insecure=insecure,
296+
bucket_access_key=bucket_access_key,
297+
bucket_secret_key=bucket_secret_key,
298+
bucket_insecure=bucket_insecure,
299299
)
300300

301301
# This update func is a generated update function that modifies
@@ -324,7 +324,7 @@ def update_config(
324324

325325
# Get the protected settings and validate the private key value
326326
protected_settings = get_protected_settings(
327-
ssh_private_key, ssh_private_key_file, https_key, secret_key
327+
ssh_private_key, ssh_private_key_file, https_key, bucket_secret_key
328328
)
329329
if protected_settings and consts.SSH_PRIVATE_KEY_KEY in protected_settings:
330330
validate_private_key(protected_settings["sshPrivateKey"])
@@ -968,15 +968,17 @@ def __init__(self, **kwargs):
968968
self.bucket_name = kwargs.get("bucket_name")
969969
self.timeout = kwargs.get("timeout")
970970
self.sync_interval = kwargs.get("sync_interval")
971-
self.access_key = kwargs.get("access_key")
972-
self.secret_key = kwargs.get("secret_key")
971+
self.bucket_access_key = kwargs.get("bucket_access_key")
972+
self.bucket_secret_key = kwargs.get("bucket_secret_key")
973973
self.local_auth_ref = kwargs.get("local_auth_ref")
974-
self.insecure = kwargs.get("insecure")
974+
self.bucket_insecure = kwargs.get("bucket_insecure")
975975

976976
def validate(self):
977977
super().validate_required_params(**self.kwargs)
978978
validate_bucket_url(self.url)
979-
if not ((self.access_key and self.secret_key) or self.local_auth_ref):
979+
if not (
980+
(self.bucket_access_key and self.bucket_secret_key) or self.local_auth_ref
981+
):
980982
raise RequiredArgumentMissingError(
981983
consts.REQUIRED_BUCKET_VALUES_MISSING_ERROR,
982984
consts.REQUIRED_BUCKET_VALUES_MISSING_HELP,
@@ -995,9 +997,9 @@ def bucket_updater(config):
995997
bucket_name=self.bucket_name,
996998
timeout_in_seconds=parse_duration(self.timeout),
997999
sync_interval_in_seconds=parse_duration(self.sync_interval),
998-
access_key=self.access_key,
1000+
access_key=self.bucket_access_key,
9991001
local_auth_ref=self.local_auth_ref,
1000-
insecure=self.insecure,
1002+
insecure=self.bucket_insecure,
10011003
)
10021004
config.source_kind = SourceKindType.BUCKET
10031005
return config
@@ -1018,9 +1020,9 @@ def bucket_patch_updater(config):
10181020
bucket_name=self.bucket_name,
10191021
timeout_in_seconds=parse_duration(self.timeout),
10201022
sync_interval_in_seconds=parse_duration(self.sync_interval),
1021-
access_key=self.access_key,
1023+
access_key=self.bucket_access_key,
10221024
local_auth_ref=self.local_auth_ref,
1023-
insecure=self.insecure,
1025+
insecure=self.bucket_insecure,
10241026
)
10251027
if swapped_kind:
10261028
self.validate()
@@ -1032,7 +1034,7 @@ def bucket_patch_updater(config):
10321034

10331035

10341036
def get_protected_settings(
1035-
ssh_private_key, ssh_private_key_file, https_key, secret_key
1037+
ssh_private_key, ssh_private_key_file, https_key, bucket_secret_key
10361038
):
10371039
protected_settings = {}
10381040
ssh_private_key_data = get_data_from_key_or_file(
@@ -1046,8 +1048,8 @@ def get_protected_settings(
10461048
if https_key:
10471049
protected_settings[consts.HTTPS_KEY_KEY] = to_base64(https_key)
10481050

1049-
if secret_key:
1050-
protected_settings[consts.BUCKET_SECRET_KEY_KEY] = to_base64(secret_key)
1051+
if bucket_secret_key:
1052+
protected_settings[consts.BUCKET_SECRET_KEY_KEY] = to_base64(bucket_secret_key)
10511053

10521054
# Return the protected settings dict if there are any values there
10531055
return protected_settings if len(protected_settings) > 0 else None

src/k8s-configuration/setup.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,49 @@
88

99
from codecs import open
1010
from setuptools import setup, find_packages
11+
1112
try:
1213
from azure_bdist_wheel import cmdclass
1314
except ImportError:
1415
from distutils import log as logger
16+
1517
logger.warn("Wheel is not available, disabling bdist_wheel hook")
1618

17-
VERSION = '1.4.0'
19+
VERSION = "1.4.1"
1820

1921
# The full list of classifiers is available at
2022
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
2123
CLASSIFIERS = [
22-
'Development Status :: 4 - Beta',
23-
'Intended Audience :: Developers',
24-
'Intended Audience :: System Administrators',
25-
'Programming Language :: Python',
26-
'Programming Language :: Python :: 3',
27-
'Programming Language :: Python :: 3.6',
28-
'Programming Language :: Python :: 3.7',
29-
'Programming Language :: Python :: 3.8',
30-
'License :: OSI Approved :: MIT License',
24+
"Development Status :: 4 - Beta",
25+
"Intended Audience :: Developers",
26+
"Intended Audience :: System Administrators",
27+
"Programming Language :: Python",
28+
"Programming Language :: Python :: 3",
29+
"Programming Language :: Python :: 3.6",
30+
"Programming Language :: Python :: 3.7",
31+
"Programming Language :: Python :: 3.8",
32+
"License :: OSI Approved :: MIT License",
3133
]
3234

3335
DEPENDENCIES = ["pycryptodome~=3.9.8"]
3436

35-
with open('README.rst', 'r', encoding='utf-8') as f:
37+
with open("README.rst", "r", encoding="utf-8") as f:
3638
README = f.read()
37-
with open('HISTORY.rst', 'r', encoding='utf-8') as f:
39+
with open("HISTORY.rst", "r", encoding="utf-8") as f:
3840
HISTORY = f.read()
3941

4042
setup(
41-
name='k8s-configuration',
43+
name="k8s-configuration",
4244
version=VERSION,
43-
description='Microsoft Azure Command-Line Tools K8s-configuration Extension',
45+
description="Microsoft Azure Command-Line Tools K8s-configuration Extension",
4446
# TODO: Update author and email, if applicable
45-
author='Microsoft Corporation',
46-
author_email='[email protected]',
47-
url='https://github.com/Azure/azure-cli-extensions/tree/master/src/k8s-configuration',
48-
long_description=README + '\n\n' + HISTORY,
49-
license='MIT',
47+
author="Microsoft Corporation",
48+
author_email="[email protected]",
49+
url="https://github.com/Azure/azure-cli-extensions/tree/master/src/k8s-configuration",
50+
long_description=README + "\n\n" + HISTORY,
51+
license="MIT",
5052
classifiers=CLASSIFIERS,
5153
packages=find_packages(),
5254
install_requires=DEPENDENCIES,
53-
package_data={'azext_k8s_configuration': ['azext_metadata.json']},
55+
package_data={"azext_k8s_configuration": ["azext_metadata.json"]},
5456
)

testing/test/configurations/Flux.Bucket.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Describe 'Bucket Flux Configuration Testing' {
66
}
77

88
It 'Creates a configuration and checks that it onboards correctly' {
9-
az k8s-configuration flux create -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type "connectedClusters" --kind bucket -u "http://52.190.35.89" --bucket-name flux -n $configurationName --scope cluster --namespace $configurationName --access-key test --secret-key test --no-wait
9+
az k8s-configuration flux create -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type "connectedClusters" --kind bucket -u "http://52.190.35.89" --bucket-name flux -n $configurationName --scope cluster --namespace $configurationName --bucket-access-key test --bucket-secret-key test --no-wait
1010
$? | Should -BeTrue
1111

1212
# Loop and retry until the configuration installs

testing/test/configurations/Flux.CrossKind.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Describe 'Bucket Flux Configuration Testing' {
66
}
77

88
It 'Creates a configuration and checks that it onboards correctly' {
9-
az k8s-configuration flux create -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type "connectedClusters" --kind bucket -u "http://52.190.35.89" --bucket-name flux -n $configurationName --scope cluster --namespace $configurationName --access-key test --secret-key test --no-wait
9+
az k8s-configuration flux create -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type "connectedClusters" --kind bucket -u "http://52.190.35.89" --bucket-name flux -n $configurationName --scope cluster --namespace $configurationName --bucket-access-key test --bucket-secret-key test --no-wait
1010
$? | Should -BeTrue
1111

1212
# Loop and retry until the configuration installs

0 commit comments

Comments
 (0)