Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare GA FluxConfiguration 2022-03-01 #103

Merged
merged 8 commits into from
Mar 24, 2022
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
18 changes: 7 additions & 11 deletions src/k8s-configuration/azext_k8s_configuration/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@

import argparse
from azure.cli.core.azclierror import InvalidArgumentValueError
from .vendored_sdks.v2022_01_01_preview.models import (
from .vendored_sdks.v2022_03_01.models import (
KustomizationDefinition,
KustomizationPatchDefinition,
DependsOnDefinition,
)
from .validators import validate_kustomization
from . import consts
Expand All @@ -18,26 +17,27 @@

class InternalKustomizationDefinition(KustomizationDefinition):
def __init__(self, **kwargs):
self.name = kwargs.get("name", "")
super().__init__(**kwargs)

# This call is after the call to super() to override the init method
# making the self.name field null
self.name = kwargs.get("name", "")

def to_KustomizationDefinition(self):
k_dict = dict(self.__dict__)
del k_dict["name"]
del k_dict["additional_properties"]
return KustomizationDefinition(**k_dict)

def to_KustomizationPatchDefinition(self):
k_dict = dict(self.__dict__)
del k_dict["name"]
del k_dict["additional_properties"]
return KustomizationPatchDefinition(**k_dict)


class KustomizationAddAction(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
validate_kustomization(values)
model_dependency = []
dependencies = None
sync_interval = None
retry_interval = None
timeout = None
Expand All @@ -47,10 +47,6 @@ def __call__(self, parser, namespace, values, option_string=None):
key, value = item.split("=", 1)
if key in consts.DEPENDENCY_KEYS:
dependencies = parse_dependencies(value)
for dep in dependencies:
model_dependency.append(
DependsOnDefinition(kustomization_name=dep)
)
elif key in consts.SYNC_INTERVAL_KEYS:
sync_interval = value
elif key in consts.RETRY_INTERVAL_KEYS:
Expand All @@ -67,7 +63,7 @@ def __call__(self, parser, namespace, values, option_string=None):
parser,
namespace,
InternalKustomizationDefinition(
depends_on=model_dependency,
depends_on=dependencies,
sync_interval_in_seconds=parse_duration(sync_interval),
retry_interval_in_seconds=parse_duration(retry_interval),
timeout_in_seconds=parse_duration(timeout),
Expand Down
3 changes: 0 additions & 3 deletions src/k8s-configuration/azext_k8s_configuration/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def load_command_table(self, _):
"k8s-configuration flux",
k8s_configuration_fluxconfig_client,
custom_command_type=flux_configuration_custom_type,
is_preview=True,
) as g:
g.custom_command("create", "create_config", supports_no_wait=True)
g.custom_command("update", "update_config", supports_no_wait=True)
Expand All @@ -52,7 +51,6 @@ def load_command_table(self, _):
"k8s-configuration flux kustomization",
k8s_configuration_fluxconfig_client,
custom_command_type=flux_configuration_custom_type,
is_preview=True,
) as g:
g.custom_command("create", "create_kustomization", supports_no_wait=True)
g.custom_command("update", "update_kustomization", supports_no_wait=True)
Expand All @@ -72,7 +70,6 @@ def load_command_table(self, _):
"k8s-configuration flux deployed-object",
k8s_configuration_fluxconfig_client,
custom_command_type=flux_configuration_custom_type,
is_preview=True,
) as g:
g.custom_command(
"list",
Expand Down
8 changes: 3 additions & 5 deletions src/k8s-configuration/azext_k8s_configuration/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

# API VERSIONS -----------------------------------------

SOURCE_CONTROL_API_VERSION = "2021-03-01"
FLUXCONFIG_API_VERSION = "2022-01-01-preview"
EXTENSION_API_VERSION = "2021-09-01"
SOURCE_CONTROL_API_VERSION = "2022-03-01"
FLUXCONFIG_API_VERSION = "2022-03-01"
EXTENSION_API_VERSION = "2022-03-01"

# ERROR/HELP TEXT DEFINITIONS -----------------------------------------

Expand Down Expand Up @@ -161,8 +161,6 @@
FLUX_EXTENSION_CREATING_ERROR = "Error! 'Microsoft.Flux' extension is currently installing on the cluster. Unable to proceed with Flux v2 configuration install."
FLUX_EXTENSION_CREATING_HELP = "Try again in a few minutes when the 'Microsoft.Flux' extension installation has completed."

HTTP_URL_NO_AUTH_WARNING = "Warning! https url is being used without https auth params, ensure the repository url provided is not a private repo"

NO_KUSTOMIZATIONS_WARNING = "Warning! No kustomizations were specified for this configuration. A kustomization will be generated with the default name 'kustomization-1'."
DEFAULT_KUSTOMIZATION_NAME = "kustomization-1"

Expand Down
10 changes: 3 additions & 7 deletions src/k8s-configuration/azext_k8s_configuration/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def __get_fluxconfig_table_row(result):
("scope", result["scope"]),
("provisioningState", result["provisioningState"]),
("complianceState", result["complianceState"]),
("lastSourceUpdatedAt", result["lastSourceUpdatedAt"]),
("statusUpdatedAt", result["statusUpdatedAt"]),
("sourceUpdatedAt", result["sourceUpdatedAt"]),
]
)

Expand All @@ -58,16 +59,11 @@ def fluxconfig_kustomization_show_table_format(results):


def __get_fluxconfig_kustomization_table_row(key, value):
deps = []
for dep in value.get("dependsOn") or []:
if dep.get("kustomizationName"):
deps.append(dep["kustomizationName"])

return OrderedDict(
[
("name", key),
("path", value["path"]),
("dependsOn", ",".join(deps)),
("dependsOn", ",".join(value.get("dependsOn") or [])),
jonathan-innis marked this conversation as resolved.
Show resolved Hide resolved
("syncInterval", format_duration(value["syncIntervalInSeconds"])),
("timeout", format_duration(value["timeoutInSeconds"])),
("prune", value["prune"]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@
validate_url_with_params,
)
from .. import consts
from ..vendored_sdks.v2022_01_01_preview.models import (
from ..vendored_sdks.v2022_03_01.models import (
FluxConfiguration,
FluxConfigurationPatch,
GitRepositoryDefinition,
GitRepositoryPatchDefinition,
BucketDefinition,
BucketPatchDefinition,
RepositoryRefDefinition,
KustomizationDefinition,
KustomizationPatchDefinition,
DependsOnDefinition,
SourceKindType,
)
from ..vendored_sdks.v2021_09_01.models import Extension, Identity
from ..vendored_sdks.v2022_03_01.models import Extension, Identity

logger = get_logger(__name__)

Expand Down Expand Up @@ -384,17 +384,10 @@ def create_kustomization(
consts.CREATE_KUSTOMIZATION_EXIST_HELP,
)

# Add the dependencies in their model to the kustomization
model_dependencies = None
if dependencies:
model_dependencies = []
for dep in parse_dependencies(dependencies):
model_dependencies.append(DependsOnDefinition(kustomization_name=dep))

kustomization = {
kustomization_name: KustomizationPatchDefinition(
path=path,
depends_on=model_dependencies,
depends_on=parse_dependencies(dependencies),
timeout_in_seconds=parse_duration(timeout),
sync_interval_in_seconds=parse_duration(sync_interval),
retry_interval_in_seconds=parse_duration(retry_interval),
Expand Down Expand Up @@ -451,17 +444,10 @@ def update_kustomization(
consts.UPDATE_KUSTOMIZATION_NO_EXIST_HELP,
)

# Add the dependencies in their model to the kustomization
model_dependencies = None
if dependencies:
model_dependencies = []
for dep in parse_dependencies(dependencies):
model_dependencies.append(DependsOnDefinition(kustomization_name=dep))

kustomization = {
kustomization_name: KustomizationPatchDefinition(
path=path,
depends_on=model_dependencies,
depends_on=parse_dependencies(dependencies),
timeout_in_seconds=parse_duration(timeout),
sync_interval_in_seconds=parse_duration(sync_interval),
retry_interval_in_seconds=parse_duration(retry_interval),
Expand Down Expand Up @@ -1015,7 +1001,7 @@ def generate_patch_update_func(self, swapped_kind):

def bucket_patch_updater(config):
if any(kwarg is not None for kwarg in self.kwargs.values()):
config.bucket = BucketDefinition(
config.bucket = BucketPatchDefinition(
url=self.url,
bucket_name=self.bucket_name,
timeout_in_seconds=parse_duration(self.timeout),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)
from .. import consts

from ..vendored_sdks.v2021_03_01.models import (
from ..vendored_sdks.v2022_03_01.models import (
HelmOperatorProperties,
SourceControlConfiguration,
)
Expand Down
Loading