Skip to content
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
3 changes: 3 additions & 0 deletions src/k8s-configuration/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Release History
===============
2.2.0
++++++++++++++++++
* Introduce a new feature to add provider authentication for git repositories.

2.1.0
++++++++++++++++++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def k8s_configuration_client(cli_ctx, **kwargs):


def k8s_configuration_fluxconfig_client(cli_ctx, *_):
return k8s_configuration_client(
cli_ctx, api_version=consts.FLUXCONFIG_API_VERSION
).flux_configurations
from azext_k8s_configuration.vendored_sdks.v2024_11_01 import FluxConfigurationClient

return get_mgmt_service_client(cli_ctx, FluxConfigurationClient).flux_configurations


def k8s_configuration_sourcecontrol_client(cli_ctx, *_):
Expand Down
6 changes: 6 additions & 0 deletions src/k8s-configuration/azext_k8s_configuration/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ def load_arguments(self, _):
arg_group="Git Auth",
help="File path to known_hosts contents containing public SSH keys required to access private Git instances",
)
c.argument(
"provider",
arg_group="Git Auth",
arg_type=get_enum_type(["generic", "azure"]),
help="Name of the provider used for authentication, azure provider can be used to authenticate to Azure DevOps repositories using Managed Identity",
)
c.argument(
"bucket_access_key",
arg_group="Bucket Auth",
Expand Down
3 changes: 2 additions & 1 deletion src/k8s-configuration/azext_k8s_configuration/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# API VERSIONS -----------------------------------------

SOURCE_CONTROL_API_VERSION = "2022-03-01"
FLUXCONFIG_API_VERSION = "2024-04-01-preview"
FLUXCONFIG_API_VERSION = "2024-11-01"
EXTENSION_API_VERSION = "2022-07-01"

# ERROR/HELP TEXT DEFINITIONS -----------------------------------------
Expand Down Expand Up @@ -222,6 +222,7 @@
"known_hosts",
"known_hosts_file",
"local_auth_ref",
"provider",
}

BUCKET_REQUIRED_PARAMS = {"url", "bucket_name"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
validate_url_with_params,
)
from .. import consts
from ..vendored_sdks.v2024_04_01_preview.models import (
from ..vendored_sdks.v2024_11_01.models import (
FluxConfiguration,
FluxConfigurationPatch,
GitRepositoryDefinition,
Expand Down Expand Up @@ -149,6 +149,7 @@ def create_config(
https_ca_cert_file=None,
known_hosts=None,
known_hosts_file=None,
provider=None,
bucket_access_key=None,
bucket_secret_key=None,
bucket_insecure=False,
Expand Down Expand Up @@ -191,6 +192,7 @@ def create_config(
https_ca_cert_file=https_ca_cert_file,
known_hosts=known_hosts,
known_hosts_file=known_hosts_file,
provider=provider,
bucket_access_key=bucket_access_key,
bucket_secret_key=bucket_secret_key,
bucket_insecure=bucket_insecure,
Expand Down Expand Up @@ -282,6 +284,7 @@ def update_config(
https_ca_cert_file=None,
known_hosts=None,
known_hosts_file=None,
provider=None,
bucket_access_key=None,
bucket_secret_key=None,
bucket_insecure=None,
Expand Down Expand Up @@ -330,6 +333,7 @@ def update_config(
https_ca_cert_file=https_ca_cert_file,
known_hosts=known_hosts,
known_hosts_file=known_hosts_file,
provider=provider,
bucket_access_key=bucket_access_key,
bucket_secret_key=bucket_secret_key,
bucket_insecure=bucket_insecure,
Expand Down Expand Up @@ -898,6 +902,7 @@ def __init__(self, **kwargs):
self.ssh_private_key_file = kwargs.get("ssh_private_key_file")
self.https_user = kwargs.get("https_user")
self.https_key = kwargs.get("https_key")
self.provider = kwargs.get("provider")

# Get the known hosts data and validate it
self.knownhost_data = get_data_from_key_or_file(
Expand Down Expand Up @@ -960,6 +965,7 @@ def updater(config):
https_user=self.https_user,
local_auth_ref=self.local_auth_ref,
https_ca_cert=self.https_ca_data,
provider=self.provider,
)
config.source_kind = SourceKindType.GIT_REPOSITORY
return config
Expand All @@ -984,6 +990,7 @@ def git_repository_updater(config):
https_user=self.https_user,
local_auth_ref=self.local_auth_ref,
https_ca_cert=self.https_ca_data,
provider=self.provider,
)
if swapped_kind:
self.validate()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from copy import deepcopy
from typing import Any, TYPE_CHECKING
from typing_extensions import Self

from azure.core.pipeline import policies
from azure.core.rest import HttpRequest, HttpResponse
from azure.mgmt.core import ARMPipelineClient
from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy

from . import models as _models
from ._configuration import FluxConfigurationClientConfiguration
from ._serialization import Deserializer, Serializer
from .operations import FluxConfigOperationStatusOperations, FluxConfigurationsOperations

if TYPE_CHECKING:
from azure.core.credentials import TokenCredential


class FluxConfigurationClient:
"""KubernetesConfiguration Flux Client.

:ivar flux_configurations: FluxConfigurationsOperations operations
:vartype flux_configurations:
azure.mgmt.kubernetesconfiguration.fluxconfigurations.operations.FluxConfigurationsOperations
:ivar flux_config_operation_status: FluxConfigOperationStatusOperations operations
:vartype flux_config_operation_status:
azure.mgmt.kubernetesconfiguration.fluxconfigurations.operations.FluxConfigOperationStatusOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2024-11-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
"""

def __init__(
self,
credential: "TokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = FluxConfigurationClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
_policies = kwargs.pop("policies", None)
if _policies is None:
_policies = [
policies.RequestIdPolicy(**kwargs),
self._config.headers_policy,
self._config.user_agent_policy,
self._config.proxy_policy,
policies.ContentDecodePolicy(**kwargs),
ARMAutoResourceProviderRegistrationPolicy(),
self._config.redirect_policy,
self._config.retry_policy,
self._config.authentication_policy,
self._config.custom_hook_policy,
self._config.logging_policy,
policies.DistributedTracingPolicy(**kwargs),
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
self._config.http_logging_policy,
]
self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs)

client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.flux_configurations = FluxConfigurationsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.flux_config_operation_status = FluxConfigOperationStatusOperations(
self._client, self._config, self._serialize, self._deserialize
)

def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.

>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client._send_request(request)
<HttpResponse: 200 OK>

For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request

:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.HttpResponse
"""

request_copy = deepcopy(request)
request_copy.url = self._client.format_url(request_copy.url)
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore

def close(self) -> None:
self._client.close()

def __enter__(self) -> Self:
self._client.__enter__()
return self

def __exit__(self, *exc_details: Any) -> None:
self._client.__exit__(*exc_details)
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
from .v2022_01_01_preview.models import *
from .v2022_03_01.models import *
from .v2022_07_01.models import *
from .v2024_04_01_preview import *
from .v2024_11_01 import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wrong-import-position

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from ._patch import * # pylint: disable=unused-wildcard-import

from ._flux_configuration_client import FluxConfigurationClient # type: ignore
from ._version import VERSION

__version__ = VERSION

try:
from ._patch import __all__ as _patch_all
from ._patch import *
except ImportError:
_patch_all = []
from ._patch import patch_sdk as _patch_sdk

__all__ = [
"FluxConfigurationClient",
]
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore

_patch_sdk()
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any, TYPE_CHECKING

from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy

from ._version import VERSION

if TYPE_CHECKING:
from azure.core.credentials import TokenCredential


class FluxConfigurationClientConfiguration: # pylint: disable=too-many-instance-attributes
"""Configuration for FluxConfigurationClient.

Note that all parameters used to create this instance are saved as instance
attributes.

:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2024-11-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
api_version: str = kwargs.pop("api_version", "2024-11-01")

if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")

self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration-fluxconfigurations/{}".format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
self._configure(**kwargs)

def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = ARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
Loading
Loading