Skip to content

Conversation

@ConnorGraham
Copy link
Contributor

@ConnorGraham ConnorGraham commented Jan 29, 2021

Plugin implementation using Python (#54)

Overview

If plugin.config.yml (new file) is as follows

plugins:
- name: fav-color
  repo: https://github.com/ConnorGraham/bitops-sample-plugin.git

Then on docker build, scripts/setup/install_plugins.py is called to

  1. git clone the fav-color repo to scripts/plugins/fav-color/
  2. Call scripts/plugins/fav-color/install.sh if it exists

During BitOps execution, $SCRIPTS_DIR/plugins/deploy.py is called to loop through all plugins and:

  1. set env vars PLUGIN_DIR and ENVIRONMENT_DIR
  2. Call before hooks
  3. Reconcile $PLUGIN_DIR/bitops.schema.yaml and $ENVIRONMENT_DIR/bitops.config.yaml
  4. source env vars from previous setup along with CLI_OPTIONS
  5. Call scripts/plugins/fav-color/deploy.sh
  6. Call after hooks

Testing

Docker Build

We can see in the docker build -t temp . log, that

Cloning into '/opt/bitops/scripts/plugins/fav-color'...

When including a plugin in a BitOps install, this script will be called during docker build.
It should be used to install any dependencies required to actually run your plugin.
BitOps uses alpine linux as its base, so you'll want to use apk commands (Alpine Package Keeper)

musl
busybox
alpine-baselayout
alpine-keys
libcrypto1.1

Runtime

Operations Repo

My operations repo contains only 1 file test/fav-color/bitops.config.yaml:

my-fav-color:
  cli:
    version: 0.1.0
  options:
    name: connor
    color: red

BitOps execution (truncated):

We can see that

connor@Connors-MacBook-Pro bitops-custom % docker run -e ENVIRONMENT=test -v $(pwd):/opt/bitops_deployment temp
making a temporary directory
TEMPDIR: /tmp/tmp.cMLNoH
environment variable (DEBUG) not set
Successfully Copied repo to /tmp/tmp.cMLNoH 

Loading BitOps Config for fav-color
Calling /opt/bitops/scripts/plugins/fav-color/deploy.sh

Welcome to the BitOps sample plugin!
The follow environment variables are available on every plugin:
PLUGIN_DIR: The root of your plugin directory. Useful if you want to invoke other scripts!
PLUGIN_DIR=/opt/bitops/scripts/plugins/fav-color

ENVIRONMENT_DIR: The location of your operations repo code for your plugin
ENVIRONMENT_DIR=/tmp/tmp.cMLNoH/test/fav-color

All the options defined in your plugin's bitops.schema.yaml. These values are overridden by bitops.config.yaml files in operations repos
MY_FAV_COLOR=red
MY_NAME=connor

Lastly, options defined as cli options will be formatted and available in the CLI_OPTIONS env var
CLI_OPTIONS= --version=0.1.0  

Lets test it out!
Hello connor! Your favourite color is red!


cleaning up...
/tmp/tmp.cMLNoH
removing temporary directory: /tmp/tmp.cMLNoH
BitOps Completed.% 

@ConnorGraham ConnorGraham added the enhancement ✨ New feature or request label Jan 29, 2021
@ConnorGraham ConnorGraham linked an issue Feb 1, 2021 that may be closed by this pull request
Copy link
Contributor

@dylan-bitovi dylan-bitovi left a comment

Choose a reason for hiding this comment

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

I've been playing around with this and hashing it out with Connor over Slack. Everything looks good to me :)

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.

@PhillypHenning PhillypHenning changed the base branch from master to main July 29, 2022 15:36
phil8t8-stack and others added 16 commits July 29, 2022 15:14
…uirements

The plugins-base ONBUILD stage should require `bitops.config.yaml` file only per plugins documentation so users can build their own BitOps image
It's replaced by the publish-docs.yaml for the `main` branch
* Fix 'disbatch' -> 'dispatch' typo in the CD workflows

* Additional image tagging for ':latest', ':dev', and ':base'

* Additional image tagging for ':latest', ':dev', and ':base'

* Adjust the base workflow with additional release tag

* Remove the 'v' prefix from the v1.2.3 for docker tagging

* Match image tag that ends with 'omnibus'
* Fix plugins install not returning correct exit code on failure

Fixes #239

* Use the proper logger.error on a plugin failure
@PhillypHenning PhillypHenning merged commit 702d35d into main Aug 3, 2022
@mickmcgrath13 mickmcgrath13 deleted the plugins branch August 4, 2022 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ✨ New feature or request plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bitops Plugins

8 participants