https://github.com/frobware/imagequalifier
A library that qualifies unqualified Docker images.
https://github.com/frobware/imagequalifier
Last synced: about 1 year ago
JSON representation
A library that qualifies unqualified Docker images.
- Host: GitHub
- URL: https://github.com/frobware/imagequalifier
- Owner: frobware
- Created: 2017-12-15T18:49:12.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-19T12:33:56.000Z (over 8 years ago)
- Last Synced: 2025-02-24T07:38:27.660Z (about 1 year ago)
- Language: Go
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://travis-ci.org/frobware/imagequalifier)
[](https://godoc.org/github.com/frobware/imagequalifier)
[](http://codecov.io/github/frobware/imagequalifier?branch=master)
[](https://goreportcard.com/report/github.com/frobware/imagequalifier)
This library and CLI tool is an experiment that, given a set of rules,
will qualify bare images names to include a domain (e.g.,
`registry.io`) component.
An unqualified image is something like `library/emacs` or `emacs`, or
`emacs:v26`. A qualified image has a domain component (e.g.,
`prep.ai.mit.edu/library/emacs`).
## Pattern Matching Rules
- Rules are new-line separated
- There are two fields per line, separated by one or more whitespace characters
- First field is the pattern
- Second field is the domain
- Blank/Empty lines are skipped
- Comment lines are skipped and begin with #.
### Rule Ordering (aka Partial Ordering)
(TBD) Should rules be automagically ordered when parsed?
- Currently no reordering of the rules is attempted
- Rules are attempted in the order presented
- _the first match wins_
## Pattern Syntax
Note: semantics stolen from `path.Match()`.
pattern:
{ term }
term:
'*' matches any sequence of non-/ characters
'?' matches any single non-/ character
'[' [ '^' ] { character-range } ']'
character class (must be non-empty)
c matches character c (c != '*', '?', '\\', '[')
'\\' c matches character c
character-range:
c matches character c (c != '\\', '-', ']')
'\\' c matches character c
lo '-' hi matches character c for lo <= c <= hi
Matching requires pattern to match all of name, not just a substring.
## Examples
The simplest pattern to pull images that do not contain a repository
component from `internal.io` is:
* internal.io
This pattern will transform any bare image to `internal.io/`.
Note: it will not transform `myrepo/nginx` to
`internal.io/myrepo/nginx` because the pattern needs to match all
segments of the [pattern] path.
To match any image and force it to pull from `internal.io` the
following rules are required:
*/* internal.io
* internal.io
Making all latest tags come from a dev registry:
*/*:latest dev.io
*/* internal.io
* internal.io
Forcing nginx v1.2.3 to come from docker.io.
*/nginx:v1.2.3 docker.io
you/* you.io
me/* me.io
*/* internal.io
* internal.io
### Sample Rules
$ cat $GOPATH/src/github.com/frobware/imagequalifier/testdata/sample-rules
busybox busybox.com
*/emacs emacs.com
myrepo/* myrepo.com
nginx:v[1-9].[0-9]* nginx.com
*/* internal.com
* external.com
### Sample Matches
| Image | Qualified Image |
|----------------|--------------------------|
| `emacs` | `external.com/emacs` |
| `busybox` | `busybox.com/busybox` |
| `myrepo/emacs` | `emacs.com/myrepo/emacs` |
| `nginx` | `external.com/nginx` |
| `nginx:v1.0` | `nginx.com/nginx` |
### Test by example
$ go install github.com/frobware/imagequalifier/...
$ imagequalifier $GOPATH/src/github.com/frobware/imagequalifier/testdata/sample-rules emacs
internal.io/emacs
$ imagequalifier $GOPATH/src/github.com/frobware/imagequalifier/testdata/sample-rules library/emacs
emacs.com/library/emacs