Circle Context Validation in Code
npm install @armakuni/circleci-context-validatorCircleCI Context Validator CLI Tool
=================

* Purpose
* Prerequisites
* Install
* Commands
* Example
* Dev Mode
* Upcoming & WIP
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.
sh-session
$ npm install -g @armakuni/circleci-context-validator
`
or
`sh-session
$ yarn global add @armakuni/circleci-context-validator
`Commands
`
$ ccv (--version)
@armakuni/circleci-context-validator/ 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:
`sh
CIRCLECI_PERSONAL_ACCESS_TOKEN=example-token ccv circleci validate --context-definitions .circleci/context_validator.yml
`
!example cli usageAll 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)
`sh-session
CIRCLECI_PERSONAL_ACCESS_TOKEN=generate_personal_access_token bin/dev circleci validate --context-definitions example/context_validator.yml
``