hammer

command module
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

README

hammer - wrapper CLI for interacting with PCF environments

Test Status

Installation

The latest build of the hammer cli is available from the releases page. Download the tar for your platform, untar it, and move it to your $PATH.

Or using brew on macOS or Linux:

brew tap pivotal/hammer https://github.com/pivotal/hammer
brew install hammer

Alternatively you can build hammer from source if you have Go installed:

git clone git@github.com:pivotal/hammer.git && cd hammer && go install

You will also need to install, separately, any of the underlying cli tools that hammer will use in your workflow. hammer does not include cf, bosh, om, etc.

Config

In order to run the hammer tool against a given environment you need to have an environment config file in the following format:

{
  "name": "ENVIRONMENT-NAME",
  "ops_manager": {
    "url": "OPSMAN-URL",
    "client_id": "OPSMAN-CLIENT-ID",
    "client_secret": "OPSMAN-CLIENT-SECRET",
    "username": "OPSMAN-USERNAME",
    "password": "OPSMAN-PASSWORD"
  },
  "ops_manager_private_key": "OPSMAN-RSA-PRIVATE-KEY",
  "ops_manager_public_ip": "OPSMAN-PUBLIC-IP",
  "ops_manager_ssh_user": "OPSMAN-SSH-USER",
  "sys_domain": "PAS-SYSTEM-DOMAIN",
  "pks_api":  {
     "url": "PKS-API-URL"
  }
}

Or the equivalent in yaml:

name: ENVIRONMENT-NAME
ops_manager:
  client_id: OPSMAN-CLIENT-ID
  client_secret: OPSMAN-CLIENT-SECRET
  password: OPSMAN-PASSWORD
  url: OPSMAN-URL
  username: OPSMAN-USERNAME
ops_manager_private_key: OPSMAN-RSA-PRIVATE-KEY
ops_manager_public_ip: OPSMAN-PUBLIC-IP
ops_manager_ssh_user: OPSMAN-SSH-USER
pks_api:
  url: PKS-API-URL
sys_domain: PAS-SYSTEM-DOMAIN

This file can then be passed into the tool via hammer -t path-to-env-config <command>.

ops_manager_ssh_user is an optional field and if not set then hammer -t path-to-env-config ssh opsman will use ubuntu to ssh to the OpsManager VM, if users need to ssh via a different username they should set this as appropriate.

Only one set of ops_manager.client_id and ops_manager.client_secret or ops_manager.username and ops_manager.password need to be specified, if both sets are specified then in line with om the client details will be used.

NB: sys_domain and pks_api.url are only needed for using hammer cf-login and hammer pks-login respectively.

Multiple environments in a single config

The config file can contain a list of environments in previously defined structure, such as:

[{
  "name": "ENVIRONMENT-NAME-1",
  "ops_manager": {
    "url": "OPSMAN-URL",
    "client_id": "OPSMAN-CLIENT-ID",
    "client_secret": "OPSMAN-CLIENT-SECRET",
    "username": "OPSMAN-USERNAME",
    "password": "OPSMAN-PASSWORD"
  },
  "ops_manager_private_key": "OPSMAN-RSA-PRIVATE-KEY",
  "ops_manager_public_ip": "OPSMAN-PUBLIC-IP",
  "ops_manager_ssh_user": "OPSMAN-SSH-USER",
  "sys_domain": "PAS-SYSTEM-DOMAIN",
  "pks_api":  {
     "url": "PKS-API-URL"
  }
},
{
  "name": "ENVIRONMENT-NAME-2",
  "ops_manager": {
    "url": "OPSMAN-URL",
    "client_id": "OPSMAN-CLIENT-ID",
    "client_secret": "OPSMAN-CLIENT-SECRET",
    "username": "OPSMAN-USERNAME",
    "password": "OPSMAN-PASSWORD"
  },
  "ops_manager_private_key": "OPSMAN-RSA-PRIVATE-KEY",
  "ops_manager_public_ip": "OPSMAN-PUBLIC-IP",
  "ops_manager_ssh_user": "OPSMAN-SSH-USER",
  "sys_domain": "PAS-SYSTEM-DOMAIN",
  "pks_api":  {
    "url": "PKS-API-URL"
  }
}]

Or the equivalent in yaml:

- name: ENVIRONMENT-NAME-1
  ops_manager:
    client_id: OPSMAN-CLIENT-ID
    client_secret: OPSMAN-CLIENT-SECRET
    password: OPSMAN-PASSWORD
    url: OPSMAN-URL
    username: OPSMAN-USERNAME
  ops_manager_private_key: OPSMAN-RSA-PRIVATE-KEY
  ops_manager_public_ip: OPSMAN-PUBLIC-IP
  ops_manager_ssh_user: OPSMAN-SSH-USER
  pks_api:
    url: PKS-API-URL
  sys_domain: PAS-SYSTEM-DOMAIN
- name: ENVIRONMENT-NAME-2
  ops_manager:
    client_id: OPSMAN-CLIENT-ID
    client_secret: OPSMAN-CLIENT-SECRET
    password: OPSMAN-PASSWORD
    url: OPSMAN-URL
    username: OPSMAN-USERNAME
  ops_manager_private_key: OPSMAN-RSA-PRIVATE-KEY
  ops_manager_public_ip: OPSMAN-PUBLIC-IP
  ops_manager_ssh_user: OPSMAN-SSH-USER
  pks_api:
    url: PKS-API-URL
  sys_domain: PAS-SYSTEM-DOMAIN

An environment can then be specified via hammer -t path-to-env-config -e environment-name <command>. If an environment name is not specified then the first environment in the config will be used.

Development

Unit and integration tests can be run if you have Ginkgo installed:

ginkgo -r .

Linters can also be run using golangci-lint:

golangci-lint run

Or just run both with:

make test

Special thanks to @blgm for letting an internal tool he created serve as the basis for this tool.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
commandsfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
scriptingfakes
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL