GetImageStreamForStrategy -> GetInputReference
The From field might contain something other than an ImageStream, e.g.,
it can contain a reference to a DockerImage.
... | ... |
@@ -19,7 +19,7 @@ func convert_v1_BuildConfig_To_api_BuildConfig(in *BuildConfig, out *newer.Build |
19 | 19 |
// strip off any default imagechange triggers where the buildconfig's |
20 | 20 |
// "from" is not an ImageStreamTag, because those triggers |
21 | 21 |
// will never be invoked. |
22 |
- imageRef := buildutil.GetImageStreamForStrategy(out.Spec.Strategy) |
|
22 |
+ imageRef := buildutil.GetInputReference(out.Spec.Strategy) |
|
23 | 23 |
hasIST := imageRef != nil && imageRef.Kind == "ImageStreamTag" |
24 | 24 |
for _, trigger := range out.Spec.Triggers { |
25 | 25 |
if trigger.Type != newer.ImageChangeBuildTriggerType { |
... | ... |
@@ -20,7 +20,7 @@ func convert_v1beta3_BuildConfig_To_api_BuildConfig(in *BuildConfig, out *newer. |
20 | 20 |
// strip off any default imagechange triggers where the buildconfig's |
21 | 21 |
// "from" is not an ImageStreamTag, because those triggers |
22 | 22 |
// will never be invoked. |
23 |
- imageRef := buildutil.GetImageStreamForStrategy(out.Spec.Strategy) |
|
23 |
+ imageRef := buildutil.GetInputReference(out.Spec.Strategy) |
|
24 | 24 |
hasIST := imageRef != nil && imageRef.Kind == "ImageStreamTag" |
25 | 25 |
for _, trigger := range out.Spec.Triggers { |
26 | 26 |
if trigger.Type != newer.ImageChangeBuildTriggerType { |
... | ... |
@@ -64,7 +64,7 @@ func ValidateBuildConfig(config *buildapi.BuildConfig) field.ErrorList { |
64 | 64 |
fromRefs := map[string]struct{}{} |
65 | 65 |
specPath := field.NewPath("spec") |
66 | 66 |
triggersPath := specPath.Child("triggers") |
67 |
- buildFrom := buildutil.GetImageStreamForStrategy(config.Spec.Strategy) |
|
67 |
+ buildFrom := buildutil.GetInputReference(config.Spec.Strategy) |
|
68 | 68 |
for i, trg := range config.Spec.Triggers { |
69 | 69 |
allErrs = append(allErrs, validateTrigger(&trg, buildFrom, triggersPath.Index(i))...) |
70 | 70 |
if trg.Type != buildapi.ImageChangeBuildTriggerType || trg.ImageChange == nil { |
... | ... |
@@ -72,7 +72,7 @@ func (c *ImageChangeController) HandleImageRepo(repo *imageapi.ImageStream) erro |
72 | 72 |
if trigger.ImageChange.From != nil { |
73 | 73 |
from = trigger.ImageChange.From |
74 | 74 |
} else { |
75 |
- from = buildutil.GetImageStreamForStrategy(config.Spec.Strategy) |
|
75 |
+ from = buildutil.GetInputReference(config.Spec.Strategy) |
|
76 | 76 |
} |
77 | 77 |
|
78 | 78 |
if from == nil || from.Kind != "ImageStreamTag" { |
... | ... |
@@ -143,7 +143,7 @@ func findImageChangeTrigger(bc *buildapi.BuildConfig, ref *kapi.ObjectReference) |
143 | 143 |
imageChange := trigger.ImageChange |
144 | 144 |
triggerRef := imageChange.From |
145 | 145 |
if triggerRef == nil { |
146 |
- triggerRef = buildutil.GetImageStreamForStrategy(bc.Spec.Strategy) |
|
146 |
+ triggerRef = buildutil.GetInputReference(bc.Spec.Strategy) |
|
147 | 147 |
if triggerRef == nil || triggerRef.Kind != "ImageStreamTag" { |
148 | 148 |
continue |
149 | 149 |
} |
... | ... |
@@ -288,7 +288,7 @@ func (g *BuildGenerator) updateImageTriggers(ctx kapi.Context, bc *buildapi.Buil |
288 | 288 |
|
289 | 289 |
triggerImageRef := trigger.ImageChange.From |
290 | 290 |
if triggerImageRef == nil { |
291 |
- triggerImageRef = buildutil.GetImageStreamForStrategy(bc.Spec.Strategy) |
|
291 |
+ triggerImageRef = buildutil.GetInputReference(bc.Spec.Strategy) |
|
292 | 292 |
} |
293 | 293 |
if triggerImageRef == nil { |
294 | 294 |
glog.Warningf("Could not get ImageStream reference for default ImageChangeTrigger on BuildConfig %s/%s", bc.Namespace, bc.Name) |
... | ... |
@@ -434,7 +434,7 @@ func (g *BuildGenerator) generateBuildFromConfig(ctx kapi.Context, bc *buildapi. |
434 | 434 |
var sourceImageSpec string |
435 | 435 |
// if the imagesource matches the strategy from, and we have a trigger for the strategy from, |
436 | 436 |
// use the imageid from the trigger rather than resolving it. |
437 |
- if strategyFrom := buildutil.GetImageStreamForStrategy(bc.Spec.Strategy); reflect.DeepEqual(sourceImage.From, *strategyFrom) && |
|
437 |
+ if strategyFrom := buildutil.GetInputReference(bc.Spec.Strategy); reflect.DeepEqual(sourceImage.From, *strategyFrom) && |
|
438 | 438 |
strategyImageChangeTrigger != nil { |
439 | 439 |
sourceImageSpec = strategyImageChangeTrigger.LastTriggeredImageID |
440 | 440 |
} else { |
... | ... |
@@ -299,7 +299,7 @@ func TestInstantiateWithImageTrigger(t *testing.T) { |
299 | 299 |
if bc.Spec.Triggers[i].Type == buildapi.ImageChangeBuildTriggerType { |
300 | 300 |
from := bc.Spec.Triggers[i].ImageChange.From |
301 | 301 |
if from == nil { |
302 |
- from = buildutil.GetImageStreamForStrategy(bc.Spec.Strategy) |
|
302 |
+ from = buildutil.GetInputReference(bc.Spec.Strategy) |
|
303 | 303 |
} |
304 | 304 |
if bc.Spec.Triggers[i].ImageChange.LastTriggeredImageID != ("ref@" + from.Name) { |
305 | 305 |
t.Errorf("%s: expected LastTriggeredImageID for trigger at %d to be %s. Got: %s", tc.name, i, "ref@"+from.Name, bc.Spec.Triggers[i].ImageChange.LastTriggeredImageID) |
... | ... |
@@ -94,7 +94,7 @@ func AddInputEdges(g osgraph.MutableUniqueGraph, node *buildgraph.BuildConfigNod |
94 | 94 |
if in := buildgraph.EnsureSourceRepositoryNode(g, node.BuildConfig.Spec.Source); in != nil { |
95 | 95 |
g.AddEdge(in, node, BuildInputEdgeKind) |
96 | 96 |
} |
97 |
- inputImage := buildutil.GetImageStreamForStrategy(node.BuildConfig.Spec.Strategy) |
|
97 |
+ inputImage := buildutil.GetInputReference(node.BuildConfig.Spec.Strategy) |
|
98 | 98 |
if input := imageRefNode(g, inputImage, node.BuildConfig); input != nil { |
99 | 99 |
g.AddEdge(input, node, BuildInputImageEdgeKind) |
100 | 100 |
} |
... | ... |
@@ -108,7 +108,7 @@ func AddTriggerEdges(g osgraph.MutableUniqueGraph, node *buildgraph.BuildConfigN |
108 | 108 |
} |
109 | 109 |
from := trigger.ImageChange.From |
110 | 110 |
if trigger.ImageChange.From == nil { |
111 |
- from = buildutil.GetImageStreamForStrategy(node.BuildConfig.Spec.Strategy) |
|
111 |
+ from = buildutil.GetInputReference(node.BuildConfig.Spec.Strategy) |
|
112 | 112 |
} |
113 | 113 |
triggerNode := imageRefNode(g, from, node.BuildConfig) |
114 | 114 |
g.AddEdge(triggerNode, node, BuildTriggerImageEdgeKind) |
... | ... |
@@ -30,9 +30,9 @@ func GetBuildName(pod *kapi.Pod) string { |
30 | 30 |
return pod.Annotations[buildapi.BuildAnnotation] |
31 | 31 |
} |
32 | 32 |
|
33 |
-// GetImageStreamForStrategy returns the ImageStream[Tag/Image] ObjectReference associated |
|
34 |
-// with the BuildStrategy. |
|
35 |
-func GetImageStreamForStrategy(strategy buildapi.BuildStrategy) *kapi.ObjectReference { |
|
33 |
+// GetInputReference returns the From ObjectReference associated with the |
|
34 |
+// BuildStrategy. |
|
35 |
+func GetInputReference(strategy buildapi.BuildStrategy) *kapi.ObjectReference { |
|
36 | 36 |
switch { |
37 | 37 |
case strategy.SourceStrategy != nil: |
38 | 38 |
return &strategy.SourceStrategy.From |
... | ... |
@@ -672,7 +672,7 @@ Outer: |
672 | 672 |
// strategyTrigger returns a synthetic ImageChangeTrigger that represents the image stream tag the build strategy |
673 | 673 |
// points to, or nil if no such strategy trigger is possible (if the build doesn't point to an ImageStreamTag). |
674 | 674 |
func strategyTrigger(config *buildapi.BuildConfig) *ImageChangeTrigger { |
675 |
- if from := buildutil.GetImageStreamForStrategy(config.Spec.Strategy); from != nil { |
|
675 |
+ if from := buildutil.GetInputReference(config.Spec.Strategy); from != nil { |
|
676 | 676 |
if from.Kind == "ImageStreamTag" { |
677 | 677 |
// normalize the strategy object reference |
678 | 678 |
from.Namespace = defaultNamespace(from.Namespace, config.Namespace) |
... | ... |
@@ -1128,7 +1128,7 @@ func (c *AppConfig) run(acceptors app.Acceptors) (*AppResult, error) { |
1128 | 1128 |
func (c *AppConfig) checkCircularReferences(objects app.Objects) error { |
1129 | 1129 |
for _, obj := range objects { |
1130 | 1130 |
if bc, ok := obj.(*buildapi.BuildConfig); ok { |
1131 |
- input := buildutil.GetImageStreamForStrategy(bc.Spec.Strategy) |
|
1131 |
+ input := buildutil.GetInputReference(bc.Spec.Strategy) |
|
1132 | 1132 |
if bc.Spec.Output.To != nil && input != nil && |
1133 | 1133 |
reflect.DeepEqual(input, bc.Spec.Output.To) { |
1134 | 1134 |
ns := input.Namespace |
... | ... |
@@ -495,7 +495,7 @@ func addBuildsToGraph(g graph.Graph, builds *buildapi.BuildList) { |
495 | 495 |
// to the image specified by strategy.from, as long as the image is managed by |
496 | 496 |
// OpenShift. |
497 | 497 |
func addBuildStrategyImageReferencesToGraph(g graph.Graph, strategy buildapi.BuildStrategy, predecessor gonum.Node) { |
498 |
- from := buildutil.GetImageStreamForStrategy(strategy) |
|
498 |
+ from := buildutil.GetInputReference(strategy) |
|
499 | 499 |
if from == nil { |
500 | 500 |
glog.V(4).Infof("Unable to determine 'from' reference - skipping") |
501 | 501 |
return |