Skip to content

Commit

Permalink
prefer TrimPrefix to checking HasPrefix first
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed Jan 22, 2021
1 parent 1c5a5cd commit a26e83e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
5 changes: 1 addition & 4 deletions drivers/docker/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,7 @@ func (d *Driver) SetConfig(c *base.Config) error {
}

d.config = &config
// Remove any http
if strings.HasPrefix(d.config.InfraImage, "https://") {
d.config.InfraImage = strings.Replace(d.config.InfraImage, "https://", "", 1)
}
d.config.InfraImage = strings.TrimPrefix(d.config.InfraImage, "https://")

if len(d.config.GC.ImageDelay) > 0 {
dur, err := time.ParseDuration(d.config.GC.ImageDelay)
Expand Down
5 changes: 1 addition & 4 deletions drivers/docker/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
return nil, nil, fmt.Errorf("image name required for docker driver")
}

// Remove any http
if strings.HasPrefix(driverConfig.Image, "https://") {
driverConfig.Image = strings.Replace(driverConfig.Image, "https://", "", 1)
}
driverConfig.Image = strings.TrimPrefix(driverConfig.Image, "https://")

handle := drivers.NewTaskHandle(taskHandleVersion)
handle.Config = cfg
Expand Down

0 comments on commit a26e83e

Please sign in to comment.