github.com/vieux/docker@v0.6.3-0.20161004191708-e097c2a938c7/cli/command/trust.go (about) 1 package command 2 3 import ( 4 "os" 5 "strconv" 6 7 "github.com/spf13/pflag" 8 ) 9 10 var ( 11 // TODO: make this not global 12 untrusted bool 13 ) 14 15 // AddTrustedFlags adds content trust flags to the current command flagset 16 func AddTrustedFlags(fs *pflag.FlagSet, verify bool) { 17 trusted, message := setupTrustedFlag(verify) 18 fs.BoolVar(&untrusted, "disable-content-trust", !trusted, message) 19 } 20 21 func setupTrustedFlag(verify bool) (bool, string) { 22 var trusted bool 23 if e := os.Getenv("DOCKER_CONTENT_TRUST"); e != "" { 24 if t, err := strconv.ParseBool(e); t || err != nil { 25 // treat any other value as true 26 trusted = true 27 } 28 } 29 message := "Skip image signing" 30 if verify { 31 message = "Skip image verification" 32 } 33 return trusted, message 34 } 35 36 // IsTrusted returns true if content trust is enabled 37 func IsTrusted() bool { 38 return !untrusted 39 }