Skip to content

Instantly share code, notes, and snippets.

@tjhop
Created November 10, 2022 02:06
Show Gist options
  • Save tjhop/7e088c26b88b47138f5ae4281a2147af to your computer and use it in GitHub Desktop.
Save tjhop/7e088c26b88b47138f5ae4281a2147af to your computer and use it in GitHub Desktop.
~/go/src/github.com/tjhop/linode-tagger (main [ U ]) -> linode-cli linodes list --json | jq '.[] | select(.label | startswith("tagger")) | .label, .tags'
"tagger-1_us-southeast_testing"
[]
~/go/src/github.com/tjhop/linode-tagger (main [ U ]) -> cat packaging/etc/tagger.yml
tagger:
instances:
- regex: '^.+_(.+)_(.+)$'
tags:
present:
- 'region=$1'
- 'environment=$2'
absent: []
~/go/src/github.com/tjhop/linode-tagger (main [ U ]) -> ./dist/linode-tagger_linux_amd64_v1/tagger --config packaging/etc/tagger.yml --dry-run --json | jq '.'
time="2022-11-09T21:04:27-05:00" level=info msg="Gathering objects on this account" func="main.tagger()" file="tagger.go:593"
time="2022-11-09T21:04:28-05:00" level=info msg="Checking linode object tags against config file" func="main.tagger()" file="tagger.go:638"
time="2022-11-09T21:04:28-05:00" level=info msg="Dry run enabled, not applying tags." func="main.tagger()" file="tagger.go:651"
{
"instances": [
{
"id": 40112098,
"label": "tagger-1_us-southeast_testing",
"diff": {
"added": [
"environment=testing",
"region=us-southeast"
],
"removed": null
}
}
],
"domains": null,
"nodebalancers": null,
"lkeclusters": null,
"volumes": null
}
~/go/src/github.com/tjhop/linode-tagger (main [ U ]) -> ./dist/linode-tagger_linux_amd64_v1/tagger --config packaging/etc/tagger.yml --json | jq '.'
time="2022-11-09T21:04:36-05:00" level=info msg="Gathering objects on this account" func="main.tagger()" file="tagger.go:593"
time="2022-11-09T21:04:36-05:00" level=info msg="Checking linode object tags against config file" func="main.tagger()" file="tagger.go:638"
time="2022-11-09T21:04:36-05:00" level=info msg="Applying new tags to objects that need updating" func="main.tagger()" file="tagger.go:642"
{
"instances": [
{
"id": 40112098,
"label": "tagger-1_us-southeast_testing",
"diff": {
"added": [
"environment=testing",
"region=us-southeast"
],
"removed": null
}
}
],
"domains": null,
"nodebalancers": null,
"lkeclusters": null,
"volumes": null
}
~/go/src/github.com/tjhop/linode-tagger (main [ U ]) -> linode-cli linodes list --json | jq '.[] | select(.label | startswith("tagger")) | .label, .tags'
"tagger-1_us-southeast_testing"
[
"environment=testing",
"region=us-southeast"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment