From aa0d81c8e7fd3d75c5e31f4ec67de06317e0d872 Mon Sep 17 00:00:00 2001 From: Roman Khlystik Date: Tue, 9 Feb 2016 19:25:58 +0200 Subject: [PATCH 01/10] Changed log message from s3: to s3.amazonaws.com/ --- src/storage/s3/s3.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/s3/s3.go b/src/storage/s3/s3.go index f97be5e1..f2358122 100644 --- a/src/storage/s3/s3.go +++ b/src/storage/s3/s3.go @@ -226,7 +226,7 @@ func (s *StorageS3) Pull(name string) error { } ) - log.Infof("| Import s3://%s/%s to %s", img.Registry, imgPath, tmpf.Name()) + log.Infof("| Import s3.amazonaws.com/%s/%s to %s", img.Registry, imgPath, tmpf.Name()) if err := s.retryer.Outer(func() error { _, err := downloader.Download(tmpf, downloadParams) From 7a209026243af6d9a81e04fd51c228621e836c51 Mon Sep 17 00:00:00 2001 From: Roman Khlystik Date: Tue, 9 Feb 2016 19:27:09 +0200 Subject: [PATCH 02/10] Ctor will be able to create ImageName from new s3 urls Will use the following convention for s3 images: s3.amazonaws.com// instead of old one: s3:/ Will leave compatibility level for now to handle old schema --- src/imagename/imagename.go | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/imagename/imagename.go b/src/imagename/imagename.go index 92ba5bf4..2cebb6f3 100644 --- a/src/imagename/imagename.go +++ b/src/imagename/imagename.go @@ -44,6 +44,11 @@ const ( StorageS3 = "s3" ) +const ( + s3_prefix = "s3.amazonaws.com/" + s3_old_prefix = "s3:" +) + var ( ecrRe = regexp.MustCompile("^\\d+\\.dkr\\.ecr\\.[^\\.]+\\.amazonaws\\.com$") ) @@ -63,6 +68,13 @@ func NewFromString(image string) *ImageName { return New(name, tag) } +func makeOldS3Compatible(image string) string { + if strings.HasPrefix(image, s3_old_prefix) { + return strings.Replace(image, s3_old_prefix, s3_prefix, 1) + } + return image +} + // New parses a given 'image' and 'tag' strings and returns ImageName func New(image string, tag string) *ImageName { dockerImage := &ImageName{} @@ -74,19 +86,17 @@ func New(image string, tag string) *ImageName { // default storage driver dockerImage.Storage = StorageRegistry - // In case storage is specified, e.g. s3://bucket-name/image-name - storages := []string{StorageRegistry, StorageS3} - firstIsHost := false + //Replace 's3:' to 's3.amazonaws.com/' if any. + //We are doing it for backward compatibility reasons + //In future this function should be removed + image = makeOldS3Compatible(image) - for _, storage := range storages { - prefix := storage + ":" + firstIsHost := false - if strings.HasPrefix(image, prefix) { - image = strings.TrimPrefix(image, prefix) - dockerImage.Storage = storage - firstIsHost = true - break - } + if strings.HasPrefix(image, s3_prefix) { + dockerImage.Storage = StorageS3 + firstIsHost = true + image = strings.TrimPrefix(image, s3_prefix) } nameParts := strings.SplitN(image, "/", 2) From eac0e02d74899c01dc8168f8bd265781607074ab Mon Sep 17 00:00:00 2001 From: Roman Khlystik Date: Wed, 10 Feb 2016 16:48:23 +0200 Subject: [PATCH 03/10] Added isOld member. Added method to get warn message in case of old s3 --- src/imagename/imagename.go | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/imagename/imagename.go b/src/imagename/imagename.go index 2cebb6f3..12351caf 100644 --- a/src/imagename/imagename.go +++ b/src/imagename/imagename.go @@ -21,6 +21,7 @@ package imagename import ( "encoding/json" + "fmt" "regexp" "sort" "strings" @@ -60,6 +61,8 @@ type ImageName struct { Tag string Storage string Version *semver.Range + + isOld bool } // NewFromString parses a given string and returns ImageName @@ -68,8 +71,28 @@ func NewFromString(image string) *ImageName { return New(name, tag) } -func makeOldS3Compatible(image string) string { - if strings.HasPrefix(image, s3_old_prefix) { +//Check whether an s3 image is referenced by old schema +func isOldS3ImageName(imageName string) bool { + return strings.HasPrefix(imageName, s3_old_prefix) +} + +//Check whether old image format is used. Also return warning message if yes +func WarnIfOldS3ImageName(imageName string) (bool, string) { + if !isOldS3ImageName(imageName) { + return false, "" + } + + warning := fmt.Sprintf("Your image '%s' is using old name style (s3:/) for s3 images."+ + " This style isn't supported by docker 1.10 and would be removed from rocker in the future as well."+ + " Please consider changing to the new schema (s3.amazonaws.com//)."+ + " For now, I'll do the conversion internally to not break your old Rockerfiles", imageName) + + return true, warning +} + +func (s *ImageName) makeOldS3Compatible(image string) string { + if isOldS3ImageName(image) { + s.isOld = true return strings.Replace(image, s3_old_prefix, s3_prefix, 1) } return image @@ -89,7 +112,7 @@ func New(image string, tag string) *ImageName { //Replace 's3:' to 's3.amazonaws.com/' if any. //We are doing it for backward compatibility reasons //In future this function should be removed - image = makeOldS3Compatible(image) + image = dockerImage.makeOldS3Compatible(image) firstIsHost := false @@ -244,7 +267,7 @@ func (img ImageName) TagAsVersion() (ver *semver.Version) { // IsSameKind returns true if current image and the given one are same but may have different versions (tags) func (img ImageName) IsSameKind(b ImageName) bool { - return img.Registry == b.Registry && img.Name == b.Name + return img.Registry == b.Registry && img.Name == b.Name && img.isOld == b.isOld } // NameWithRegistry returns the [registry/]name of the current image name @@ -253,8 +276,8 @@ func (img ImageName) NameWithRegistry() string { if img.Registry != "" { registryPrefix = img.Registry + "/" } - if img.Storage != StorageRegistry { - registryPrefix = img.Storage + ":" + registryPrefix + if img.Storage == StorageS3 { + registryPrefix = s3_prefix + registryPrefix } return registryPrefix + img.Name } From c6e67080bb335da0591d23b57a9e516f4a8fab71 Mon Sep 17 00:00:00 2001 From: Roman Khlystik Date: Wed, 10 Feb 2016 16:55:43 +0200 Subject: [PATCH 04/10] Added warn messages in case of old s3 --- src/build/client.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/build/client.go b/src/build/client.go index 756e9bab..c5cc212a 100644 --- a/src/build/client.go +++ b/src/build/client.go @@ -120,6 +120,10 @@ 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 { + c.log.Warn(warning) + } + return c.s3storage.Pull(name) } @@ -183,6 +187,9 @@ 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 { + c.log.Warn(warning) + } return c.s3storage.ListTags(name) } return dockerclient.RegistryListTags(imagename.NewFromString(name), c.auth) @@ -432,6 +439,9 @@ 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 { + c.log.Warn(warning) + } c.log.Infof("| Tag %.12s -> %s", imageID, img) @@ -475,6 +485,9 @@ 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 { + c.log.Warn(warning) + } return c.s3storage.Push(imageName) } From bfcf6f856a9977aff2fda65bf104687ec7e046d9 Mon Sep 17 00:00:00 2001 From: Roman Khlystik Date: Wed, 10 Feb 2016 17:22:34 +0200 Subject: [PATCH 05/10] imgName will be created from new s3 name --- src/storage/s3/s3.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/s3/s3.go b/src/storage/s3/s3.go index f2358122..7cf60ecc 100644 --- a/src/storage/s3/s3.go +++ b/src/storage/s3/s3.go @@ -483,7 +483,7 @@ func (s *StorageS3) ListTags(imageName string) (images []*imagename.ImageName, e } imgName := strings.Join(split[:len(split)-1], "/") - imgName = fmt.Sprintf("s3:%s/%s", image.Registry, imgName) + imgName = fmt.Sprintf("s3.amazonaws.com/%s/%s", image.Registry, imgName) tag := strings.TrimSuffix(split[len(split)-1], ".tar") candidate := imagename.New(imgName, tag) From f98091da1e9941165b886bcde399270af2c0eb9a Mon Sep 17 00:00:00 2001 From: Roman Khlystik Date: Wed, 10 Feb 2016 17:27:08 +0200 Subject: [PATCH 06/10] Warning about old s3 images --- src/build/build.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/build/build.go b/src/build/build.go index 0996d8f3..1c010050 100644 --- a/src/build/build.go +++ b/src/build/build.go @@ -270,6 +270,9 @@ 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 { + log.Warn(warning) + } var ( candidate, remoteCandidate *imagename.ImageName From 16579f57be3a88b9a7bf3f5524ba2349e1c7bc90 Mon Sep 17 00:00:00 2001 From: Roman Khlystik Date: Wed, 10 Feb 2016 17:53:05 +0200 Subject: [PATCH 07/10] Log messages changed from old format to new one --- src/storage/s3/s3.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/storage/s3/s3.go b/src/storage/s3/s3.go index 7cf60ecc..2c3a1da9 100644 --- a/src/storage/s3/s3.go +++ b/src/storage/s3/s3.go @@ -155,7 +155,7 @@ func (s *StorageS3) Push(imageName string) (digest string, err error) { } defer fd.Close() - log.Infof("| Uploading image to s3://%s/%s", img.Registry, imgPathDigest) + log.Infof("| Uploading image to s3.amazonaws.com/%s/%s", img.Registry, imgPathDigest) uploadParams := &s3manager.UploadInput{ Bucket: aws.String(img.Registry), @@ -184,7 +184,7 @@ func (s *StorageS3) Push(imageName string) (digest string, err error) { Key: aws.String(imgPathTag), } - log.Infof("| Make alias s3://%s/%s", img.Registry, imgPathTag) + log.Infof("| Make alias s3.amazonaws.com/%s/%s", img.Registry, imgPathTag) if _, err = s.s3.CopyObject(copyParams); err != nil { return "", fmt.Errorf("Failed to PUT object to S3, error: %s", err) From 6159df08c9fb0365d305edf3c5d98654e3f4fddc Mon Sep 17 00:00:00 2001 From: Roman Khlystik Date: Wed, 10 Feb 2016 18:23:22 +0200 Subject: [PATCH 08/10] Fixed tests --- src/imagename/imagename_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/imagename/imagename_test.go b/src/imagename/imagename_test.go index a42699a6..e7bd60e1 100644 --- a/src/imagename/imagename_test.go +++ b/src/imagename/imagename_test.go @@ -499,8 +499,8 @@ func TestImagename_S3_Basic(t *testing.T) { assert.Equal(t, "image-name", img.Name) assert.Equal(t, false, img.TagIsSha()) assert.Equal(t, "1.2.3", img.GetTag()) - assert.Equal(t, "s3:bucket-name/image-name", img.NameWithRegistry()) - assert.Equal(t, "s3:bucket-name/image-name:1.2.3", img.String()) + assert.Equal(t, "s3.amazonaws.com/bucket-name/image-name", img.NameWithRegistry()) + assert.Equal(t, "s3.amazonaws.com/bucket-name/image-name:1.2.3", img.String()) } func TestImagename_S3_Digest(t *testing.T) { @@ -509,9 +509,9 @@ func TestImagename_S3_Digest(t *testing.T) { assert.Equal(t, "image-name", img.Name) assert.Equal(t, true, img.TagIsSha()) assert.Equal(t, true, img.TagIsDigest()) - assert.Equal(t, "s3:bucket-name/image-name", img.NameWithRegistry()) + assert.Equal(t, "s3.amazonaws.com/bucket-name/image-name", img.NameWithRegistry()) assert.Equal(t, "sha256:ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11", img.GetTag()) - assert.Equal(t, "s3:bucket-name/image-name@sha256:ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11", img.String()) + assert.Equal(t, "s3.amazonaws.com/bucket-name/image-name@sha256:ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11", img.String()) } func TestImagename_S3_Sha(t *testing.T) { @@ -520,7 +520,7 @@ func TestImagename_S3_Sha(t *testing.T) { assert.Equal(t, "image-name", img.Name) assert.Equal(t, true, img.TagIsSha()) assert.Equal(t, false, img.TagIsDigest()) - assert.Equal(t, "s3:bucket-name/image-name", img.NameWithRegistry()) + assert.Equal(t, "s3.amazonaws.com/bucket-name/image-name", img.NameWithRegistry()) assert.Equal(t, "sha256-ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11", img.GetTag()) - assert.Equal(t, "s3:bucket-name/image-name:sha256-ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11", img.String()) + assert.Equal(t, "s3.amazonaws.com/bucket-name/image-name:sha256-ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11", img.String()) } From ff5910eb6daf23ec8164a3ad5462273518de5f60 Mon Sep 17 00:00:00 2001 From: Roman Khlystik Date: Wed, 10 Feb 2016 18:28:13 +0200 Subject: [PATCH 09/10] Added test for new s3 path schema --- src/imagename/imagename_test.go | 38 ++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/src/imagename/imagename_test.go b/src/imagename/imagename_test.go index e7bd60e1..64ce126e 100644 --- a/src/imagename/imagename_test.go +++ b/src/imagename/imagename_test.go @@ -493,7 +493,7 @@ func TestImagename_ToYaml(t *testing.T) { assert.Equal(t, "name: hub/ns/name:1\n", string(data)) } -func TestImagename_S3_Basic(t *testing.T) { +func TestImagename_S3_Basic_Old(t *testing.T) { img := NewFromString("s3:bucket-name/image-name:1.2.3") assert.Equal(t, "bucket-name", img.Registry) assert.Equal(t, "image-name", img.Name) @@ -503,7 +503,7 @@ func TestImagename_S3_Basic(t *testing.T) { assert.Equal(t, "s3.amazonaws.com/bucket-name/image-name:1.2.3", img.String()) } -func TestImagename_S3_Digest(t *testing.T) { +func TestImagename_S3_Digest_Old(t *testing.T) { img := NewFromString("s3:bucket-name/image-name@sha256:ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11") assert.Equal(t, "bucket-name", img.Registry) assert.Equal(t, "image-name", img.Name) @@ -514,7 +514,7 @@ func TestImagename_S3_Digest(t *testing.T) { assert.Equal(t, "s3.amazonaws.com/bucket-name/image-name@sha256:ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11", img.String()) } -func TestImagename_S3_Sha(t *testing.T) { +func TestImagename_S3_Sha_Old(t *testing.T) { img := NewFromString("s3:bucket-name/image-name:sha256-ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11") assert.Equal(t, "bucket-name", img.Registry) assert.Equal(t, "image-name", img.Name) @@ -524,3 +524,35 @@ func TestImagename_S3_Sha(t *testing.T) { assert.Equal(t, "sha256-ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11", img.GetTag()) assert.Equal(t, "s3.amazonaws.com/bucket-name/image-name:sha256-ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11", img.String()) } + +func TestImagename_S3_Basic(t *testing.T) { + img := NewFromString("s3.amazonaws.com/bucket-name/image-name:1.2.3") + assert.Equal(t, "bucket-name", img.Registry) + assert.Equal(t, "image-name", img.Name) + assert.Equal(t, false, img.TagIsSha()) + assert.Equal(t, "1.2.3", img.GetTag()) + assert.Equal(t, "s3.amazonaws.com/bucket-name/image-name", img.NameWithRegistry()) + assert.Equal(t, "s3.amazonaws.com/bucket-name/image-name:1.2.3", img.String()) +} + +func TestImagename_S3_Digest(t *testing.T) { + img := NewFromString("s3.amazonaws.com/bucket-name/image-name@sha256:ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11") + assert.Equal(t, "bucket-name", img.Registry) + assert.Equal(t, "image-name", img.Name) + assert.Equal(t, true, img.TagIsSha()) + assert.Equal(t, true, img.TagIsDigest()) + assert.Equal(t, "s3.amazonaws.com/bucket-name/image-name", img.NameWithRegistry()) + assert.Equal(t, "sha256:ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11", img.GetTag()) + assert.Equal(t, "s3.amazonaws.com/bucket-name/image-name@sha256:ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11", img.String()) +} + +func TestImagename_S3_Sha(t *testing.T) { + img := NewFromString("s3.amazonaws.com/bucket-name/image-name:sha256-ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11") + assert.Equal(t, "bucket-name", img.Registry) + assert.Equal(t, "image-name", img.Name) + assert.Equal(t, true, img.TagIsSha()) + assert.Equal(t, false, img.TagIsDigest()) + assert.Equal(t, "s3.amazonaws.com/bucket-name/image-name", img.NameWithRegistry()) + assert.Equal(t, "sha256-ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11", img.GetTag()) + assert.Equal(t, "s3.amazonaws.com/bucket-name/image-name:sha256-ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11", img.String()) +} From 871bc85774b611ba3bf1410e58b92dda29d755a8 Mon Sep 17 00:00:00 2001 From: Roman Khlystik Date: Wed, 10 Feb 2016 19:05:47 +0200 Subject: [PATCH 10/10] Make lint happy --- src/build/build.go | 2 +- src/build/client.go | 8 ++++---- src/build/commands.go | 2 +- src/imagename/imagename.go | 22 +++++++++++----------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/build/build.go b/src/build/build.go index 1c010050..d1bb56a8 100644 --- a/src/build/build.go +++ b/src/build/build.go @@ -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 ( diff --git a/src/build/client.go b/src/build/client.go index c5cc212a..8c80f4fa 100644 --- a/src/build/client.go +++ b/src/build/client.go @@ -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) } @@ -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) @@ -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) } @@ -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) diff --git a/src/build/commands.go b/src/build/commands.go index c7c88097..29b40436 100644 --- a/src/build/commands.go +++ b/src/build/commands.go @@ -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 { diff --git a/src/imagename/imagename.go b/src/imagename/imagename.go index 12351caf..82b0e84e 100644 --- a/src/imagename/imagename.go +++ b/src/imagename/imagename.go @@ -46,8 +46,8 @@ const ( ) const ( - s3_prefix = "s3.amazonaws.com/" - s3_old_prefix = "s3:" + s3Prefix = "s3.amazonaws.com/" + s3OldPrefix = "s3:" ) var ( @@ -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, "" @@ -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 } @@ -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) @@ -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 }