diff --git a/.gitignore b/.gitignore index 8c72f3ee..bc32e67a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -!cmd/skopeo/ /skopeo /skopeo.1 /layers-* diff --git a/Makefile b/Makefile index 6785c4c0..bcc739a7 100644 --- a/Makefile +++ b/Makefile @@ -22,12 +22,11 @@ endif DOCKER_RUN_DOCKER := $(DOCKER_FLAGS) "$(DOCKER_IMAGE)" GIT_COMMIT := $(shell git rev-parse HEAD 2> /dev/null || true) -LDFLAGS := "-X github.com/projectatomic/skopeo.GitCommit=${GIT_COMMIT} ${LDFLAGS}" all: man binary binary: - go build -ldflags ${LDFLAGS} -o ${DEST}skopeo ./cmd/skopeo + go build -ldflags "-X main.gitCommit=${GIT_COMMIT}" -o ${DEST}skopeo . build-container: docker build ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)" . diff --git a/docker.go b/docker.go index f7ee2fd4..f1e1ef70 100644 --- a/docker.go +++ b/docker.go @@ -1,4 +1,4 @@ -package skopeo +package main import ( "crypto/tls" diff --git a/cmd/skopeo/inspect.go b/inspect.go similarity index 91% rename from cmd/skopeo/inspect.go rename to inspect.go index fd2ecb09..0faec960 100644 --- a/cmd/skopeo/inspect.go +++ b/inspect.go @@ -6,7 +6,6 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" - "github.com/projectatomic/skopeo" ) var inspectCmd = cli.Command{ @@ -19,7 +18,7 @@ var inspectCmd = cli.Command{ }, }, Action: func(c *cli.Context) { - img, err := skopeo.ParseImage(c) + img, err := parseImage(c) if err != nil { logrus.Fatal(err) } diff --git a/cmd/skopeo/layers.go b/layers.go similarity index 83% rename from cmd/skopeo/layers.go rename to layers.go index dda13dac..27285520 100644 --- a/cmd/skopeo/layers.go +++ b/layers.go @@ -3,7 +3,6 @@ package main import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" - "github.com/projectatomic/skopeo" ) // TODO(runcom): document args and usage @@ -11,7 +10,7 @@ var layersCmd = cli.Command{ Name: "layers", Usage: "get images layers", Action: func(c *cli.Context) { - img, err := skopeo.ParseImage(c) + img, err := parseImage(c) if err != nil { logrus.Fatal(err) } diff --git a/cmd/skopeo/main.go b/main.go similarity index 74% rename from cmd/skopeo/main.go rename to main.go index 6c05e218..3f09c1fb 100644 --- a/cmd/skopeo/main.go +++ b/main.go @@ -6,18 +6,26 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" - "github.com/projectatomic/skopeo" + "github.com/projectatomic/skopeo/version" +) + +// gitCommit will be the hash that the binary was built from +// and will be populated by the Makefile +var gitCommit = "" + +const ( + usage = `interact with registries` ) func main() { app := cli.NewApp() app.Name = "skopeo" - if skopeo.GitCommit != "" { - app.Version = fmt.Sprintf("%s commit: %s", skopeo.Version, skopeo.GitCommit) + if gitCommit != "" { + app.Version = fmt.Sprintf("%s commit: %s", version.Version, gitCommit) } else { - app.Version = skopeo.Version + app.Version = version.Version } - app.Usage = "interact with registries" + app.Usage = usage // TODO(runcom) //app.EnableBashCompletion = true app.Flags = []cli.Flag{ diff --git a/signature/signature.go b/signature/signature.go index 870b97b0..d834d019 100644 --- a/signature/signature.go +++ b/signature/signature.go @@ -8,12 +8,12 @@ import ( "fmt" "time" - "github.com/projectatomic/skopeo" + "github.com/projectatomic/skopeo/version" ) const ( signatureType = "atomic container signature" - signatureCreatorID = "atomic " + skopeo.Version + signatureCreatorID = "atomic " + version.Version ) // InvalidSignatureError is returned when parsing an invalid signature. diff --git a/cmd/skopeo/signing.go b/signing.go similarity index 100% rename from cmd/skopeo/signing.go rename to signing.go diff --git a/utils.go b/utils.go index fc4f9e81..5c69f30c 100644 --- a/utils.go +++ b/utils.go @@ -1,4 +1,4 @@ -package skopeo +package main import ( "fmt" @@ -9,7 +9,7 @@ import ( ) // ParseImage converts image URL-like string to an initialized handler for that image. -func ParseImage(c *cli.Context) (types.Image, error) { +func parseImage(c *cli.Context) (types.Image, error) { var ( imgName = c.Args().First() certPath = c.GlobalString("cert-path") diff --git a/version.go b/version.go deleted file mode 100644 index 0ddd894b..00000000 --- a/version.go +++ /dev/null @@ -1,7 +0,0 @@ -package skopeo - -// Version is a version of thils build. -const Version = "0.1.12-dev" - -// GitCommit is a git commit hash of this build. It is ordinarily overriden by LDFLAGS in Makefile. -var GitCommit = "" diff --git a/version/version.go b/version/version.go new file mode 100644 index 00000000..26fc8858 --- /dev/null +++ b/version/version.go @@ -0,0 +1,4 @@ +package version + +// Version is the version of the build. +const Version = "0.1.12-dev"