From bf2795397f8e5904fd83c38b4520857cc2cbe735 Mon Sep 17 00:00:00 2001 From: Sebastien Binet Date: Tue, 20 Sep 2016 17:47:11 +0200 Subject: [PATCH] cmd/marina-pull: add -addr flag --- README.md | 10 ++++++++++ cmd/marina-pull/main.go | 8 ++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7d2c26f..14fe186 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,13 @@ $> marina-pull piscineri3/go-base:latest Loaded image: piscineri3/go-base:latest 2016/09/19 16:22:13 pulling "piscineri3/go-base"... [done] (16.304998995s) ``` + +Note that by default `marina-pull` will try to pull from `piscine.in2p3.fr`. +You may change this behaviour by passing `-addr=example.com` or `-addr=192.168.0.2` as an argument: + +```sh +$> marina-pull -addr=19.168.0.2 piscineri3/go-base +2016/09/20 12:41:10 pulling "piscineri3/go-base"... +Loaded image: piscineri3/go-base:latest +2016/09/20 12:41:26 pulling "piscineri3/go-base"... [done] (16.304998995s) +``` diff --git a/cmd/marina-pull/main.go b/cmd/marina-pull/main.go index ceb0633..458088a 100644 --- a/cmd/marina-pull/main.go +++ b/cmd/marina-pull/main.go @@ -5,6 +5,7 @@ package main import ( + "flag" "io" "log" "net/http" @@ -18,7 +19,10 @@ func main() { } func run() { - name := os.Args[1] + addr := flag.String("addr", "piscine.in2p3.fr", "address of the marina") + flag.Parse() + + name := flag.Arg(0) start := time.Now() defer func() { @@ -26,7 +30,7 @@ func run() { }() log.Printf("pulling %q...\n", name) - resp, err := http.Get("http://piscine.in2p3.fr:8080/docker-images/" + name) + resp, err := http.Get("http://" + *addr + ":8080/docker-images/" + name) if err != nil { log.Fatalf("marina-get %q: %v\n", name, err) }