Skip to content

Conversation

@mrDzurb
Copy link
Member

@mrDzurb mrDzurb commented Sep 15, 2023

Description

https://jira.oci.oraclecorp.com/browse/ODSC-47201
Adds opctl environment validator decorator.

A Python decorator to validate whether a OPCTL CLI command can be executed in the current environment. This decorator will help ensure that CLI commands are only executed when the necessary conditions are met within the environment. For instance the operator's image cannot be created in the NB session or OCI Jobs.

Pre-commit

image

Tests

image

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Sep 15, 2023
def wrapper(*args: List, **kwargs: Dict) -> Dict:
if any(
value
for value in (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking only the environment variable might not cause problem if user set the value manually in a supported environment. I think, since the root cause of the operation not being supported is that the environment does not support certain dependency, for example, docker. Maybe it is enough to tell users that since docker is not installed, the operation is not supported.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! User may not have set up dataflow, for example

Copy link
Member

@ahosler ahosler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, this will be super helpful for testing going forward.

@mrDzurb
Copy link
Member Author

mrDzurb commented Sep 21, 2023

In the next PR will add extra validation:

try:
    import docker
    docker.from_env().version()
except:
    raise OpctlEnvironmentError()

@mrDzurb mrDzurb merged commit dea1cdd into feature/forecasting Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants