@@ -265,7 +265,7 @@ func (o *ImportImageOptions) createImageImport() (*imageapi.ImageStream, *imagea
265
265
266
266
// the stream already exists
267
267
if len (stream .Spec .DockerImageRepository ) == 0 && len (stream .Spec .Tags ) == 0 {
268
- return nil , nil , fmt .Errorf ("image stream has not defined anything to import " )
268
+ return nil , nil , fmt .Errorf ("image stream does not have valid docker images to be imported " )
269
269
}
270
270
271
271
if o .All {
@@ -285,45 +285,6 @@ func (o *ImportImageOptions) createImageImport() (*imageapi.ImageStream, *imagea
285
285
return stream , isi , nil
286
286
}
287
287
288
- func (o * ImportImageOptions ) newImageStream () (* imageapi.ImageStream , * imageapi.ImageStreamImport ) {
289
- from := o .From
290
- tag := o .Tag
291
- if len (from ) == 0 {
292
- from = o .Target
293
- }
294
- var stream * imageapi.ImageStream
295
- // create new ImageStream
296
- if o .All {
297
- stream = & imageapi.ImageStream {
298
- ObjectMeta : kapi.ObjectMeta {Name : o .Name },
299
- Spec : imageapi.ImageStreamSpec {DockerImageRepository : from },
300
- }
301
- } else {
302
- stream = & imageapi.ImageStream {
303
- ObjectMeta : kapi.ObjectMeta {Name : o .Name },
304
- Spec : imageapi.ImageStreamSpec {
305
- Tags : map [string ]imageapi.TagReference {
306
- tag : {
307
- From : & kapi.ObjectReference {
308
- Kind : "DockerImage" ,
309
- Name : from ,
310
- },
311
- },
312
- },
313
- },
314
- }
315
- }
316
- // and accompanying ImageStreamImport
317
- var isi * imageapi.ImageStreamImport
318
- if o .All {
319
- isi = o .newImageStreamImportAll (stream , from )
320
- } else {
321
- isi = o .newImageStreamImportTags (stream , map [string ]string {tag : from })
322
- }
323
-
324
- return stream , isi
325
- }
326
-
327
288
func (o * ImportImageOptions ) importAll (stream * imageapi.ImageStream ) (* imageapi.ImageStreamImport , error ) {
328
289
from := o .From
329
290
// update ImageStream appropriately
@@ -338,7 +299,7 @@ func (o *ImportImageOptions) importAll(stream *imageapi.ImageStream) (*imageapi.
338
299
}
339
300
}
340
301
if len (tags ) == 0 {
341
- return nil , fmt .Errorf ("image stream does not have importable tags ( pointing to DockerImage) " )
302
+ return nil , fmt .Errorf ("image stream does not have tags pointing to external docker images " )
342
303
}
343
304
return o .newImageStreamImportTags (stream , tags ), nil
344
305
}
@@ -414,6 +375,45 @@ func (o *ImportImageOptions) importTag(stream *imageapi.ImageStream) (*imageapi.
414
375
return o .newImageStreamImportTags (stream , map [string ]string {tag : from }), nil
415
376
}
416
377
378
+ func (o * ImportImageOptions ) newImageStream () (* imageapi.ImageStream , * imageapi.ImageStreamImport ) {
379
+ from := o .From
380
+ tag := o .Tag
381
+ if len (from ) == 0 {
382
+ from = o .Target
383
+ }
384
+ var stream * imageapi.ImageStream
385
+ // create new ImageStream
386
+ if o .All {
387
+ stream = & imageapi.ImageStream {
388
+ ObjectMeta : kapi.ObjectMeta {Name : o .Name },
389
+ Spec : imageapi.ImageStreamSpec {DockerImageRepository : from },
390
+ }
391
+ } else {
392
+ stream = & imageapi.ImageStream {
393
+ ObjectMeta : kapi.ObjectMeta {Name : o .Name },
394
+ Spec : imageapi.ImageStreamSpec {
395
+ Tags : map [string ]imageapi.TagReference {
396
+ tag : {
397
+ From : & kapi.ObjectReference {
398
+ Kind : "DockerImage" ,
399
+ Name : from ,
400
+ },
401
+ },
402
+ },
403
+ },
404
+ }
405
+ }
406
+ // and accompanying ImageStreamImport
407
+ var isi * imageapi.ImageStreamImport
408
+ if o .All {
409
+ isi = o .newImageStreamImportAll (stream , from )
410
+ } else {
411
+ isi = o .newImageStreamImportTags (stream , map [string ]string {tag : from })
412
+ }
413
+
414
+ return stream , isi
415
+ }
416
+
417
417
func (o * ImportImageOptions ) newImageStreamImport (stream * imageapi.ImageStream ) (* imageapi.ImageStreamImport , bool ) {
418
418
isi := & imageapi.ImageStreamImport {
419
419
ObjectMeta : kapi.ObjectMeta {
0 commit comments