diff --git a/src/connectedk8s/azext_connectedk8s/_params.py b/src/connectedk8s/azext_connectedk8s/_params.py index 349da56fd74..e8c92df4edc 100644 --- a/src/connectedk8s/azext_connectedk8s/_params.py +++ b/src/connectedk8s/azext_connectedk8s/_params.py @@ -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 ( @@ -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) @@ -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) diff --git a/src/connectedk8s/azext_connectedk8s/_validators.py b/src/connectedk8s/azext_connectedk8s/_validators.py index 19ea07df458..36718f9c9cf 100644 --- a/src/connectedk8s/azext_connectedk8s/_validators.py +++ b/src/connectedk8s/azext_connectedk8s/_validators.py @@ -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.") \ No newline at end of file + if namespace.gateway_resource_id != "" and namespace.disable_gateway: + raise ArgumentUsageError("Cannot specify both --gateway-resource-id and --disable-gateway simultaneously.") \ No newline at end of file diff --git a/src/connectedk8s/azext_connectedk8s/custom.py b/src/connectedk8s/azext_connectedk8s/custom.py index e9f8990199b..fc049e16f1e 100644 --- a/src/connectedk8s/azext_connectedk8s/custom.py +++ b/src/connectedk8s/azext_connectedk8s/custom.py @@ -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: @@ -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 @@ -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 @@ -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) @@ -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