Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Bucket Support in the CLI #92

Merged
merged 12 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ignore =
F401, # imported but unused, too many violations, to be removed in the future
F811, # redefinition of unused, to be removed in the future
C901 # code flow is too complex, too many violations, to be removed in the future
W503 # line break before binary operator effect on readability is subjective
W504 # line break after binary operator effect on readability is subjective
exclude =
*/vendored_sdks
Expand Down
12 changes: 7 additions & 5 deletions src/k8s-configuration/azext_k8s_configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,25 @@


class K8sConfigurationCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_k8s_configuration._client_factory import k8s_configuration_client

k8s_configuration_custom = CliCommandType(
operations_tmpl='azext_k8s_configuration.custom#{}',
client_factory=k8s_configuration_client)
super().__init__(cli_ctx=cli_ctx,
custom_command_type=k8s_configuration_custom)
operations_tmpl="azext_k8s_configuration.custom#{}",
client_factory=k8s_configuration_client,
)
super().__init__(cli_ctx=cli_ctx, custom_command_type=k8s_configuration_custom)

def load_command_table(self, args):
from azext_k8s_configuration.commands import load_command_table

load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from azext_k8s_configuration._params import load_arguments

load_arguments(self, command)


Expand Down
32 changes: 22 additions & 10 deletions src/k8s-configuration/azext_k8s_configuration/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,51 @@

def k8s_configuration_client(cli_ctx, **kwargs):
from azext_k8s_configuration.vendored_sdks import SourceControlConfigurationClient

return get_mgmt_service_client(cli_ctx, SourceControlConfigurationClient, **kwargs)


def k8s_configuration_fluxconfig_client(cli_ctx, *_):
return k8s_configuration_client(cli_ctx, api_version=consts.FLUXCONFIG_API_VERSION).flux_configurations
return k8s_configuration_client(
cli_ctx, api_version=consts.FLUXCONFIG_API_VERSION
).flux_configurations


def k8s_configuration_sourcecontrol_client(cli_ctx, *_):
return k8s_configuration_client(
cli_ctx,
api_version=consts.SOURCE_CONTROL_API_VERSION
cli_ctx, api_version=consts.SOURCE_CONTROL_API_VERSION
).source_control_configurations


def k8s_configuration_extension_client(cli_ctx, *_):
return k8s_configuration_client(cli_ctx, api_version=consts.EXTENSION_API_VERSION).extensions
return k8s_configuration_client(
cli_ctx, api_version=consts.EXTENSION_API_VERSION
).extensions


def resource_providers_client(cli_ctx):
from azure.mgmt.resource import ResourceManagementClient

return get_mgmt_service_client(cli_ctx, ResourceManagementClient).providers


def cf_resource_groups(cli_ctx, subscription_id=None):
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
subscription_id=subscription_id).resource_groups
return get_mgmt_service_client(
cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, subscription_id=subscription_id
).resource_groups


def cf_resources(cli_ctx, subscription_id=None):
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
subscription_id=subscription_id).resources
return get_mgmt_service_client(
cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, subscription_id=subscription_id
).resources


def cf_log_analytics(cli_ctx, subscription_id=None):
from azure.mgmt.loganalytics import LogAnalyticsManagementClient # pylint: disable=no-name-in-module
return get_mgmt_service_client(cli_ctx, LogAnalyticsManagementClient, subscription_id=subscription_id)
from azure.mgmt.loganalytics import (
LogAnalyticsManagementClient,
) # pylint: disable=no-name-in-module

return get_mgmt_service_client(
cli_ctx, LogAnalyticsManagementClient, subscription_id=subscription_id
)
8 changes: 8 additions & 0 deletions src/k8s-configuration/azext_k8s_configuration/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@
--name myconfig --scope cluster --namespace my-namespace \\
--kind git --url https://github.com/Azure/arc-k8s-demo \\
--branch main --kustomization name=my-kustomization
- name: Create a Kubernetes v2 Flux Configuration with Bucket Source Kind
text: |-
az k8s-configuration flux create --resource-group my-resource-group \\
--cluster-name mycluster --cluster-type connectedClusters \\
--name myconfig --scope cluster --namespace my-namespace \\
--kind bucket --url https://bucket-provider.minio.io \\
--bucket-name my-bucket --kustomization name=my-kustomization \\
--access-key my-access-key --secret-key my-secret-key
"""

helps[
Expand Down
Loading