Browse code

Merge pull request #12376 from soltysh/bug1348174

Merged by openshift-bot

OpenShift Bot authored on 2017/01/05 03:27:35
Showing 2 changed files
... ...
@@ -6,6 +6,8 @@ import (
6 6
 	"strings"
7 7
 	"time"
8 8
 
9
+	"github.com/spf13/cobra"
10
+
9 11
 	kapi "k8s.io/kubernetes/pkg/api"
10 12
 	"k8s.io/kubernetes/pkg/api/errors"
11 13
 	"k8s.io/kubernetes/pkg/api/unversioned"
... ...
@@ -17,10 +19,8 @@ import (
17 17
 	"github.com/openshift/origin/pkg/client"
18 18
 	"github.com/openshift/origin/pkg/cmd/cli/describe"
19 19
 	"github.com/openshift/origin/pkg/cmd/templates"
20
-	imageapi "github.com/openshift/origin/pkg/image/api"
21
-	"github.com/spf13/cobra"
22
-
23 20
 	"github.com/openshift/origin/pkg/cmd/util/clientcmd"
21
+	imageapi "github.com/openshift/origin/pkg/image/api"
24 22
 )
25 23
 
26 24
 var (
... ...
@@ -383,7 +383,7 @@ func (o *ImportImageOptions) importTag(stream *imageapi.ImageStream) (*imageapi.
383 383
 
384 384
 	} else {
385 385
 		// create a new tag
386
-		if len(from) == 0 {
386
+		if len(from) == 0 && tag == imageapi.DefaultImageTag {
387 387
 			from = stream.Spec.DockerImageRepository
388 388
 		}
389 389
 		// if the from is still empty this means there's no such tag defined
... ...
@@ -59,6 +59,17 @@ func TestCreateImageImport(t *testing.T) {
59 59
 				To:   &kapi.LocalObjectReference{Name: "latest"},
60 60
 			}},
61 61
 		},
62
+		"import from .spec.dockerImageRepository non-existing tag": {
63
+			name: "testis:nonexisting",
64
+			stream: &imageapi.ImageStream{
65
+				ObjectMeta: kapi.ObjectMeta{Name: "testis", Namespace: "other"},
66
+				Spec: imageapi.ImageStreamSpec{
67
+					DockerImageRepository: "repo.com/somens/someimage",
68
+					Tags: make(map[string]imageapi.TagReference),
69
+				},
70
+			},
71
+			err: `"nonexisting" does not exist on the image stream`,
72
+		},
62 73
 		"import all from .spec.dockerImageRepository": {
63 74
 			name: "testis",
64 75
 			all:  true,