github.com/skippbox/kompose-origin@v0.0.0-20160524133224-16a9dca7bac2/cli/docker/app/commands.go (about) 1 package app 2 3 import ( 4 "github.com/Sirupsen/logrus" 5 "github.com/codegangsta/cli" 6 "github.com/docker/libcompose/docker" 7 "github.com/docker/libcompose/docker/client" 8 "github.com/docker/libcompose/project" 9 ) 10 11 // DockerClientFlags defines the flags that are specific to the docker client, 12 // like configdir or tls related flags. 13 func DockerClientFlags() []cli.Flag { 14 return []cli.Flag{ 15 cli.BoolFlag{ 16 Name: "tls", 17 Usage: "Use TLS; implied by --tlsverify", 18 }, 19 cli.BoolFlag{ 20 Name: "tlsverify", 21 Usage: "Use TLS and verify the remote", 22 EnvVar: "DOCKER_TLS_VERIFY", 23 }, 24 cli.StringFlag{ 25 Name: "tlscacert", 26 Usage: "Trust certs signed only by this CA", 27 }, 28 cli.StringFlag{ 29 Name: "tlscert", 30 Usage: "Path to TLS certificate file", 31 }, 32 cli.StringFlag{ 33 Name: "tlskey", 34 Usage: "Path to TLS key file", 35 }, 36 cli.StringFlag{ 37 Name: "configdir", 38 Usage: "Path to docker config dir, default ${HOME}/.docker", 39 }, 40 } 41 } 42 43 // Populate updates the specified docker context based on command line arguments and subcommands. 44 func Populate(context *docker.Context, c *cli.Context) { 45 context.ConfigDir = c.String("configdir") 46 47 opts := client.Options{} 48 opts.TLS = c.GlobalBool("tls") 49 opts.TLSVerify = c.GlobalBool("tlsverify") 50 opts.TLSOptions.CAFile = c.GlobalString("tlscacert") 51 opts.TLSOptions.CertFile = c.GlobalString("tlscert") 52 opts.TLSOptions.KeyFile = c.GlobalString("tlskey") 53 54 clientFactory, err := project.NewDefaultClientFactory(opts) 55 if err != nil { 56 logrus.Fatalf("Failed to construct Docker client: %v", err) 57 } 58 59 context.ClientFactory = clientFactory 60 }