diff --git a/pkg/api/graph/test/bc-missing-output.yaml b/pkg/api/graph/test/bc-missing-output.yaml new file mode 100644 index 000000000000..e97a704a1750 --- /dev/null +++ b/pkg/api/graph/test/bc-missing-output.yaml @@ -0,0 +1,33 @@ +apiVersion: v1 +kind: BuildConfig +metadata: + annotations: + openshift.io/generated-by: OpenShiftNewApp + creationTimestamp: 2015-11-18T14:41:17Z + labels: + app: gitauthtest + template: gitserver + name: gitauthtest + namespace: devproj + resourceVersion: "634" + selfLink: /oapi/v1/namespaces/devproj/buildconfigs/gitauthtest + uid: 6d487478-8e02-11e5-9cf2-3c970e88b00e +spec: + output: {} + resources: {} + source: + git: + uri: http://gitserver-tokenauth.linux.xip.io/ruby-hello-world + sourceSecret: + name: builder-token-nbme5 + type: Git + strategy: + sourceStrategy: + from: + kind: ImageStreamTag + name: ruby:latest + namespace: openshift + type: Source + triggers: [] +status: + lastVersion: 1 diff --git a/pkg/build/graph/analysis/bc_test.go b/pkg/build/graph/analysis/bc_test.go index 6678d99dad46..0ad73bbfd021 100644 --- a/pkg/build/graph/analysis/bc_test.go +++ b/pkg/build/graph/analysis/bc_test.go @@ -72,6 +72,16 @@ func TestPushableBuild(t *testing.T) { } } +func TestBuildConfigNoOutput(t *testing.T) { + g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/bc-missing-output.yaml") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + // we were getting go panics with nil refs cause output destinations are not required for BuildConfigs + buildedges.AddAllInputOutputEdges(g) +} + func TestCircularDeps(t *testing.T) { g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/circular.yaml") if err != nil { diff --git a/pkg/build/graph/edges.go b/pkg/build/graph/edges.go index a3846a9a3a45..55a3369351b2 100644 --- a/pkg/build/graph/edges.go +++ b/pkg/build/graph/edges.go @@ -79,6 +79,9 @@ func imageRefNode(g osgraph.MutableUniqueGraph, ref *kapi.ObjectReference, bc *b // AddOutputEdges links the build config to its output image node. func AddOutputEdges(g osgraph.MutableUniqueGraph, node *buildgraph.BuildConfigNode) { + if node.BuildConfig.Spec.Output.To == nil { + return + } out := imageRefNode(g, node.BuildConfig.Spec.Output.To, node.BuildConfig) g.AddEdge(node, out, BuildOutputEdgeKind) }