This repository was archived by the owner on May 13, 2025. It is now read-only.
forked from Azure/azure-cli-extensions
-
Notifications
You must be signed in to change notification settings - Fork 17
Add Check for Provider Registration and Refactor #19
Merged
jonathan-innis
merged 14 commits into
k8s-configuration
from
joinnis/add-provider-check
Jun 28, 2021
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bd23e0b
Add check for provider registration and refactor
jonathan-innis 77ffb31
Fix bug in checking registration
jonathan-innis 4466800
Add license header to utils
jonathan-innis cbd4b95
Merge branch 'k8s-configuration' into joinnis/add-provider-check
jonathan-innis 4e5bbda
Update private key check and error messaging
jonathan-innis c284f7d
Update based on refactoring
jonathan-innis 30b4fc0
Fix failing tests
jonathan-innis a7c4cf6
Merge branch 'k8s-configuration' into joinnis/add-provider-check
jonathan-innis f0ea38d
Merge branch 'k8s-configuration' into joinnis/add-provider-check
jonathan-innis f63ed4f
Add provider registration check
jonathan-innis c914aad
Merge branch 'k8s-configuration' into joinnis/add-provider-check
jonathan-innis 9f2e11e
Create a test for uppercase url, address comments
jonathan-innis a55fa28
Add blank line to fix style check
jonathan-innis e58e5c8
Merge branch 'k8s-configuration' into joinnis/add-provider-check
jonathan-innis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| PROVIDER_NAMESPACE = 'Microsoft.KubernetesConfiguration' | ||
| REGISTERED = "Registered" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| import base64 | ||
| from azure.cli.core.azclierror import MutuallyExclusiveArgumentError, InvalidArgumentValueError | ||
|
|
||
|
|
||
| def _get_cluster_type(cluster_type): | ||
| if cluster_type.lower() == 'connectedclusters': | ||
| return 'Microsoft.Kubernetes' | ||
| # Since cluster_type is an enum of only two values, if not connectedClusters, it will be managedClusters. | ||
| return 'Microsoft.ContainerService' | ||
|
|
||
|
|
||
| def _fix_compliance_state(config): | ||
| # If we get Compliant/NonCompliant as compliance_sate, change them before returning | ||
| if config.compliance_status.compliance_state.lower() == 'noncompliant': | ||
| config.compliance_status.compliance_state = 'Failed' | ||
| elif config.compliance_status.compliance_state.lower() == 'compliant': | ||
| config.compliance_status.compliance_state = 'Installed' | ||
|
|
||
| return config | ||
|
|
||
|
|
||
| def _get_data_from_key_or_file(key, filepath): | ||
| if key != '' and filepath != '': | ||
| raise MutuallyExclusiveArgumentError( | ||
| 'Error! Both textual key and key filepath cannot be provided', | ||
| 'Try providing the file parameter without providing the plaintext parameter') | ||
| data = '' | ||
| if filepath != '': | ||
| data = _read_key_file(filepath) | ||
| elif key != '': | ||
| data = key | ||
| return data | ||
|
|
||
|
|
||
| def _read_key_file(path): | ||
| try: | ||
| with open(path, "r") as myfile: # user passed in filename | ||
| data_list = myfile.readlines() # keeps newline characters intact | ||
| data_list_len = len(data_list) | ||
| if (data_list_len) <= 0: | ||
| raise Exception("File provided does not contain any data") | ||
| raw_data = ''.join(data_list) | ||
| return _to_base64(raw_data) | ||
| except Exception as ex: | ||
| raise InvalidArgumentValueError( | ||
| 'Error! Unable to read key file specified with: {0}'.format(ex), | ||
| 'Verify that the filepath specified exists and contains valid utf-8 data') from ex | ||
|
|
||
|
|
||
| def _from_base64(base64_str): | ||
| return base64.b64decode(base64_str) | ||
|
|
||
|
|
||
| def _to_base64(raw_data): | ||
| bytes_data = raw_data.encode('utf-8') | ||
| return base64.b64encode(bytes_data).decode('utf-8') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.