0.1.7 • Published 2 years ago

@armakuni/circleci-context-validator v0.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

CircleCI Context Validator CLI Tool

CircleCI

Purpose

As projects grow, team members drop in and out and the documented state of environment variables become a mystery, and left in a precarious state not knowing if a varaible is required any more looking at the Circle UI.

CircleCI Context Validator (CCV for short) makes use of a simple yaml configuration file, refer to the example. The configuration file refers to the names of the context and associated environment variables. The config should reflect what should only be present in your context (can be more than one, should you need that), is then compared against the API giving back user input on valid or failures.

Prerequisites

Install

$ npm install -g @armakuni/circleci-context-validator

or

$ yarn global add @armakuni/circleci-context-validator

Commands

$ ccv (--version)
@armakuni/circleci-context-validator/<semver> darwin-x64 node-v16.13.1
$ ccv --help [COMMAND]
USAGE
  $ CIRCLECI_PERSONAL_ACCESS_TOKEN=example-token ccv circleci validate --context-definitions example/context_validator.yml
USAGE
  $ ccv help [COMMAND] [-n]

ARGUMENTS
  COMMAND  Command to show help for.

FLAGS
  -n, --nested-commands  Include all nested commands in the output.

DESCRIPTION
  Display help for ccv.

Examples

Run the CLI tool:

CIRCLECI_PERSONAL_ACCESS_TOKEN=example-token ccv circleci validate --context-definitions .circleci/context_validator.yml

example cli usage

All Valid

Context exists, associated env var values configured exist in context definition yaml.

Context "context-validator-ci" is valid
Success

Missing Env Var

Configured in context definition yaml, but not present in CircleCI Context

Missing Env Var "API_KEY" in Context "context-validator-ci"
Failures 1

Missing Context

Configured in context definition yaml, but not present in CircleCI Context

Context "context-validator-cid" is missing
Failures 1

Undocumented

A value is not configured, but exists in circleci

Unexpected Env Var "NPM_TOKEN" in Context "context-validator-ci"
Failures 1

Development

How to dev on circleci-context-validator, for a quick start guide checkout oclif which this tool makes heavy use of.

Entrypoint

Command entrypoint is located: circleci-context-validator/src/commands/circleci/validate

NVM

$ cd circleci-context-validator
$ nvm use .

Dev Run (no compile)

CIRCLECI_PERSONAL_ACCESS_TOKEN=generate_personal_access_token bin/dev circleci validate --context-definitions example/context_validator.yml

Upcoming

  • Pretty console output
  • Different output formats e.g. JSON
  • Support for standard Environment Variables i.e. non-context associated
  • Autocomplete commands
  • Retrieve existing context and associated env vars to pre-populate a context_validator.yml