Allows you to create local aliases within directory/repository with proper assertions upon executions.
APACHE-2.0 License
Allows you to create local aliases withing directory/repository with proper assertions upon executions.
Motivation:
Install via brew
:
# Will be simplified
brew tap aaabramov/goal https://github.com/aaabramov/goal
brew install aaabramov/goal/goal
Run goal init
in directory where aliases will be used. This will generate example goal.yaml
file. Use it as a reference to define your own aliases.
$ goal init
⌛ Generating default goal.yaml file
✅ Generated default goal.yaml file. Try running `goal` to see available goals.
Simply type goal
to see list of available goals and their dependencies:
$ goal
Available goals:
+---------------------+-------------+-----------------------------------------------------------------+-----------------------------+--------------------------------------------------+
| GOAL | ENVIRONMENT | CLI | DESCRIPTION | ASSERTIONS |
+---------------------+-------------+-----------------------------------------------------------------+-----------------------------+--------------------------------------------------+
| gcloud-ssh | dev | gcloud compute ssh dev-vm --zone=us-central1-c | SSH to dev | 1. gcloud.project == "dev-project" |
+ +-------------+-----------------------------------------------------------------+-----------------------------+--------------------------------------------------+
| | stage | gcloud compute ssh stage-vm --zone=us-central1-c | SSH to stage | 1. gcloud.project == "stage-project" |
+---------------------+-------------+-----------------------------------------------------------------+-----------------------------+--------------------------------------------------+
| helm-upgrade | dev | helm upgrade release-name -f values.yaml -f values/dev.yaml . | helm upgrade on dev | 1. kubectl.context == "gke_project_region_dev" |
+ +-------------+-----------------------------------------------------------------+-----------------------------+--------------------------------------------------+
| | stage | helm upgrade release-name -f values.yaml -f values/stage.yaml . | helm upgrade on stage | 1. kubectl.context == "gke_project_region_stage" |
+---------------------+-------------+-----------------------------------------------------------------+-----------------------------+--------------------------------------------------+
| k8s-apply | dev | kubectl apply -f deployment.yaml | kubectl apply on dev | 1. kubectl.context == "gke_project_region_dev" |
| | | | | 2. Manual approval |
+ +-------------+ +-----------------------------+--------------------------------------------------+
| | stage | | kubectl apply on stage | 1. kubectl.context == "gke_project_region_stage" |
| | | | | 2. Manual approval |
+---------------------+-------------+-----------------------------------------------------------------+-----------------------------+--------------------------------------------------+
| terraform-apply | dev | terraform apply -var-file vars/dev.tfvars | Terraform apply on dev | 1. terraform.workspace == "dev" |
+ +-------------+-----------------------------------------------------------------+-----------------------------+--------------------------------------------------+
| | stage | terraform apply -var-file vars/stage.tfvars | Terraform apply on stage | 1. terraform.workspace == "stage" |
+---------------------+-------------+-----------------------------------------------------------------+-----------------------------+--------------------------------------------------+
| terraform-workspace | | terraform workspace show | Current terraform workspace | |
+---------------------+-------------+-----------------------------------------------------------------+-----------------------------+--------------------------------------------------+
| test | | go test -v ./... | Run go tests | |
+---------------------+-------------+-----------------------------------------------------------------+-----------------------------+--------------------------------------------------+
pods:
desc: Get nginx pods
cmd: kubectl
args:
- get
- pods
- -l
- app=nginx
svc:
desc: Get nginx services
cmd: kubectl
args:
- get
- svc
- -l
- app=nginx
# This example demonstrates how to use custom assertions upon executions.
my-assertion:
desc: Ultimate Question of Life?
cmd: echo
args:
- -n
- $((40 + 2))
my-goal:
desc: The Answer to the Ultimate Question of Life
assert:
- desc: If answer is 42..
ref: my-assertion # references another goal
expect: '42'
fix: # CLI on how to fix
- approve: yes # ask user to config execution
cmd: echo
args:
- The Answer to the Ultimate Question of Life, the Universe, and Everything is 42
Tool | Example |
---|---|
approval | examples/kubectl |
kubectl | examples/kubectl |
helm | examples/helm |
terraform | examples/terraform |
gcloud | examples/gcloud |
TODO
assert.fix
. Display when assertion failed, e.g. terraform workspace select dev
goal tf-apply --on dev
goal.env: dev
matches-f my-goal.yaml
goal init
which simply generated example goal.yaml
k8s_cluster
terraform_workspace
gcloud_project
Check if current kubectl context is "gke_project_region_stage"
-> kubectl.context == "gke_project_region_stage"
brew tap aaabramov/goal
assert.approval
$HOME
directory?goal.yaml
(ops-doc)goal add GOAL_NAME
-- check if already existsFatal
with err
fix?
when precondition failed with yes/no
promptgoal.name
if there is no specific for env goalsource <(goal completion zsh)
did you forget "--on env"
when command name is found but env is required