Adding support for fully qualified allow list eg user=bob

before thhis change the allow list would only support checking the 'pool' label value
we can now specify a different label name by using the format labename=value where
the equal sign '=' is considered the separator
This commit is contained in:
Samuel Beaulieu 2021-12-09 11:33:10 -06:00
parent fc7a628063
commit f6791baba0
No known key found for this signature in database
GPG key ID: 12030F74136D0F34
3 changed files with 66 additions and 21 deletions

View file

@ -13,23 +13,27 @@
# (optional: will default to it's parent :key: name eg. 'gce')
#
# - purge_unconfigured_resources
# Enable purging of VMs detected
# By default will purge VMs in the project without a "pool" label, or a "pool" label with the value for an unconfigured pool
# Enable purging of VMs, disks and snapshots
# By default will purge resources in the project without a "pool" label, or a "pool" label with the value for an unconfigured pool
# An optional allowlist can be provided to ignore purging certain VMs based on pool labels
#
# Setting this on the provider will enable purging for the provider
# Expects a boolean value
# (optional; default: false)
#
# - recources_allowlist
# For GCE: Specify pool labels that should be ignored when purging VMs, for pools that are not configured. For example if the label is
# set to 'pool=donotdelete' and there is no pool with that name configured, adding "donotdelete" to the allowlist would not purge the VM.
# adding "" (empty string) to the allowlist has a special meaning whereas VMs that do not have the "pool" label are also not purged.
# - resources_allowlist
# For GCE: Specify labels that should be ignored when purging VMs. For example if a VM's label is
# set to 'pool' with value 'donotdelete' and there is no pool with that name configured, it would normally be purged,
# unless you add a resources_allowlist "donotdelete" in which case it is ignored and not purged.
# Additionally the "" (empty string) has a special meaning whereas VMs that do not have the "pool" label are not purged.
# Additionally if you want to ignore VM's with an arbitrary label, include it in the allow list as a string with the separator "="
# between the label name and value eg user=bob would ignore VMs that include the label "user" with the value "bob"
# If any one of the above condition is met, the resource is ignored and not purged
# This option is only evaluated when 'purge_unconfigured_resources' is enabled
# Expects an array of strings specifying the allowlisted labels by name
# Expects an array of strings specifying the allowlisted labels by name. The strings should be all lower case, since
# no uppercase char is allowed in a label
# (optional; default: nil)
#
# If you want to support more than one provider with different parameters (server, username or passwords) you have to specify the
# If you want to support more than one provider with different parameters you have to specify the
# backing service in the provider_class configuration parameter for example 'vsphere' or 'dummy'. Each pool can specify
# the provider to use.
#
@ -43,6 +47,10 @@
provider_class: 'gce'
project: 'myproject-foo'
zone: 'us-central1-f'
resources_allowlist:
- "user=bob"
- ""
- "custom-pool"
# :gce:
#