Skip to content

Commit

Permalink
remove redundant cli param
Browse files Browse the repository at this point in the history
  • Loading branch information
Bavneet Singh committed Aug 20, 2024
1 parent ff894ba commit 22a1f9b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
7 changes: 2 additions & 5 deletions src/connectedk8s/azext_connectedk8s/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from ._validators import (
validate_private_link_properties,
override_client_request_id_header,
validate_gateway_properties,
validate_gateway_updates
)
from .action import (
Expand Down Expand Up @@ -62,8 +61,7 @@ def load_arguments(self, _):
c.argument('enable_oidc_issuer', arg_type=get_three_state_flag(), help="Enable creation of OIDC issuer url used for workload identity", is_preview=True)
c.argument('self_hosted_issuer', options_list=['--self-hosted-issuer'], help="Self hosted issuer url for public cloud clusters - AKS, GKE, EKS", is_preview=True)
c.argument('enable_workload_identity', options_list=["--enable-workload-identity", "--enable-wi"], arg_type=get_three_state_flag(), help="Enable workload identity webhook", is_preview=True)
c.argument('enable_gateway', options_list=['--enable-gateway'], arg_group='Gateway', help='Pass this value to enable Arc Gateway.', validator=validate_gateway_properties)
c.argument('gateway_resource_id', options_list=['--gateway-resource-id'], arg_group='Gateway', help='ArmID of the Arc Gateway resource.', validator=validate_gateway_properties)
c.argument('gateway_resource_id', options_list=['--gateway-resource-id'], arg_group='Gateway', help='ArmID of the Arc Gateway resource.')
c.argument('configuration_settings', options_list=['--configuration-settings', '--config'], action=AddConfigurationSettings, nargs='+', help='Configuration Settings as key=value pair. Repeat parameter for each setting. Do not use this for secrets, as this value is returned in response.', is_preview=True)
c.argument('configuration_protected_settings', options_list=['--config-protected-settings', '--config-protected'], action=AddConfigurationProtectedSettings, nargs='+', help='Configuration Protected Settings as key=value pair. Repeat parameter for each setting. Only the key is returned in response, the value is not.', is_preview=True)

Expand All @@ -88,8 +86,7 @@ def load_arguments(self, _):
c.argument('self_hosted_issuer', options_list=["--self-hosted-issuer"], help="Self hosted issuer url for public cloud clusters - AKS, GKE, EKS", is_preview=True)
c.argument('enable_workload_identity', options_list=["--enable-workload-identity", "--enable-wi"], arg_type=get_three_state_flag(), help="Enable workload identity webhook", is_preview=True)
c.argument('disable_workload_identity', options_list=["--disable-workload-identity", "--disable-wi"], arg_type=get_three_state_flag(), help="Disable workload identity webhook", is_preview=True)
c.argument('enable_gateway', options_list=['--enable-gateway'], arg_group='Gateway', help='Flag to enable Arc Gateway.', validator=validate_gateway_updates)
c.argument('gateway_resource_id', options_list=['--gateway-resource-id'], arg_group='Gateway', help='ArmID of the Arc Gateway resource.', validator=validate_gateway_properties)
c.argument('gateway_resource_id', options_list=['--gateway-resource-id'], arg_group='Gateway', help='ArmID of the Arc Gateway resource.', validator=validate_gateway_updates)
c.argument('disable_gateway', options_list=['--disable-gateway'], arg_group='Gateway', help='Flag to disable Arc Gateway', validator=validate_gateway_updates)
c.argument('configuration_settings', options_list=['--configuration-settings', '--config'], action=AddConfigurationSettings, nargs='+', help='Configuration Settings as key=value pair. Repeat parameter for each setting. Do not use this for secrets, as this value is returned in response.', is_preview=True)
c.argument('configuration_protected_settings', options_list=['--config-protected-settings', '--config-protected'], action=AddConfigurationProtectedSettings, nargs='+', help='Configuration Protected Settings as key=value pair. Repeat parameter for each setting. Only the key is returned in response, the value is not.', is_preview=True)
Expand Down
14 changes: 2 additions & 12 deletions src/connectedk8s/azext_connectedk8s/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ def override_client_request_id_header(cmd, namespace):
else:
cmd.cli_ctx.data['headers'][consts.Client_Request_Id_Header] = consts.Default_Onboarding_Source_Tracking_Guid


def validate_gateway_properties(namespace):
if namespace.enable_gateway is False and namespace.gateway_resource_id != "":
raise ArgumentUsageError("Conflicting gateway parameters received. The parameter '--gateway-resource-id' should be set only if '--enable-gateway' is set to true.")
if namespace.enable_gateway is True and namespace.gateway_resource_id == "":
raise ArgumentUsageError("The parameter '--gateway-resource-id' was not provided. It is mandatory to pass this parameter for enabling gateway on the connected cluster resource.")


def validate_gateway_updates(namespace):
if namespace.enable_gateway and namespace.disable_gateway:
raise ArgumentUsageError("Cannot specify both --enable-gateway and --disable-gateway simultaneously.")
if namespace.enable_gateway and namespace.gateway_resource_id == "":
raise ArgumentUsageError("The parameter '--gateway-resource-id' was not provided. It is mandatory to pass this parameter for enabling gateway on the connected cluster resource.")
if namespace.gateway_resource_id != "" and namespace.disable_gateway:
raise ArgumentUsageError("Cannot specify both --gateway-resource-id and --disable-gateway simultaneously.")
14 changes: 7 additions & 7 deletions src/connectedk8s/azext_connectedk8s/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, correlat
kube_config=None, kube_context=None, no_wait=False, tags=None, distribution='generic', infrastructure='generic',
disable_auto_upgrade=False, cl_oid=None, onboarding_timeout=consts.DEFAULT_MAX_ONBOARDING_TIMEOUT_HELMVALUE_SECONDS, enable_private_link=None,
private_link_scope_resource_id=None, distribution_version=None, azure_hybrid_benefit=None, skip_ssl_verification=False, yes=False, container_log_path=None,
enable_oidc_issuer=False, enable_workload_identity=False, self_hosted_issuer="", enable_gateway=False, gateway_resource_id="",
configuration_settings=None, configuration_protected_settings=None):
enable_oidc_issuer=False, enable_workload_identity=False, self_hosted_issuer="", gateway_resource_id="", configuration_settings=None,
configuration_protected_settings=None):
logger.warning("This operation might take a while...\n")
# changing cli config to push telemetry in 1 hr interval
try:
Expand Down Expand Up @@ -149,11 +149,11 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, correlat

# Set preview client if latest preview properties are provided.
if enable_private_link is not None or distribution_version is not None or azure_hybrid_benefit is not None \
or enable_workload_identity or enable_oidc_issuer or enable_gateway:
or enable_workload_identity or enable_oidc_issuer or gateway_resource_id != "":
client = cf_connected_cluster_prev_2024_07_01(cmd.cli_ctx, None)

gateway = None
if enable_gateway:
if gateway_resource_id != "":
gateway = Gateway(
enabled=True,
resource_id=gateway_resource_id
Expand Down Expand Up @@ -1334,7 +1334,7 @@ def update_connected_cluster(cmd, client, resource_group_name, cluster_name, htt
disable_proxy=False, kube_config=None, kube_context=None, auto_upgrade=None, tags=None,
distribution=None, distribution_version=None, azure_hybrid_benefit=None, skip_ssl_verification=False, yes=False,
container_log_path=None, enable_oidc_issuer=None, enable_workload_identity=None, self_hosted_issuer="",
disable_workload_identity=None, enable_gateway=False, gateway_resource_id="", disable_gateway=False,
disable_workload_identity=None, gateway_resource_id="", disable_gateway=False,
configuration_settings=None, configuration_protected_settings=None):

# Prompt for confirmation for few parameters
Expand Down Expand Up @@ -1414,7 +1414,7 @@ def update_connected_cluster(cmd, client, resource_group_name, cluster_name, htt
and not container_log_path
and enable_oidc_issuer is None
and enable_workload_identity is None
and not enable_gateway
and gateway_resource_id == ""
and not disable_gateway
):
raise RequiredArgumentMissingError(consts.No_Param_Error)
Expand Down Expand Up @@ -1458,7 +1458,7 @@ def update_connected_cluster(cmd, client, resource_group_name, cluster_name, htt

# If gateway is enabled
gateway = None
if enable_gateway:
if gateway_resource_id != "":
gateway = Gateway(
enabled=True,
resource_id=gateway_resource_id
Expand Down

0 comments on commit 22a1f9b

Please sign in to comment.