-
Notifications
You must be signed in to change notification settings - Fork 5
[minor] Add support for improved SLS flow in the CLI #53
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
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3581a05
[patch] Add sls.py
rawa-resul a250a71
[patch] linting fixes
rawa-resul 4043d73
[patch] Update pipelinerun-install.yml.j2
rawa-resul 0830980
[patch] Switch to sls_tls_crt_local_file_base64_path
rawa-resul 003a078
[patch] Fix bug in getNamespace
rawa-resul 6533d69
[patch] Fix bug in listSLSInstances
rawa-resul e2cab24
[patch] Improve logging
rawa-resul 3a4e079
[patch] Add verify sls connection function
rawa-resul 49f0d03
[patch] autopep8 fix
rawa-resul a1fd983
[patch] Fix sls url
rawa-resul 624a258
[patch] Make slsLicenseFile optional
rawa-resul 02f03cb
[patch] Fix slsLicenseFile
rawa-resul 7321c7a
[patch] Remove b64 var
rawa-resul c0ea92f
[patch] Add findSLSByNamespace function
rawa-resul a3340d5
[patch] Fix autopep8 issue
rawa-resul 0b688f0
[patch] Add new line
rawa-resul 520a4e0
[patch] Cleanup
rawa-resul 69626a5
[patch] Further cleanup
rawa-resul c34ae0f
[patch] Add copyright to sls.py
rawa-resul 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
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,46 @@ | ||
| # ***************************************************************************** | ||
| # Copyright (c) 2025 IBM Corporation and other Contributors. | ||
| # | ||
| # All rights reserved. This program and the accompanying materials | ||
| # are made available under the terms of the Eclipse Public License v1.0 | ||
| # which accompanies this distribution, and is available at | ||
| # http://www.eclipse.org/legal/epl-v10.html | ||
| # | ||
| # ***************************************************************************** | ||
|
|
||
| import logging | ||
| from openshift.dynamic import DynamicClient | ||
| from openshift.dynamic.exceptions import NotFoundError, ResourceNotFoundError, UnauthorizedError | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def listSLSInstances(dynClient: DynamicClient) -> list: | ||
| """ | ||
| Get a list of SLS instances on the cluster | ||
| """ | ||
| try: | ||
| slsAPI = dynClient.resources.get(api_version="sls.ibm.com/v1", kind="LicenseService") | ||
| return slsAPI.get().to_dict()['items'] | ||
| except NotFoundError: | ||
| logger.info("There are no SLS instances installed on this cluster") | ||
| return [] | ||
| except ResourceNotFoundError: | ||
| logger.info("LicenseService CRD not found on cluster") | ||
| return [] | ||
| except UnauthorizedError: | ||
| logger.error("Error: Unable to verify SLS instances due to failed authorization: {e}") | ||
| return [] | ||
|
|
||
|
|
||
| def findSLSByNamespace(namespace: str, instances: list = None, dynClient: DynamicClient = None): | ||
| if not instances and not dynClient: | ||
| return False | ||
|
|
||
| if not instances and dynClient: | ||
| instances = listSLSInstances(dynClient) | ||
|
|
||
| for instance in instances: | ||
| if namespace in instance['metadata']['namespace']: | ||
| return True | ||
| return False | ||
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
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.