Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Make lint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
romank87 committed Feb 10, 2016
1 parent ff5910e commit 871bc85
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (b *Build) getExportsContainer() (c *docker.Container, err error) {
//
// See also TestBuild_LookupImage_* test cases in build_test.go
func (b *Build) lookupImage(name string) (img *docker.Image, err error) {
if is_old, warning := imagename.WarnIfOldS3ImageName(name); is_old {
if isOld, warning := imagename.WarnIfOldS3ImageName(name); isOld {
log.Warn(warning)
}
var (
Expand Down
8 changes: 4 additions & 4 deletions src/build/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (c *DockerClient) PullImage(name string) error {

// e.g. s3:bucket-name/image-name
if image.Storage == imagename.StorageS3 {
if is_old, warning := imagename.WarnIfOldS3ImageName(name); is_old {
if isOld, warning := imagename.WarnIfOldS3ImageName(name); isOld {
c.log.Warn(warning)
}

Expand Down Expand Up @@ -187,7 +187,7 @@ func (c *DockerClient) ListImages() (images []*imagename.ImageName, err error) {
func (c *DockerClient) ListImageTags(name string) (images []*imagename.ImageName, err error) {
img := imagename.NewFromString(name)
if img.Storage == imagename.StorageS3 {
if is_old, warning := imagename.WarnIfOldS3ImageName(name); is_old {
if isOld, warning := imagename.WarnIfOldS3ImageName(name); isOld {
c.log.Warn(warning)
}
return c.s3storage.ListTags(name)
Expand Down Expand Up @@ -439,7 +439,7 @@ func (c *DockerClient) UploadToContainer(containerID string, stream io.Reader, p
// TagImage adds tag to the image
func (c *DockerClient) TagImage(imageID, imageName string) error {
img := imagename.NewFromString(imageName)
if is_old, warning := imagename.WarnIfOldS3ImageName(imageName); is_old {
if isOld, warning := imagename.WarnIfOldS3ImageName(imageName); isOld {
c.log.Warn(warning)
}

Expand Down Expand Up @@ -485,7 +485,7 @@ func (c *DockerClient) pushImageInner(imageName string) (digest string, err erro

// Use direct S3 image pusher instead
if img.Storage == imagename.StorageS3 {
if is_old, warning := imagename.WarnIfOldS3ImageName(imageName); is_old {
if isOld, warning := imagename.WarnIfOldS3ImageName(imageName); isOld {
c.log.Warn(warning)
}
return c.s3storage.Push(imageName)
Expand Down
2 changes: 1 addition & 1 deletion src/build/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ func (c *CommandPush) Execute(b *Build) (State, error) {
filePath := filepath.Join(b.cfg.ArtifactsPath, artifact.GetFileName())

artifacts := imagename.Artifacts{
[]imagename.Artifact{artifact},
RockerArtifacts: []imagename.Artifact{artifact},
}
content, err := yaml.Marshal(artifacts)
if err != nil {
Expand Down
22 changes: 11 additions & 11 deletions src/imagename/imagename.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const (
)

const (
s3_prefix = "s3.amazonaws.com/"
s3_old_prefix = "s3:"
s3Prefix = "s3.amazonaws.com/"
s3OldPrefix = "s3:"
)

var (
Expand All @@ -71,12 +71,12 @@ func NewFromString(image string) *ImageName {
return New(name, tag)
}

//Check whether an s3 image is referenced by old schema
// isOldS3ImageName Check whether an s3 image is referenced by old schema
func isOldS3ImageName(imageName string) bool {
return strings.HasPrefix(imageName, s3_old_prefix)
return strings.HasPrefix(imageName, s3OldPrefix)
}

//Check whether old image format is used. Also return warning message if yes
// WarnIfOldS3ImageName Check whether old image format is used. Also return warning message if yes
func WarnIfOldS3ImageName(imageName string) (bool, string) {
if !isOldS3ImageName(imageName) {
return false, ""
Expand All @@ -90,10 +90,10 @@ func WarnIfOldS3ImageName(imageName string) (bool, string) {
return true, warning
}

func (s *ImageName) makeOldS3Compatible(image string) string {
func (img *ImageName) makeOldS3Compatible(image string) string {
if isOldS3ImageName(image) {
s.isOld = true
return strings.Replace(image, s3_old_prefix, s3_prefix, 1)
img.isOld = true
return strings.Replace(image, s3OldPrefix, s3Prefix, 1)
}
return image
}
Expand All @@ -116,10 +116,10 @@ func New(image string, tag string) *ImageName {

firstIsHost := false

if strings.HasPrefix(image, s3_prefix) {
if strings.HasPrefix(image, s3Prefix) {
dockerImage.Storage = StorageS3
firstIsHost = true
image = strings.TrimPrefix(image, s3_prefix)
image = strings.TrimPrefix(image, s3Prefix)
}

nameParts := strings.SplitN(image, "/", 2)
Expand Down Expand Up @@ -277,7 +277,7 @@ func (img ImageName) NameWithRegistry() string {
registryPrefix = img.Registry + "/"
}
if img.Storage == StorageS3 {
registryPrefix = s3_prefix + registryPrefix
registryPrefix = s3Prefix + registryPrefix
}
return registryPrefix + img.Name
}
Expand Down

0 comments on commit 871bc85

Please sign in to comment.