Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default to auth hard fail but optionally soft fail #2786

Merged
merged 2 commits into from
Jul 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion client/driver/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ type DockerDriverConfig struct {
LabelsRaw []map[string]string `mapstructure:"labels"` //
Labels map[string]string `mapstructure:"-"` // Labels to set when the container starts up
Auth []DockerDriverAuth `mapstructure:"auth"` // Authentication credentials for a private Docker registry
AuthSoftFail bool `mapstructure:"auth_soft_fail"` // Soft-fail if auth creds are provided but fail
TTY bool `mapstructure:"tty"` // Allocate a Pseudo-TTY
Interactive bool `mapstructure:"interactive"` // Keep STDIN open even if not attached
ShmSize int64 `mapstructure:"shm_size"` // Size of /dev/shm of the container in bytes
Expand Down Expand Up @@ -400,6 +401,9 @@ func (d *DockerDriver) Validate(config map[string]interface{}) error {
"auth": &fields.FieldSchema{
Type: fields.TypeArray,
},
"auth_soft_fail": &fields.FieldSchema{
Type: fields.TypeBool,
},
// COMPAT: Remove in 0.6.0. SSL is no longer needed
"ssl": &fields.FieldSchema{
Type: fields.TypeBool,
Expand Down Expand Up @@ -1082,7 +1086,11 @@ func (d *DockerDriver) createImage(driverConfig *DockerDriverConfig, client *doc
func (d *DockerDriver) pullImage(driverConfig *DockerDriverConfig, client *docker.Client, repo, tag string) (id string, err error) {
authOptions, err := d.resolveRegistryAuthentication(driverConfig, repo)
if err != nil {
d.logger.Printf("[WARN] Failed to find docker auth for repo %q: %v", repo, err)
if d.driverConfig.AuthSoftFail {
d.logger.Printf("[WARN] Failed to find docker auth for repo %q: %v", repo, err)
} else {
return "", fmt.Errorf("Failed to find docker auth for repo %q: %v", repo, err)
}
}

if authIsEmpty(authOptions) {
Expand Down
3 changes: 3 additions & 0 deletions website/source/docs/drivers/docker.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ The `docker` driver supports the following configuration in the job spec. Only

* `auth` - (Optional) Provide authentication for a private registry (see below).

* `auth_soft_fail` `(bool: false)` - Don't fail the task on an auth failure.
Attempt to continue without auth.

* `command` - (Optional) The command to run when starting the container.

```hcl
Expand Down