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

Bug 1327108 - Updated error information when trying to import ImageStream pointing to a different one #9021

Merged
merged 1 commit into from Jun 15, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/cmd/cli/cmd/importimage.go
Expand Up @@ -329,8 +329,12 @@ func (o *ImportImageOptions) importTag(stream *imageapi.ImageStream) (*imageapi.

// update ImageStream appropriately
if ok {
// disallow re-importing anything other than DockerImage
if existing.From != nil && existing.From.Kind != "DockerImage" {
return nil, fmt.Errorf("tag %q points to existing %s %q, it cannot be re-imported", tag, existing.From.Kind, existing.From.Name)
}
// disallow changing an existing tag
if existing.From == nil || existing.From.Kind != "DockerImage" {
if existing.From == nil {
return nil, fmt.Errorf("tag %q already exists - you must use the 'tag' command if you want to change the source to %q", tag, from)
}
if len(from) != 0 && from != existing.From.Name {
Expand Down
37 changes: 37 additions & 0 deletions pkg/cmd/cli/cmd/importimage_test.go
Expand Up @@ -250,6 +250,43 @@ func TestCreateImageImport(t *testing.T) {
},
},
},
"import tag from .spec.tags": {
name: "testis:mytag",
stream: &imageapi.ImageStream{
ObjectMeta: kapi.ObjectMeta{
Name: "testis",
Namespace: "other",
},
Spec: imageapi.ImageStreamSpec{
Tags: map[string]imageapi.TagReference{
"mytag": {
From: &kapi.ObjectReference{Kind: "DockerImage", Name: "repo.com/somens/someimage:mytag"},
},
},
},
},
expectedImages: []imageapi.ImageImportSpec{{
From: kapi.ObjectReference{Kind: "DockerImage", Name: "repo.com/somens/someimage:mytag"},
To: &kapi.LocalObjectReference{Name: "mytag"},
}},
},
"import tag from .spec.tags with Kind != DockerImage": {
name: "testis:mytag",
stream: &imageapi.ImageStream{
ObjectMeta: kapi.ObjectMeta{
Name: "testis",
Namespace: "other",
},
Spec: imageapi.ImageStreamSpec{
Tags: map[string]imageapi.TagReference{
"mytag": {
From: &kapi.ObjectReference{Kind: "ImageStreamTag", Name: "someimage:mytag"},
},
},
},
},
err: "tag \"mytag\" points to existing ImageStreamTag \"someimage:mytag\", it cannot be re-imported",
},
"use insecure annotation": {
name: "testis",
stream: &imageapi.ImageStream{
Expand Down