Skip to content

Commit b2cfeed

Browse files
dipti-paiBavneet Singh
andauthored
az k8s-configuration Release 2.2.0 (Azure#8559)
* add pester tests for k8s-configuration * Add api version 2024-11-01 with provider support for git repository (Azure#1) * Delete testing directory --------- Co-authored-by: Bavneet Singh <bavneetsingh@microsoft.com>
1 parent 524d814 commit b2cfeed

30 files changed

+7896
-7
lines changed

src/k8s-configuration/HISTORY.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
33
Release History
44
===============
5+
2.2.0
6+
++++++++++++++++++
7+
* Introduce a new feature to add provider authentication for git repositories.
58

69
2.1.0
710
++++++++++++++++++

src/k8s-configuration/azext_k8s_configuration/_client_factory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ def k8s_configuration_client(cli_ctx, **kwargs):
1515

1616

1717
def k8s_configuration_fluxconfig_client(cli_ctx, *_):
18-
return k8s_configuration_client(
19-
cli_ctx, api_version=consts.FLUXCONFIG_API_VERSION
20-
).flux_configurations
18+
from azext_k8s_configuration.vendored_sdks.v2024_11_01 import FluxConfigurationClient
19+
20+
return get_mgmt_service_client(cli_ctx, FluxConfigurationClient).flux_configurations
2121

2222

2323
def k8s_configuration_sourcecontrol_client(cli_ctx, *_):

src/k8s-configuration/azext_k8s_configuration/_params.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ def load_arguments(self, _):
139139
arg_group="Git Auth",
140140
help="File path to known_hosts contents containing public SSH keys required to access private Git instances",
141141
)
142+
c.argument(
143+
"provider",
144+
arg_group="Git Auth",
145+
arg_type=get_enum_type(["generic", "azure"]),
146+
help="Name of the provider used for authentication, azure provider can be used to authenticate to Azure DevOps repositories using Managed Identity",
147+
)
142148
c.argument(
143149
"bucket_access_key",
144150
arg_group="Bucket Auth",

src/k8s-configuration/azext_k8s_configuration/consts.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# API VERSIONS -----------------------------------------
99

1010
SOURCE_CONTROL_API_VERSION = "2022-03-01"
11-
FLUXCONFIG_API_VERSION = "2024-04-01-preview"
11+
FLUXCONFIG_API_VERSION = "2024-11-01"
1212
EXTENSION_API_VERSION = "2022-07-01"
1313

1414
# ERROR/HELP TEXT DEFINITIONS -----------------------------------------
@@ -222,6 +222,7 @@
222222
"known_hosts",
223223
"known_hosts_file",
224224
"local_auth_ref",
225+
"provider",
225226
}
226227

227228
BUCKET_REQUIRED_PARAMS = {"url", "bucket_name"}

src/k8s-configuration/azext_k8s_configuration/providers/FluxConfigurationProvider.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
validate_url_with_params,
4848
)
4949
from .. import consts
50-
from ..vendored_sdks.v2024_04_01_preview.models import (
50+
from ..vendored_sdks.v2024_11_01.models import (
5151
FluxConfiguration,
5252
FluxConfigurationPatch,
5353
GitRepositoryDefinition,
@@ -149,6 +149,7 @@ def create_config(
149149
https_ca_cert_file=None,
150150
known_hosts=None,
151151
known_hosts_file=None,
152+
provider=None,
152153
bucket_access_key=None,
153154
bucket_secret_key=None,
154155
bucket_insecure=False,
@@ -191,6 +192,7 @@ def create_config(
191192
https_ca_cert_file=https_ca_cert_file,
192193
known_hosts=known_hosts,
193194
known_hosts_file=known_hosts_file,
195+
provider=provider,
194196
bucket_access_key=bucket_access_key,
195197
bucket_secret_key=bucket_secret_key,
196198
bucket_insecure=bucket_insecure,
@@ -282,6 +284,7 @@ def update_config(
282284
https_ca_cert_file=None,
283285
known_hosts=None,
284286
known_hosts_file=None,
287+
provider=None,
285288
bucket_access_key=None,
286289
bucket_secret_key=None,
287290
bucket_insecure=None,
@@ -330,6 +333,7 @@ def update_config(
330333
https_ca_cert_file=https_ca_cert_file,
331334
known_hosts=known_hosts,
332335
known_hosts_file=known_hosts_file,
336+
provider=provider,
333337
bucket_access_key=bucket_access_key,
334338
bucket_secret_key=bucket_secret_key,
335339
bucket_insecure=bucket_insecure,
@@ -898,6 +902,7 @@ def __init__(self, **kwargs):
898902
self.ssh_private_key_file = kwargs.get("ssh_private_key_file")
899903
self.https_user = kwargs.get("https_user")
900904
self.https_key = kwargs.get("https_key")
905+
self.provider = kwargs.get("provider")
901906

902907
# Get the known hosts data and validate it
903908
self.knownhost_data = get_data_from_key_or_file(
@@ -960,6 +965,7 @@ def updater(config):
960965
https_user=self.https_user,
961966
local_auth_ref=self.local_auth_ref,
962967
https_ca_cert=self.https_ca_data,
968+
provider=self.provider,
963969
)
964970
config.source_kind = SourceKindType.GIT_REPOSITORY
965971
return config
@@ -984,6 +990,7 @@ def git_repository_updater(config):
984990
https_user=self.https_user,
985991
local_auth_ref=self.local_auth_ref,
986992
https_ca_cert=self.https_ca_data,
993+
provider=self.provider,
987994
)
988995
if swapped_kind:
989996
self.validate()
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from copy import deepcopy
10+
from typing import Any, TYPE_CHECKING
11+
from typing_extensions import Self
12+
13+
from azure.core.pipeline import policies
14+
from azure.core.rest import HttpRequest, HttpResponse
15+
from azure.mgmt.core import ARMPipelineClient
16+
from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy
17+
18+
from . import models as _models
19+
from ._configuration import FluxConfigurationClientConfiguration
20+
from ._serialization import Deserializer, Serializer
21+
from .operations import FluxConfigOperationStatusOperations, FluxConfigurationsOperations
22+
23+
if TYPE_CHECKING:
24+
from azure.core.credentials import TokenCredential
25+
26+
27+
class FluxConfigurationClient:
28+
"""KubernetesConfiguration Flux Client.
29+
30+
:ivar flux_configurations: FluxConfigurationsOperations operations
31+
:vartype flux_configurations:
32+
azure.mgmt.kubernetesconfiguration.fluxconfigurations.operations.FluxConfigurationsOperations
33+
:ivar flux_config_operation_status: FluxConfigOperationStatusOperations operations
34+
:vartype flux_config_operation_status:
35+
azure.mgmt.kubernetesconfiguration.fluxconfigurations.operations.FluxConfigOperationStatusOperations
36+
:param credential: Credential needed for the client to connect to Azure. Required.
37+
:type credential: ~azure.core.credentials.TokenCredential
38+
:param subscription_id: The ID of the target subscription. Required.
39+
:type subscription_id: str
40+
:param base_url: Service URL. Default value is "https://management.azure.com".
41+
:type base_url: str
42+
:keyword api_version: Api Version. Default value is "2024-11-01". Note that overriding this
43+
default value may result in unsupported behavior.
44+
:paramtype api_version: str
45+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
46+
Retry-After header is present.
47+
"""
48+
49+
def __init__(
50+
self,
51+
credential: "TokenCredential",
52+
subscription_id: str,
53+
base_url: str = "https://management.azure.com",
54+
**kwargs: Any
55+
) -> None:
56+
self._config = FluxConfigurationClientConfiguration(
57+
credential=credential, subscription_id=subscription_id, **kwargs
58+
)
59+
_policies = kwargs.pop("policies", None)
60+
if _policies is None:
61+
_policies = [
62+
policies.RequestIdPolicy(**kwargs),
63+
self._config.headers_policy,
64+
self._config.user_agent_policy,
65+
self._config.proxy_policy,
66+
policies.ContentDecodePolicy(**kwargs),
67+
ARMAutoResourceProviderRegistrationPolicy(),
68+
self._config.redirect_policy,
69+
self._config.retry_policy,
70+
self._config.authentication_policy,
71+
self._config.custom_hook_policy,
72+
self._config.logging_policy,
73+
policies.DistributedTracingPolicy(**kwargs),
74+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
75+
self._config.http_logging_policy,
76+
]
77+
self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs)
78+
79+
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
80+
self._serialize = Serializer(client_models)
81+
self._deserialize = Deserializer(client_models)
82+
self._serialize.client_side_validation = False
83+
self.flux_configurations = FluxConfigurationsOperations(
84+
self._client, self._config, self._serialize, self._deserialize
85+
)
86+
self.flux_config_operation_status = FluxConfigOperationStatusOperations(
87+
self._client, self._config, self._serialize, self._deserialize
88+
)
89+
90+
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
91+
"""Runs the network request through the client's chained policies.
92+
93+
>>> from azure.core.rest import HttpRequest
94+
>>> request = HttpRequest("GET", "https://www.example.org/")
95+
<HttpRequest [GET], url: 'https://www.example.org/'>
96+
>>> response = client._send_request(request)
97+
<HttpResponse: 200 OK>
98+
99+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
100+
101+
:param request: The network request you want to make. Required.
102+
:type request: ~azure.core.rest.HttpRequest
103+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
104+
:return: The response of your network call. Does not do error handling on your response.
105+
:rtype: ~azure.core.rest.HttpResponse
106+
"""
107+
108+
request_copy = deepcopy(request)
109+
request_copy.url = self._client.format_url(request_copy.url)
110+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
111+
112+
def close(self) -> None:
113+
self._client.close()
114+
115+
def __enter__(self) -> Self:
116+
self._client.__enter__()
117+
return self
118+
119+
def __exit__(self, *exc_details: Any) -> None:
120+
self._client.__exit__(*exc_details)

src/k8s-configuration/azext_k8s_configuration/vendored_sdks/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
from .v2022_01_01_preview.models import *
88
from .v2022_03_01.models import *
99
from .v2022_07_01.models import *
10-
from .v2024_04_01_preview import *
10+
from .v2024_11_01 import *
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
9+
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._flux_configuration_client import FluxConfigurationClient # type: ignore
16+
from ._version import VERSION
17+
18+
__version__ = VERSION
19+
20+
try:
21+
from ._patch import __all__ as _patch_all
22+
from ._patch import *
23+
except ImportError:
24+
_patch_all = []
25+
from ._patch import patch_sdk as _patch_sdk
26+
27+
__all__ = [
28+
"FluxConfigurationClient",
29+
]
30+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
31+
32+
_patch_sdk()
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from typing import Any, TYPE_CHECKING
10+
11+
from azure.core.pipeline import policies
12+
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy
13+
14+
from ._version import VERSION
15+
16+
if TYPE_CHECKING:
17+
from azure.core.credentials import TokenCredential
18+
19+
20+
class FluxConfigurationClientConfiguration: # pylint: disable=too-many-instance-attributes
21+
"""Configuration for FluxConfigurationClient.
22+
23+
Note that all parameters used to create this instance are saved as instance
24+
attributes.
25+
26+
:param credential: Credential needed for the client to connect to Azure. Required.
27+
:type credential: ~azure.core.credentials.TokenCredential
28+
:param subscription_id: The ID of the target subscription. Required.
29+
:type subscription_id: str
30+
:keyword api_version: Api Version. Default value is "2024-11-01". Note that overriding this
31+
default value may result in unsupported behavior.
32+
:paramtype api_version: str
33+
"""
34+
35+
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
36+
api_version: str = kwargs.pop("api_version", "2024-11-01")
37+
38+
if credential is None:
39+
raise ValueError("Parameter 'credential' must not be None.")
40+
if subscription_id is None:
41+
raise ValueError("Parameter 'subscription_id' must not be None.")
42+
43+
self.credential = credential
44+
self.subscription_id = subscription_id
45+
self.api_version = api_version
46+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
47+
kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration-fluxconfigurations/{}".format(VERSION))
48+
self.polling_interval = kwargs.get("polling_interval", 30)
49+
self._configure(**kwargs)
50+
51+
def _configure(self, **kwargs: Any) -> None:
52+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
53+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
54+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
55+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
56+
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
57+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
58+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
59+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
60+
self.authentication_policy = kwargs.get("authentication_policy")
61+
if self.credential and not self.authentication_policy:
62+
self.authentication_policy = ARMChallengeAuthenticationPolicy(
63+
self.credential, *self.credential_scopes, **kwargs
64+
)

0 commit comments

Comments
 (0)