0.0.1 • Published 5 years ago

bvapigee v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

apigee-cli

CLI tool desinged to aid the CI/CD process of Apigee artifacts, even across different Apigee instances.

Installation

npm install -g git+ssh://git@github.com:bazaarvoice/apigee-cli.git

Usage

Terminology

  • export: download artifact from the specified Apigee source instance
  • include: using the previously exported artifacts, add the respective files into your Apigee configuration source
  • package: using the previously included sources, package them so that they can be imported into an Apigee instance
  • import: create/update artifact in the specified Apigee destination instance

config.json

Create config.json from config.json.example

  • credentials: default credentials to be used for source and destination configurations
  • source: defines Apigee instance which will be queried
    • can specify own credentials configuration
  • destination: defines Apigee instance which will receive updates
    • can specify own credentials configuration
  • directory: specifies the directories which will be used for the various artifact related processes
  • plugins: specify the globally installed plugins to load

Methodology

This tool does not perscribe much about how CI/CD must be done. It's only requirements are that you specify known locations of where artifacts will be exported, included, and packaged. Given those facts, any number of custom CI/CD processes can be implemented.

Proxy Cloning

Apigee Edge UI does allow for multiple developers to edit Apigee artifacts in a maintanable manner. Developers can inadvertantently make conflicting changes to artifacts. For this reason the concept of proxy cloning has been added to this tool. Given a proxy name and a label, a unique identifier, a clone of the proxy can be created alongside all of its dependencies (sharedflows, kvms, etc). All of the dependencies will also adorn the specified label.

A developer can now make and test changes in an isolated way via the Apigee Edge UI without having to worry if another developer is also making changes.

Basic Proxy Cloning Workflow
  1. Clone desired proxy
apigee proxy clone create myproxy mylabel
  1. Deploy desired proxy
apigee proxy clone deploy myproxy mylabel
  1. Make changes to proxy clone in Apigee Edge UI
  2. Export changes made to proxy clone
apigee proxy clone export myproxy mylabel
  1. Apply the changes to source
apigee proxy include --name myproxy
  1. Commit changes to source control
  2. Package and deploy updated proxy
apigee proxy package --name myproxy
apigee proxy import --name myproxy

Commands

Every command has a help subcommand, use it to get details about the command:

apigee help

Any value defined in the config.json can be overriden via CLI arguments:

apigee kvm list --source.organization <org> --source.environment <env>

Plugins

Plugins are yargs commands exported from an npm package.

A plugin package needs to export a yargs CommandModule object which apigee-cli will load and expose the underlying commands.

  1. Export a yargs CommandModule from plugin package
import yargs from 'yargs';

const Command: yargs.CommandModule = {
    command: 'bv <command>',
    describe: 'bazaarvoice commands',
    builder: (yargs: yargs.Argv) => {
        return yargs
            .commandDir("cmds");
    },
    handler(/*args: any*/) { }
};

export = Command;
  1. Install plugin globally for apigee-cli to be able to load
npm install -g your-plugin
  1. Add the plugin package to config.json
"plugins": ["your-plugin"]
  1. Your plugins commands are now available via apigee-cli:
apigee help

Development

  1. Fork the repo
  2. Clone your fork

Requirements

  • nvm for Node version management
    • brew install nvm
    • run nvm install and nvm use commands inside the project directory

      • the .nvmrc will be used to determine which node version to install and use
  • Visiual Studio Code for editing and debugging
    • brew cask install visual-studio-code