-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix AWS ECR private repository usage #858
Changes from 3 commits
e2bb234
2ae1f44
bfbd4d6
4aa575b
d5142c2
5859c95
d1f2843
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,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 | ||
SSL bool `mapstructure:"ssl"` | ||
} | ||
|
||
func (c *DockerDriverConfig) Validate() error { | ||
|
@@ -408,6 +409,14 @@ func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle | |
if err := mapstructure.WeakDecode(task.Config, &driverConfig); err != nil { | ||
return nil, err | ||
} | ||
|
||
if strings.Contains(driverConfig.ImageName, "https://") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we move this logic out of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This transformation has to occur before the image is pulled and inspected (around line 496) and therefore before the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ErikEvenson Oh I see. Can we create another method called |
||
driverConfig.SSL = true | ||
driverConfig.ImageName = strings.Replace(driverConfig.ImageName, "https://", "", 1) | ||
} else { | ||
driverConfig.SSL = false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't need to set this as false as default value for bools are There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed -- will change. |
||
} | ||
|
||
image := driverConfig.ImageName | ||
|
||
if err := driverConfig.Validate(); err != nil { | ||
|
@@ -471,7 +480,14 @@ func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle | |
if authConfigurations, err = docker.NewAuthConfigurations(f); err != nil { | ||
return nil, fmt.Errorf("Failed to create docker auth object: %v", err) | ||
} | ||
if authConfiguration, ok := authConfigurations.Configs[repo]; ok { | ||
|
||
authConfigurationKey := "" | ||
if driverConfig.SSL { | ||
authConfigurationKey += "https://" | ||
} | ||
|
||
authConfigurationKey += strings.Split(driverConfig.ImageName, "/")[0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the split command returns the image string with the url scheme and without the url path -- which is different from the repo string. |
||
if authConfiguration, ok := authConfigurations.Configs[authConfigurationKey]; ok { | ||
authOptions = authConfiguration | ||
} | ||
} else { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add this.