Simple helper script to list and delete ecr images.
- copy
.env.example
to.env
- replace / add required values
- We initialize the aws client with default setup
- For that, it's expected that you follow the standard aws configuration setup. E.g
- using the standard environment variables;
- having appropriate profiles in a configuration file in, for example,
~/.aws/credentials
- in that case, replacing the variables in the provided
.env
file should suffice
- in that case, replacing the variables in the provided
- etc..
- for more info about that, check out their docs
- build / install
- help
./ecr_cleaner --help
Obs.: since this project is built with cobra, all commands have the --help
flag
-
ecr_cleaner
only uses two flags, both required. They are:-r
or--repository
-> for passing the ecr repository name-p
or--pattern
-> for passing the pattern with which you wish to search the repository with
-
list images
./ecr_cleaner list -r repository_name -p tag_pattern
- delete images
./ecr_cleaner delete -r repository_name -p tag_pattern
-
user provided patterns are compiled as-is (so no escaping)
- this means regex metacharacters will be interpreted as such
- if you wish to match literal characters instead, you have two options
- escape them yourself (might require double backslack
\\
) - use the optional
-e
flag- this uses QuoteMeta to escape all metacharacters in the provided string
- escape them yourself (might require double backslack
-
As example, some possible patterns could be:
- jira ticket references, if you tag your test images with that:
REF-1234
- the normal SemVer version itself:
1.9.0
- since we ignore normal SemVer version, this will only return the pre-release versions associated with it. e.g.:
1.9.0-testing-new-endpoint
1.9.0-alpha.1
1.9.0-rc1
1.9.0.1-REF-1234
- etc..
- BUT NOT:
1.9.0
itself
- since we ignore normal SemVer version, this will only return the pre-release versions associated with it. e.g.:
- jira ticket references, if you tag your test images with that:
Tags matching normal SemVer versions (X.Y.Z
) are never returned by any commands on purpose, to make sure we don't screw up with important images.