Skip to content

Commit

Permalink
start of work to add DOCKER_HOST environment
Browse files Browse the repository at this point in the history
this seems to be the basic to add support for a custom docker host as
an envar or command line option. Some questions I have:
1. how/where to test
2. should the default value be set to something instead of empty string?

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Jun 16, 2022
1 parent 6499111 commit 6c80391
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
specified instance, running within a cgroup.
- Add `--sparse` flag to `overlay create` command to allow generation of a
sparse ext3 overlay image.
- Support for `DOCKER_HOST` parsing when using `docker-daemon://`

### Bug Fixes

Expand Down
1 change: 1 addition & 0 deletions cmd/internal/cli/action_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ func init() {
cmdManager.RegisterFlagForCmd(&commonNoHTTPSFlag, actionsInstanceCmd...)
cmdManager.RegisterFlagForCmd(&commonOldNoHTTPSFlag, actionsInstanceCmd...)
cmdManager.RegisterFlagForCmd(&dockerLoginFlag, actionsInstanceCmd...)
cmdManager.RegisterFlagForCmd(&dockerHostFlag, actionsInstanceCmd...)
cmdManager.RegisterFlagForCmd(&dockerPasswordFlag, actionsInstanceCmd...)
cmdManager.RegisterFlagForCmd(&dockerUsernameFlag, actionsInstanceCmd...)
cmdManager.RegisterFlagForCmd(&actionEnvFlag, actionsInstanceCmd...)
Expand Down
1 change: 1 addition & 0 deletions cmd/internal/cli/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ func init() {
cmdManager.RegisterFlagForCmd(&commonNoHTTPSFlag, buildCmd)
cmdManager.RegisterFlagForCmd(&commonTmpDirFlag, buildCmd)

cmdManager.RegisterFlagForCmd(&dockerHostFlag, buildCmd)
cmdManager.RegisterFlagForCmd(&dockerUsernameFlag, buildCmd)
cmdManager.RegisterFlagForCmd(&dockerPasswordFlag, buildCmd)
cmdManager.RegisterFlagForCmd(&dockerLoginFlag, buildCmd)
Expand Down
1 change: 1 addition & 0 deletions cmd/internal/cli/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func init() {
cmdManager.RegisterFlagForCmd(&pullDisableCacheFlag, PullCmd)
cmdManager.RegisterFlagForCmd(&pullDirFlag, PullCmd)

cmdManager.RegisterFlagForCmd(&dockerHostFlag, PullCmd)
cmdManager.RegisterFlagForCmd(&dockerUsernameFlag, PullCmd)
cmdManager.RegisterFlagForCmd(&dockerPasswordFlag, PullCmd)
cmdManager.RegisterFlagForCmd(&dockerLoginFlag, PullCmd)
Expand Down
1 change: 1 addition & 0 deletions cmd/internal/cli/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func init() {
cmdManager.RegisterFlagForCmd(&pushAllowUnsignedFlag, PushCmd)
cmdManager.RegisterFlagForCmd(&pushDescriptionFlag, PushCmd)

cmdManager.RegisterFlagForCmd(&dockerHostFlag, PushCmd)
cmdManager.RegisterFlagForCmd(&dockerUsernameFlag, PushCmd)
cmdManager.RegisterFlagForCmd(&dockerPasswordFlag, PushCmd)
})
Expand Down
11 changes: 11 additions & 0 deletions cmd/internal/cli/singularity.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var currentRemoteEndpoint *endpoint.Config
var (
dockerAuthConfig ocitypes.DockerAuthConfig
dockerLogin bool
dockerHost string

encryptionPEMPath string
promptForPassphrase bool
Expand Down Expand Up @@ -154,6 +155,16 @@ var dockerLoginFlag = cmdline.Flag{
EnvKeys: []string{"DOCKER_LOGIN"},
}

// --docker-host
var dockerHostFlag = cmdline.Flag{
ID: "dockerHostFlag",
Value: &dockerHost,
DefaultValue: "",
Name: "docker-host",
Usage: "specify a custom Docker daemon host",
EnvKeys: []string{"DOCKER_HOST"},
}

// --passphrase
var commonPromptForPassphraseFlag = cmdline.Flag{
ID: "commonPromptForPassphraseFlag",
Expand Down
2 changes: 2 additions & 0 deletions internal/pkg/build/sources/conveyorPacker_oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,13 @@ func (cp *OCIConveyorPacker) Get(ctx context.Context, b *sytypes.Bundle) (err er
cp.sysCtx = &types.SystemContext{
OCIInsecureSkipTLSVerify: cp.b.Opts.NoHTTPS,
DockerAuthConfig: cp.b.Opts.DockerAuthConfig,
DockerDaemonHost: cp.b.Opts.DockerDaemonHost,
OSChoice: "linux",
AuthFilePath: syfs.DockerConf(),
DockerRegistryUserAgent: useragent.Value(),
BigFilesTemporaryDir: b.TmpDir,
}

if cp.b.Opts.NoHTTPS {
cp.sysCtx.DockerInsecureSkipTLSVerify = types.NewOptionalBool(true)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/build/types/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type Options struct {
KeyServerOpts []scskeyclient.Option
// contains docker credentials if specified.
DockerAuthConfig *ocitypes.DockerAuthConfig
// Custom docker Daemon host
DockerDaemonHost string
// EncryptionKeyInfo specifies the key used for filesystem
// encryption if applicable.
// A nil value indicates encryption should not occur.
Expand Down

0 comments on commit 6c80391

Please sign in to comment.