Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
fixing test fixtures

neuter more tumblr specifics
  • Loading branch information
byxorna committed Jul 3, 2019
1 parent 25de446 commit 39e6999
Show file tree
Hide file tree
Showing 24 changed files with 210 additions and 188 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@

# Documentation

## Quickstart

See [configuration overview](/docs/config.md) for how to write a config file. Then, map it into your container and run the report!

```
$ docker run -ti -v $(pwd)/config:/app/config --rm tumblr/docker-registry-pruner --mode report --config ./config/myconfig.yaml
```

Once you are happy with the report, you can perform pruning! WARNING: this is destructive!

```
$ docker run -ti -v $(pwd)/config:/app/config --rm tumblr/docker-registry-pruner --mode prune --config ./config/myconfig.yaml
```

## Configuration

See the [configuration overview](/docs/config.md) for how to write config files to apply retention rules to images in your Registry.
Expand Down
4 changes: 2 additions & 2 deletions config/examples/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ rules:
- php-runtime/dev/phpunit
keep_recent: 5

# keep 15 latest semantic versions of breakingbot
# keep 15 latest semantic versions of someslackbot
- repos:
- tumblr/breakingbot
- tumblr/someslackbot
match_tags:
- ^v\d+\.\d+\.\d+.*
keep_versions: 15
Expand Down
6 changes: 3 additions & 3 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A Rule is made up of a Selector, and an Action. See below for more details.

A selector is a predicate that images must satisfy to be considered by the `Action` for deletion.

* `repos` is a list of repositories to apply this rule to. This is literal string matching, _not_ regex. (i.e. `tumblr/redpop`)
* `repos` is a list of repositories to apply this rule to. This is literal string matching, _not_ regex. (i.e. `tumblr/plumbus`)
* `match_tags` is a list of regexp. Any matching image will have the rule action evaluated against it (i.e. `^v\d+`)
* `ignore_tags` is a list of regexp. Any matching image will explicitly not be evaluated, even if it would have matched `match_tags`

Expand Down Expand Up @@ -63,7 +63,7 @@ rules:
keep_versions: 5
- repos:
- tumblr/bb8
- tumblr/fleeble
match_tags:
- ^v\d+.\d+.\d+
keep_versions: 5
Expand All @@ -85,7 +85,7 @@ rules:
# keep only the most recent 5 images by modification time
- repos:
- tumblr/airflow
- web/devtools
keep_recent: 5
```

88 changes: 44 additions & 44 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ You can generate a report of actions it would take, without actually doing any d
```
$ ./bin/docker-registry-pruner -mode report -config ./config/gabe.yaml
{"level":"info","ts":1557265749.7190368,"caller":"cmd/main.go:51","msg":"Created Registry client for https://registry.company.net"}
{"level":"info","ts":1557265749.719176,"caller":"cmd/main.go:66","msg":"Loaded rule: Repos:tumblr/bb8,trash-island/docker-registry-pruner Selector{ignore tags [latest], match tags [^v\\d+\\.\\d+]} Action{keep latest 4 versions}"}
{"level":"info","ts":1557265749.719208,"caller":"cmd/main.go:71","msg":"Building image report for images: tumblr/bb8, trash-island/docker-registry-pruner"}
{"level":"info","ts":1557265749.719176,"caller":"cmd/main.go:66","msg":"Loaded rule: Repos:tumblr/fleeble,trash-island/docker-registry-pruner Selector{ignore tags [latest], match tags [^v\\d+\\.\\d+]} Action{keep latest 4 versions}"}
{"level":"info","ts":1557265749.719208,"caller":"cmd/main.go:71","msg":"Building image report for images: tumblr/fleeble, trash-island/docker-registry-pruner"}
{"level":"info","ts":1557265749.719243,"caller":"cmd/main.go:123","msg":"Querying for manifests. This may take a while..."}
action image tag parsed_version age_days
keep tumblr/bb8 v0.6.0-560-gb975605 0.6.0-560-gb975605 39
keep tumblr/bb8 v0.6.0-561-g63760b8 0.6.0-561-g63760b8 39
keep tumblr/bb8 v0.6.0-564-gbbda8c3 0.6.0-564-gbbda8c3 33
keep tumblr/bb8 v0.6.0-566-g82b147c 0.6.0-566-g82b147c 32
keep tumblr/fleeble v0.6.0-560-gb975605 0.6.0-560-gb975605 39
keep tumblr/fleeble v0.6.0-561-g63760b8 0.6.0-561-g63760b8 39
keep tumblr/fleeble v0.6.0-564-gbbda8c3 0.6.0-564-gbbda8c3 33
keep tumblr/fleeble v0.6.0-566-g82b147c 0.6.0-566-g82b147c 32
keep trash-island/docker-registry-pruner v0.1.0-16-g710a0e3-master 0.1.0-16-g710a0e3-master 1
keep trash-island/docker-registry-pruner v0.1.0-17-ge5bf735-master 0.1.0-17-ge5bf735-master 1
keep trash-island/docker-registry-pruner v0.1.0-19-gdddaf1e-master 0.1.0-19-gdddaf1e-master 0
keep trash-island/docker-registry-pruner v0.1.0-20-gf53cfa7-master 0.1.0-20-gf53cfa7-master 0
delete tumblr/bb8 v0.6.0-497-g5820922 0.6.0-497-g5820922 123
delete tumblr/bb8 v0.6.0-503-g8e24b6a 0.6.0-503-g8e24b6a 123
delete tumblr/bb8 v0.6.0-511-g7127911 0.6.0-511-g7127911 123
delete tumblr/bb8 v0.6.0-514-g39b0708 0.6.0-514-g39b0708 120
delete tumblr/bb8 v0.6.0-516-gafffdf5 0.6.0-516-gafffdf5 119
delete tumblr/bb8 v0.6.0-518-ga02e868 0.6.0-518-ga02e868 102
delete tumblr/bb8 v0.6.0-521-g49e37cd 0.6.0-521-g49e37cd 98
delete tumblr/bb8 v0.6.0-529-g7029e4c 0.6.0-529-g7029e4c 68
delete tumblr/bb8 v0.6.0-531-g662a23d 0.6.0-531-g662a23d 47
delete tumblr/bb8 v0.6.0-535-ge62b08a 0.6.0-535-ge62b08a 47
delete tumblr/bb8 v0.6.0-547-ge2c98ab 0.6.0-547-ge2c98ab 40
delete tumblr/fleeble v0.6.0-497-g5820922 0.6.0-497-g5820922 123
delete tumblr/fleeble v0.6.0-503-g8e24b6a 0.6.0-503-g8e24b6a 123
delete tumblr/fleeble v0.6.0-511-g7127911 0.6.0-511-g7127911 123
delete tumblr/fleeble v0.6.0-514-g39b0708 0.6.0-514-g39b0708 120
delete tumblr/fleeble v0.6.0-516-gafffdf5 0.6.0-516-gafffdf5 119
delete tumblr/fleeble v0.6.0-518-ga02e868 0.6.0-518-ga02e868 102
delete tumblr/fleeble v0.6.0-521-g49e37cd 0.6.0-521-g49e37cd 98
delete tumblr/fleeble v0.6.0-529-g7029e4c 0.6.0-529-g7029e4c 68
delete tumblr/fleeble v0.6.0-531-g662a23d 0.6.0-531-g662a23d 47
delete tumblr/fleeble v0.6.0-535-ge62b08a 0.6.0-535-ge62b08a 47
delete tumblr/fleeble v0.6.0-547-ge2c98ab 0.6.0-547-ge2c98ab 40
delete trash-island/docker-registry-pruner v0.1.0-11-g0f017e0-master 0.1.0-11-g0f017e0-master 1
delete trash-island/docker-registry-pruner v0.1.0-14-g0a78f97-master 0.1.0-14-g0a78f97-master 1
delete trash-island/docker-registry-pruner v0.1.0-15-gad48256-master 0.1.0-15-gad48256-master 1
Expand All @@ -44,32 +44,32 @@ NOTE: make sure you are using the right config!!!!! This action will mutate your
# lets delete some shit
$ ./bin/docker-registry-pruner -mode prune -config ./config/gabe.yaml
{"level":"info","ts":1557265970.763993,"caller":"cmd/main.go:51","msg":"Created Registry client for https://registry.company.net"}
{"level":"info","ts":1557265970.764477,"caller":"cmd/main.go:66","msg":"Loaded rule: Repos:tumblr/bb8,trash-island/docker-registry-pruner Selector{ignore tags [latest], match tags [^v\\d+\\.\\d+]} Action{keep latest 4 versions}"}
{"level":"info","ts":1557265970.76457,"caller":"cmd/main.go:74","msg":"Pruning tags for images: tumblr/bb8, trash-island/docker-registry-pruner"}
{"level":"info","ts":1557265970.764477,"caller":"cmd/main.go:66","msg":"Loaded rule: Repos:tumblr/fleeble,trash-island/docker-registry-pruner Selector{ignore tags [latest], match tags [^v\\d+\\.\\d+]} Action{keep latest 4 versions}"}
{"level":"info","ts":1557265970.76457,"caller":"cmd/main.go:74","msg":"Pruning tags for images: tumblr/fleeble, trash-island/docker-registry-pruner"}
{"level":"info","ts":1557265970.7648351,"caller":"cmd/main.go:131","msg":"Querying for manifests. This may take a while..."}
{"level":"info","ts":1557265973.501079,"caller":"cmd/main.go:133","msg":"Beginning deletion of 14 images"}
{"level":"info","ts":1557265973.501157,"caller":"registry/client.go:98","msg":"9: deleting manifest for tumblr/bb8:v0.6.0-497-g5820922"}
{"level":"info","ts":1557265973.501204,"caller":"registry/client.go:98","msg":"3: deleting manifest for tumblr/bb8:v0.6.0-503-g8e24b6a"}
{"level":"info","ts":1557265973.501285,"caller":"registry/client.go:98","msg":"2: deleting manifest for tumblr/bb8:v0.6.0-516-gafffdf5"}
{"level":"info","ts":1557265973.501207,"caller":"registry/client.go:98","msg":"0: deleting manifest for tumblr/bb8:v0.6.0-511-g7127911"}
{"level":"info","ts":1557265973.5012422,"caller":"registry/client.go:98","msg":"8: deleting manifest for tumblr/bb8:v0.6.0-535-ge62b08a"}
{"level":"info","ts":1557265973.501249,"caller":"registry/client.go:98","msg":"6: deleting manifest for tumblr/bb8:v0.6.0-518-ga02e868"}
{"level":"info","ts":1557265973.5012622,"caller":"registry/client.go:98","msg":"4: deleting manifest for tumblr/bb8:v0.6.0-521-g49e37cd"}
{"level":"info","ts":1557265973.501269,"caller":"registry/client.go:98","msg":"1: deleting manifest for tumblr/bb8:v0.6.0-514-g39b0708"}
{"level":"info","ts":1557265973.5012732,"caller":"registry/client.go:98","msg":"5: deleting manifest for tumblr/bb8:v0.6.0-529-g7029e4c"}
{"level":"info","ts":1557265973.5012858,"caller":"registry/client.go:98","msg":"7: deleting manifest for tumblr/bb8:v0.6.0-531-g662a23d"}
{"level":"info","ts":1557265973.690368,"caller":"registry/client.go:104","msg":"8: manifest tumblr/bb8:v0.6.0-535-ge62b08a successfully deleted"}
{"level":"info","ts":1557265973.69044,"caller":"registry/client.go:98","msg":"8: deleting manifest for tumblr/bb8:v0.6.0-547-ge2c98ab"}
{"level":"info","ts":1557265973.501157,"caller":"registry/client.go:98","msg":"9: deleting manifest for tumblr/fleeble:v0.6.0-497-g5820922"}
{"level":"info","ts":1557265973.501204,"caller":"registry/client.go:98","msg":"3: deleting manifest for tumblr/fleeble:v0.6.0-503-g8e24b6a"}
{"level":"info","ts":1557265973.501285,"caller":"registry/client.go:98","msg":"2: deleting manifest for tumblr/fleeble:v0.6.0-516-gafffdf5"}
{"level":"info","ts":1557265973.501207,"caller":"registry/client.go:98","msg":"0: deleting manifest for tumblr/fleeble:v0.6.0-511-g7127911"}
{"level":"info","ts":1557265973.5012422,"caller":"registry/client.go:98","msg":"8: deleting manifest for tumblr/fleeble:v0.6.0-535-ge62b08a"}
{"level":"info","ts":1557265973.501249,"caller":"registry/client.go:98","msg":"6: deleting manifest for tumblr/fleeble:v0.6.0-518-ga02e868"}
{"level":"info","ts":1557265973.5012622,"caller":"registry/client.go:98","msg":"4: deleting manifest for tumblr/fleeble:v0.6.0-521-g49e37cd"}
{"level":"info","ts":1557265973.501269,"caller":"registry/client.go:98","msg":"1: deleting manifest for tumblr/fleeble:v0.6.0-514-g39b0708"}
{"level":"info","ts":1557265973.5012732,"caller":"registry/client.go:98","msg":"5: deleting manifest for tumblr/fleeble:v0.6.0-529-g7029e4c"}
{"level":"info","ts":1557265973.5012858,"caller":"registry/client.go:98","msg":"7: deleting manifest for tumblr/fleeble:v0.6.0-531-g662a23d"}
{"level":"info","ts":1557265973.690368,"caller":"registry/client.go:104","msg":"8: manifest tumblr/fleeble:v0.6.0-535-ge62b08a successfully deleted"}
{"level":"info","ts":1557265973.69044,"caller":"registry/client.go:98","msg":"8: deleting manifest for tumblr/fleeble:v0.6.0-547-ge2c98ab"}
{"level":"info","ts":1557265973.6948102,"caller":"registry/client.go:98","msg":"5: deleting manifest for trash-island/docker-registry-pruner:v0.1.0-11-g0f017e0-master"}
{"level":"info","ts":1557265973.69545,"caller":"registry/client.go:98","msg":"7: deleting manifest for trash-island/docker-registry-pruner:v0.1.0-14-g0a78f97-master"}
{"level":"info","ts":1557265973.696696,"caller":"registry/client.go:98","msg":"2: deleting manifest for trash-island/docker-registry-pruner:v0.1.0-15-gad48256-master"}
{"level":"info","ts":1557265973.706157,"caller":"registry/client.go:104","msg":"6: manifest tumblr/bb8:v0.6.0-518-ga02e868 successfully deleted"}
{"level":"info","ts":1557265973.722357,"caller":"registry/client.go:104","msg":"0: manifest tumblr/bb8:v0.6.0-511-g7127911 successfully deleted"}
{"level":"info","ts":1557265973.7224078,"caller":"registry/client.go:104","msg":"4: manifest tumblr/bb8:v0.6.0-521-g49e37cd successfully deleted"}
{"level":"info","ts":1557265973.722363,"caller":"registry/client.go:104","msg":"3: manifest tumblr/bb8:v0.6.0-503-g8e24b6a successfully deleted"}
{"level":"info","ts":1557265973.803635,"caller":"registry/client.go:104","msg":"9: manifest tumblr/bb8:v0.6.0-497-g5820922 successfully deleted"}
{"level":"info","ts":1557265973.803627,"caller":"registry/client.go:104","msg":"1: manifest tumblr/bb8:v0.6.0-514-g39b0708 successfully deleted"}
{"level":"info","ts":1557265973.888031,"caller":"registry/client.go:104","msg":"8: manifest tumblr/bb8:v0.6.0-547-ge2c98ab successfully deleted"}
{"level":"info","ts":1557265973.706157,"caller":"registry/client.go:104","msg":"6: manifest tumblr/fleeble:v0.6.0-518-ga02e868 successfully deleted"}
{"level":"info","ts":1557265973.722357,"caller":"registry/client.go:104","msg":"0: manifest tumblr/fleeble:v0.6.0-511-g7127911 successfully deleted"}
{"level":"info","ts":1557265973.7224078,"caller":"registry/client.go:104","msg":"4: manifest tumblr/fleeble:v0.6.0-521-g49e37cd successfully deleted"}
{"level":"info","ts":1557265973.722363,"caller":"registry/client.go:104","msg":"3: manifest tumblr/fleeble:v0.6.0-503-g8e24b6a successfully deleted"}
{"level":"info","ts":1557265973.803635,"caller":"registry/client.go:104","msg":"9: manifest tumblr/fleeble:v0.6.0-497-g5820922 successfully deleted"}
{"level":"info","ts":1557265973.803627,"caller":"registry/client.go:104","msg":"1: manifest tumblr/fleeble:v0.6.0-514-g39b0708 successfully deleted"}
{"level":"info","ts":1557265973.888031,"caller":"registry/client.go:104","msg":"8: manifest tumblr/fleeble:v0.6.0-547-ge2c98ab successfully deleted"}
{"level":"info","ts":1557265974.265267,"caller":"registry/client.go:104","msg":"2: manifest trash-island/docker-registry-pruner:v0.1.0-15-gad48256-master successfully deleted"}
{"level":"info","ts":1557265974.4662452,"caller":"cmd/main.go:135","msg":"Deleted 9 images, encountered 5 errors"}
....
Expand All @@ -79,14 +79,14 @@ $ ./bin/docker-registry-pruner -mode prune -config ./config/gabe.yaml
[17:52:54] [gabec@Gabes-MacBook-Pro] ( 2 ) ~/code/tumblr/docker-registry-pruner master*
-> $ ./bin/docker-registry-pruner -mode report -config ./config/gabe.yaml
{"level":"info","ts":1557265982.717484,"caller":"cmd/main.go:51","msg":"Created Registry client for https://registry.company.net"}
{"level":"info","ts":1557265982.717578,"caller":"cmd/main.go:66","msg":"Loaded rule: Repos:tumblr/bb8,trash-island/docker-registry-pruner Selector{ignore tags [latest], match tags [^v\\d+\\.\\d+]} Action{keep latest 4 versions}"}
{"level":"info","ts":1557265982.717599,"caller":"cmd/main.go:71","msg":"Building image report for images: tumblr/bb8, trash-island/docker-registry-pruner"}
{"level":"info","ts":1557265982.717578,"caller":"cmd/main.go:66","msg":"Loaded rule: Repos:tumblr/fleeble,trash-island/docker-registry-pruner Selector{ignore tags [latest], match tags [^v\\d+\\.\\d+]} Action{keep latest 4 versions}"}
{"level":"info","ts":1557265982.717599,"caller":"cmd/main.go:71","msg":"Building image report for images: tumblr/fleeble, trash-island/docker-registry-pruner"}
{"level":"info","ts":1557265982.7176151,"caller":"cmd/main.go:123","msg":"Querying for manifests. This may take a while..."}
action image tag parsed_version age_days
keep tumblr/bb8 v0.6.0-560-gb975605 0.6.0-560-gb975605 39
keep tumblr/bb8 v0.6.0-561-g63760b8 0.6.0-561-g63760b8 39
keep tumblr/bb8 v0.6.0-564-gbbda8c3 0.6.0-564-gbbda8c3 33
keep tumblr/bb8 v0.6.0-566-g82b147c 0.6.0-566-g82b147c 32
keep tumblr/fleeble v0.6.0-560-gb975605 0.6.0-560-gb975605 39
keep tumblr/fleeble v0.6.0-561-g63760b8 0.6.0-561-g63760b8 39
keep tumblr/fleeble v0.6.0-564-gbbda8c3 0.6.0-564-gbbda8c3 33
keep tumblr/fleeble v0.6.0-566-g82b147c 0.6.0-566-g82b147c 32
keep trash-island/docker-registry-pruner v0.1.0-16-g710a0e3-master 0.1.0-16-g710a0e3-master 1
keep trash-island/docker-registry-pruner v0.1.0-17-ge5bf735-master 0.1.0-17-ge5bf735-master 1
keep trash-island/docker-registry-pruner v0.1.0-19-gdddaf1e-master 0.1.0-19-gdddaf1e-master 1
Expand Down
Loading

0 comments on commit 39e6999

Please sign in to comment.