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

Update Formatting for Deployed Object #93

Merged
merged 1 commit into from
Nov 30, 2021
Merged
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
90 changes: 51 additions & 39 deletions src/k8s-configuration/azext_k8s_configuration/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ def sourcecontrol_show_table_format(result):


def __get_sourcecontrolconfig_table_row(result):
return OrderedDict([
('name', result['name']),
('repositoryUrl', result['repositoryUrl']),
('operatorName', result['operatorInstanceName']),
('operatorNamespace', result['operatorNamespace']),
('scope', result['operatorScope']),
('provisioningState', result['provisioningState'])
])
return OrderedDict(
[
("name", result["name"]),
("repositoryUrl", result["repositoryUrl"]),
("operatorName", result["operatorInstanceName"]),
("operatorNamespace", result["operatorNamespace"]),
("scope", result["operatorScope"]),
("provisioningState", result["provisioningState"]),
]
)


def fluxconfig_list_table_format(results):
Expand All @@ -35,14 +37,16 @@ def fluxconfig_show_table_format(result):


def __get_fluxconfig_table_row(result):
return OrderedDict([
('name', result['name']),
('namespace', result['namespace']),
('scope', result['scope']),
('provisioningState', result['provisioningState']),
('complianceState', result['complianceState']),
('lastSourceSyncedAt', result['lastSourceSyncedAt']),
])
return OrderedDict(
[
("namespace", result["namespace"]),
("name", result["name"]),
("scope", result["scope"]),
("provisioningState", result["provisioningState"]),
("complianceState", result["complianceState"]),
("lastSourceSyncedAt", result["lastSourceSyncedAt"]),
]
)


def fluxconfig_kustomization_list_table_format(results):
Expand All @@ -55,19 +59,21 @@ 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)),
('syncInterval', format_duration(value['syncIntervalInSeconds'])),
('timeout', format_duration(value['timeoutInSeconds'])),
('prune', value['prune']),
('force', value['force'])
])
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)),
("syncInterval", format_duration(value["syncIntervalInSeconds"])),
("timeout", format_duration(value["timeoutInSeconds"])),
("prune", value["prune"]),
("force", value["force"]),
]
)


def fluxconfig_deployed_object_list_table_format(results):
Expand All @@ -79,13 +85,19 @@ def fluxconfig_deployed_object_show_table_format(result):


def __get_fluxconfig_deployed_object_table_row(result):
applied_by = 'None'
if result['appliedBy']:
applied_by = result['appliedBy']['namespace'] + result['appliedBy']['name']
return OrderedDict([
('kind', result['kind']),
('name', result['name']),
('namespace', result['namespace']),
('complianceState', result['complianceState']),
('appliedBy', applied_by)
])
message = "None"
for condition in result.get("statusConditions") or []:
if condition.get("type") == "Ready":
message = condition.get("message")
if len(message) > 60:
message = message[:60] + "..."
break
return OrderedDict(
[
("kind", result["kind"]),
("namespace", result["namespace"]),
("name", result["name"]),
("complianceState", result["complianceState"]),
("message", message),
]
)