From c3a150d5f7d439b9e43dd78639719f0c8e1d0069 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Fri, 3 Nov 2017 15:38:11 +0000 Subject: [PATCH] linuxkit pkg: add `--dev` to force local org and hash $USER and "dev" respectively. Signed-off-by: Ian Campbell --- src/cmd/linuxkit/pkglib/pkglib.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/cmd/linuxkit/pkglib/pkglib.go b/src/cmd/linuxkit/pkglib/pkglib.go index cecd34bf0..d49fb371a 100644 --- a/src/cmd/linuxkit/pkglib/pkglib.go +++ b/src/cmd/linuxkit/pkglib/pkglib.go @@ -5,6 +5,7 @@ import ( "fmt" "gopkg.in/yaml.v2" "io/ioutil" + "os" "path/filepath" "strings" ) @@ -68,12 +69,13 @@ func NewFromCLI(fs *flag.FlagSet, args ...string) (Pkg, error) { // Other arguments var buildYML, hash, hashCommit, hashPath string - var dirty bool + var dirty, devMode bool fs.StringVar(&buildYML, "build-yml", "build.yml", "Override the name of the yml file") fs.StringVar(&hash, "hash", "", "Override the image hash (default is to query git for the package's tree-sh)") fs.StringVar(&hashCommit, "hash-commit", "HEAD", "Override the git commit to use for the hash") fs.StringVar(&hashPath, "hash-path", "", "Override the directory to use for the image hash, must be a parent of the package dir (default is to use the package dir)") fs.BoolVar(&dirty, "force-dirty", false, "Force the pkg to be considered dirty") + fs.BoolVar(&devMode, "dev", false, "Force org and hash to $USER and \"dev\" respectively") fs.Parse(args) @@ -90,6 +92,16 @@ func NewFromCLI(fs *flag.FlagSet, args ...string) (Pkg, error) { return Pkg{}, err } + if devMode { + // If --org is also used then this will be overwritten + // by argOrg when we iterate over the provided options + // in the fs.Visit block below. + pi.Org = os.Getenv("USER") + if hash == "" { + hash = "dev" + } + } + if hashPath == "" { hashPath = pkgPath } else {