Signed-off-by: Jess Frazelle <me@jessfraz.com>
This commit is contained in:
Jess Frazelle 2016-09-06 14:56:46 -07:00
parent 8ad648bcd4
commit 7515aa6513
No known key found for this signature in database
GPG key ID: 18F3685C0022BFF3
2 changed files with 44 additions and 28 deletions

View file

@ -2,18 +2,20 @@
Docker registry v2 client. Docker registry v2 client.
> **NOTE:** There is a way better version of this @ [`docker-ls`](https://github.com/mayflower/docker-ls) > **NOTE:** There is a way better, _maintained_ version of this @
> [`docker-ls`](https://github.com/mayflower/docker-ls)
**Auth** **Auth**
`reg` will automatically try to parse your docker config credentials, but if `reg` will automatically try to parse your docker config credentials, but if
not saved there you can pass through flags directly. not present, you can pass through flags directly.
**List Repositories and Tags** **List Repositories and Tags**
```console ```console
$ ./reg # this command might take a while if you have hundreds of images like I do
Repositories for registry.jess.co $ reg -r r.j3ss.co ls
Repositories for r.j3ss.co
REPO TAGS REPO TAGS
ab latest ab latest
android-tools latest android-tools latest
@ -34,33 +36,35 @@ chrome beta, latest, stable
**Usage** **Usage**
```console ```console
$ reg --help $ reg
_ __ ___ __ _ NAME:
| '__/ _ \/ _` | reg - Docker registry v2 client.
| | | __/ (_| |
|_| \___|\__, |
|___/
Docker registry v2 client. USAGE:
Version: v0.1.0 reg [global options] command [command options] [arguments...]
-d run in debug mode VERSION:
-p string v0.2.0
Password for the registry
-r string AUTHOR(S):
Url to the private registry (ex. https://registry.jess.co) @jfrazelle <no-reply@butts.com>
-u string
Username for the registry COMMANDS:
-v print version and exit (shorthand) list, ls list all repositories
-version tags get the tags for a repository
print version and exit manifest get the json manifest for the specific reference of a repository
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--debug, -d run in debug mode
--username value, -u value username for the registry
--password value, -p value password for the registry
--registry value, -r value URL to the provate registry (ex. r.j3ss.co)
--help, -h show help
--version, -v print the version
``` ```
**Known Issues** **Known Issues**
`reg` does not work with `reg` does not work to:
* unauthenticated registries
* http basic auth
* output image history * output image history
For more advanced registry usage please use [`docker-ls`](https://github.com/mayflower/docker-ls)

14
main.go
View file

@ -136,7 +136,14 @@ func main() {
return fmt.Errorf("pass the name of the repository") return fmt.Errorf("pass the name of the repository")
} }
parts := strings.Split(c.Args()[0], ":") arg := c.Args()[0]
parts := []string{}
if strings.Contains(arg, "@") {
parts = strings.Split(c.Args()[0], "@")
} else if strings.Contains(arg, ":") {
parts = strings.Split(c.Args()[0], ":")
}
repo := parts[0] repo := parts[0]
ref := "latest" ref := "latest"
if len(parts) > 1 { if len(parts) > 1 {
@ -180,6 +187,11 @@ func getAuthConfig(c *cli.Context) (types.AuthConfig, error) {
// return error early if there are no auths saved // return error early if there are no auths saved
if !dcfg.ContainsAuth() { if !dcfg.ContainsAuth() {
if c.GlobalString("registry") != "" {
return types.AuthConfig{
ServerAddress: c.GlobalString("registry"),
}, nil
}
return types.AuthConfig{}, fmt.Errorf("No auth was present in %s, please pass a registry, username, and password", cliconfig.ConfigDir()) return types.AuthConfig{}, fmt.Errorf("No auth was present in %s, please pass a registry, username, and password", cliconfig.ConfigDir())
} }