Skip to content

Basic Plugin Config to CLI#403

Merged
arm4b merged 5 commits intomainfrom
refactor/schema-cli
Feb 17, 2023
Merged

Basic Plugin Config to CLI#403
arm4b merged 5 commits intomainfrom
refactor/schema-cli

Conversation

@arm4b
Copy link
Copy Markdown
Contributor

@arm4b arm4b commented Feb 16, 2023

Closes #360

This adds basic implementation to compose a CLI command based on plugin config values and pass it as an ENV variable.

An example Ansible plugin bitops-plugins/ansible#11 refactored to use this functionality:

ansible-playbook ${BITOPS_ANSIBLE_CLI}

UPDATE:
Users should be able to override the config value based on magically-assumed input ENV for each config setting.
So for ansible.properties.options.dry-run schema key BITOPS_ANSIBLE_DRY_RUN is the magic variable.

The value precedence is: ENV > BitOps Config > Plugin Defaults.

TODO:

  • CLI schema generation
  • ENV variable magic
  • Documentation

@arm4b arm4b added the feature label Feb 16, 2023
@runforesight
Copy link
Copy Markdown

runforesight bot commented Feb 16, 2023

Foresight Summary

Image Image Image Image 
Major Impacts
Foresight hasn't detected any major impact on your workflows and tests.

View More Details

✅  CI workflow has finished in 51 seconds and finished at 17th Feb, 2023.


Job Failed Steps Tests
lint-black -     🔗  N/A See Details
lint-pylint -     🔗  N/A See Details

🔎 See details on Foresight

*You can configure Foresight comments in your organization settings page.

@arm4b arm4b force-pushed the refactor/schema-cli branch from 0a64a7f to fde4db8 Compare February 16, 2023 16:42
@arm4b arm4b marked this pull request as ready for review February 16, 2023 16:47
@PhillypHenning
Copy link
Copy Markdown
Contributor

Could you add a README / doc update to explain the import_env usage

# Compose a CLI and export it as "BITOPS_{PLUGIN_NAME}_CLI}"
cli = PluginConfigCLI(cli_config_list).get_command()
os.environ[f"BITOPS_{plugin_name.upper()}_CLI"] = cli
logger.debug(f"Exported CLI: {cli}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Keeping in line with almost all other log event in BitOps I would suggest you change {} to []

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, updated in c3e5e12

logger.debug(f"\n\t\tKEY [{key}] \n\t\tRESULT FOUND: [{obj}]")
return obj

@staticmethod
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good additions 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, small steps

For every plugin config property, there is an associated ENV variable name that could be used to override the value.

Config `ansible.properties.options.verbosity` => `BITOPS_ANSIBLE_VERBOSITY`
Copy link
Copy Markdown
Contributor

@PhillypHenning PhillypHenning left a comment

Choose a reason for hiding this comment

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

It would be ideal if we could add a blurb about using this new behavior in the local development devops.sh doc

@arm4b
Copy link
Copy Markdown
Contributor Author

arm4b commented Feb 17, 2023

The new "magic" ENV behavior and CLI should be documented for sure, I have it as a checklist item in the #403 (comment).

Thinking about merging the functionality first to have the bitops:dev tag.
I'm guessing I'll have some minor adjustments after testing it with the :dev tag in GHA and so docs adjustments may come with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI args to the plugins are not passed

2 participants