Skip to content

Commit

Permalink
Enable Bucket Support in the CLI (#92)
Browse files Browse the repository at this point in the history
* Update vendored_sdks

* Enable source kind generation factories and use kwargs to pass to provider

* Add better validation logic to source generator

* Move away from classes in the provider directory

* Fix style issues using black auto-formatter

* Fix linter failures

* Update identity with api version and rp in same function
  • Loading branch information
jonathan-innis authored Dec 9, 2021
1 parent 235065f commit 8aedb4e
Show file tree
Hide file tree
Showing 52 changed files with 11,898 additions and 1,075 deletions.
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

0 comments on commit 8aedb4e

Please sign in to comment.