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

Fix installed plugins to use a dedicated dir to prevent naming conflict #347

Merged
merged 13 commits into from
Nov 21, 2022

Conversation

PhillypHenning
Copy link
Contributor

@PhillypHenning PhillypHenning commented Nov 4, 2022

Description

Updating where plugins are installed by updating the path that is used.

fixes #339

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update

How Has This Been Tested?

I tested this locally, proof is in the issue ticket.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

bitops.schema.yaml Outdated Show resolved Hide resolved
scripts/plugins/logging.py Outdated Show resolved Hide resolved
@PhillypHenning PhillypHenning force-pushed the installed_plugins branch 2 times, most recently from d8197f8 to 8719afc Compare November 8, 2022 17:52
@arm4b arm4b added this to the v2.2.0 milestone Nov 8, 2022
@arm4b arm4b added the bug 🪲 Something isn't working label Nov 8, 2022
Copy link
Contributor

@mickmcgrath13 mickmcgrath13 left a comment

Choose a reason for hiding this comment

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

set to "request changes" to remove the schema config reference

Also, we'll probably want to check to be sure that all plugins that reference other plugins (helm references aws and kubectl, for example) are doing so via the $BITOPS_PLUGINS_DIR env var)

bitops.schema.yaml Outdated Show resolved Hide resolved
@PhillypHenning
Copy link
Contributor Author

Plugin confirmed usage of BITOPS_PLUGINS_DIR

  • Cloudformation
  • Helm

Plugins confirmed not to use BITOPS_PLUGINS_DIR or /scripts/plugin

  • Terraform
  • Ansible
  • kubectl
  • aws

docs/plugins.md Outdated Show resolved Hide resolved
@PhillypHenning PhillypHenning requested a review from arm4b November 15, 2022 17:55
@@ -45,7 +48,7 @@ def deploy_plugins(): # pylint: disable=too-many-locals,too-many-branches,too-m

bitops_dir = "/opt/bitops"
bitops_deployment_dir = "/opt/bitops_deployment/"
bitops_plugins_dir = bitops_dir + "/scripts/plugins/"
bitops_plugins_dir = BITOPS_plugin_dir
Copy link
Member

@arm4b arm4b Nov 16, 2022

Choose a reason for hiding this comment

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

This variable is used only once. We could remove the unneeded variable assignment from this line:

Suggested change
bitops_plugins_dir = BITOPS_plugin_dir

and use the original BITOPS_plugin_dir var later below:

\n\t BITOPS_PLUGIN_DIR: [{bitops_plugins_dir}] \

that will keep vars a bit cleaner in this function.

@PhillypHenning
Copy link
Contributor Author

Testing

docker run --rm -it --entrypoint bash bitops:latest

bash-5.0# ls -al /opt/bitops/scripts/
total 32
drwxr-xr-x    1 root     root          4096 Nov 21 16:54 .
drwxr-xr-x    1 root     root          4096 Nov 21 16:54 ..
drwxr-xr-x    2 root     root          4096 Nov 21 16:54 ci
drwxr-xr-x    8 root     root          4096 Nov 21 16:55 installed_plugins
-rwxr-xr-x    1 root     root          1838 Nov 10 17:09 main.py
drwxr-xr-x    1 root     root          4096 Nov 21 16:54 plugins
bash-5.0# ls -al /opt/bitops/scripts/installed_plugins/
total 36
drwxr-xr-x    8 root     root          4096 Nov 21 16:55 .
drwxr-xr-x    1 root     root          4096 Nov 21 16:54 ..
drwxr-xr-x    4 root     root          4096 Nov 21 16:55 ansible
drwxr-xr-x    3 root     root          4096 Nov 21 16:54 aws
drwxr-xr-x    4 root     root          4096 Nov 21 16:54 cloudformation
drwxr-xr-x    4 root     root          4096 Nov 21 16:54 helm
drwxr-xr-x    4 root     root          4096 Nov 21 16:54 kubectl
drwxr-xr-x    4 root     root          4096 Nov 21 16:54 terraform

@@ -39,6 +39,7 @@
BITOPS_ENV_run_mode = os.environ.get("BITOPS_MODE")
BITOPS_ENV_logging_level = os.environ.get("BITOPS_LOGGING_LEVEL")
BITOPS_ENV_plugin_dir = os.environ.get("BITOPS_PLUGIN_DIR")
BITOPS_ENV_installed_plugin_dir = os.environ.get("BITOPS_INSTALLED_PLUGIN_DIR")
Copy link
Member

Choose a reason for hiding this comment

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

If we agreed to not expose the configuration for this setting via bitops.config.yaml, can we exclude setting it from the ENV var as a source too?

That's again for the reasons of simplicity and avoiding exposing configuration that's not needed by the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right but plugin scripts directly use this env var ...

Copy link
Member

Choose a reason for hiding this comment

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

The exporting for the plugins looks fine.

But here we're importing the ENV var from the user's side. This could be removed as we don't want users to override this setting.

Copy link
Member

Choose a reason for hiding this comment

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

This would make BITOPS_INSTALLED_PLUGIN_DIR = /opt/bitops/scripts/installed_plugins/ a constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha 👍 Will fix this after lunch

@PhillypHenning PhillypHenning requested a review from arm4b November 21, 2022 18:54
Copy link
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

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

Looks good 👍
Thanks for all the changes!

@arm4b arm4b dismissed mickmcgrath13’s stale review November 21, 2022 22:38

The requested change to remove the config parameter was addressed

@arm4b arm4b merged commit d382d68 into main Nov 21, 2022
@arm4b arm4b deleted the installed_plugins branch November 21, 2022 22:38
@arm4b arm4b changed the title Updating install_plugins and settings file with installed_plugins path Fix installed plugins to use a dedicated path to prevent naming conflict Nov 22, 2022
@arm4b arm4b changed the title Fix installed plugins to use a dedicated path to prevent naming conflict Fix installed plugins to use a dedicated dir to prevent naming conflict Nov 22, 2022
@arm4b arm4b mentioned this pull request Dec 19, 2022
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plugins are installed into scripts/plugins which could lead to a conflict
3 participants