Drone.io plugin to facilitate the use of Google Deployment Manager in drone deploy phase.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
plugin
travis
util
.gitignore
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
Dockerfile
LICENSE.md
README.md
composite.go
config.go
context.go Normalize template env var schemes between files May 22, 2018
deployment.go
drone.go
gdm.go
glide.lock
glide.yaml
main.go Idiomatic go: shuffle source files into root dir May 22, 2018
parse.go
parse_test.go
run.go
run_test.go
typeprovider.go
yaml2json.go

README.md

drone-gdm

Build Status

A simple drone plugin which wraps Google Deployment Manager.

Docker Tags

All Versions

1.x Series

  • the latest tag to get the latest v1.x stable
  • the beta tag to get the latest beta release
  • the alpha tag to get the latest alpha release
  • the develop tag to get the last thing that built (alpha, beta, and develop tags introduced as of 1.2.1a)

Starting with version 2.0.0a the tag scheme is prefixed with major version, e.g:

  • the v2-alpha tag to get the latest 2.x alpha release
  • the v2-beta tag to get the latest 2.x beta release
  • the v2-stable tag to get the latest 2.x stable release This pattern will continue with subsequent major version releases; enabling you to pin your build to the latest stable version of any given backwards-compatible, major-level release

Features

  • Set the desired state (absent, present, or latest) and the plugin determines whether to create, update, or delete.
  • Support for GDM Beta Composite Types

Compatibility

Drone-GDM has been tested with drone 0.4 and 0.8.

Usage

The bulk of the input parameters are mapped directly to gcloud command options. Documentation follows for the handful of parameters which are particular to drone-gdm.

State and Action

The state can be one of absent, present, or latest.

Plugin "state" Object Exists? Action
present no create
present yes no action
latest no create
latest yes update
absent no no action
absent yes delete

The specific action selected by drone-gdm can be provided to your template as a property, by specifying passAction: true. This will invoke your configuration or template with --properties=action:<action from table above>.

Variables

To circumvent data-type limitations imposed by the passing of properties via the deployment manager --properties option, template and configurations files passed to drone-gdm are first parsed as golang templates with the following top-level interfaces available for variable interpolation:

  • .drone - Drone environment variables provided by the CI system during plugin invocation
  • .plugin - Plugin parameters passed via environment during plugin invocation
  • .context - Any variables defined in the vars section of the plugin invocation
  • .config - Any variables defined in the vars section of the configuration definition
  • .properties - Variables defined in the properties section of the configuration definition
  • .gdm - A dictionary containing:
    • name - entity name for the configuration/template/composite
    • status - the entity status (e.g. DEPRECATED, EXPERIMENTAL, SUPPORTED)
    • project - the GCP project name
    • action - the gcloud "action" parameter (i.e. create, update, or delete)

Example with Inline Configurations

deploy:
  gdm:
    # Indicate where to acquire the image:
    image: nytimes/drone-gdm:2.0.0

    # Provided JSON auth token (from drone secrets):
    gcloudPath: /bin/gcloud   # path to gcloud executable
    verbose: false            # (optional)
    dryRun: false             # (optional)
    token: >
      $$GOOGLE_JSON_CREDENTIALS
    project: my-gcp-project   # Da--project
    preview: false            # --preview
    async: false              # --async
    vars:
    - myCtxVar: ctxVal1
    - myOtherCtxVar: ctxVal2

    configurations:
    - name:  my-provider
      group: typeprovider
      state: present
      descriptorURL: https://cloudtasks.googleapis.com/$discovery/rest?version=v2beta3
      apiOptions: ./api-options-definition.yaml # path to api options YAML
    - name:  my-deployment
      group: deployment
      state: present
      path: ./my-deployment.yaml
      description: A GDM Deployment
      vars:
      - myCfgVar: cfgVal1
      - myOtherCfgVar: cfgVal2
      properties:    # mapped to gcloud '--properties=...'
        myvar: myval # can be referenced in jinja as: {{ properties.myvar }}
      labels:        # mapped to '--labels' or '--update-labels', as appropriate
        mylabel: labelval
      autoRollbackOnError: false
      createPolicy: CREATE_OR_ACQUIRE # Optional: CREATE_OR_ACQUIRE or CREATE
      deletePolicy: DELETE # Optional: DELETE or ABANDON
      passAction: false # if true, pass action as property, e.g. "action:update"

    - name:  my-composite
      version: beta  # gcloud version to use
      group: composite
      state: present
      path: ./my-composite.jinja
      description: A GDM "Composite Type"
      labels: # mapped to '--labels' or '--update-labels', as appropriate
        mylabel: labelval
      status: SUPPORTED # Optional: SUPPORTED, DEPRECATED, or EXPERIMENTAL
      passAction: false

Example with Inline and External Configurations

deploy:
  gdm:
    # Indicate where to acquire the image:
    image: nytimes/drone-gdm:2.0.0

    # Provided JSON auth token (from drone secrets):
    gcloudPath: /bin/gcloud   # path to gcloud executable
    verbose: false            # (optional)
    dryRun: false             # (optional)
    token: >
      $$GOOGLE_JSON_CREDENTIALS
    project: my-gcp-project   # Da--project
    preview: false            # --preview
    async: false              # --async

    vars:
       prefix: test1
    configFile: my-configurations.yml
    configurations:
    - name:  my-deployment
      group: deployment
      state: present
      path: ./my-deployment.yaml
      description: A GDM Deployment
      properties:    # mapped to gcloud '--properties=...'
        myvar: myval # can be referenced in jinja as: {{ properties.myvar }}
      labels:        # mapped to '--labels' or '--update-labels', as appropriate
        mylabel: labelval
      autoRollbackOnError: false
      createPolicy: CREATE_OR_ACQUIRE # Optional: CREATE_OR_ACQUIRE or CREATE
      deletePolicy: DELETE # Optional: DELETE or ABANDON
      passAction: false # if true, pass action as property, e.g. "action:update"
my-configurations.yml
# Parsed as a golang template with variables populated from "vars" above.
- name:  {{.prefix}}-composite
  version: beta  # gcloud version to use
  group: composite
  state: present
  path: ./my-composite.jinja
  description: A GDM "Composite Type"
  labels: # mapped to '--labels' or '--update-labels', as appropriate
    mylabel: labelval
  status: SUPPORTED # Optional: SUPPORTED, DEPRECATED, or EXPERIMENTAL
  passAction: false

Resources