Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

Commit

Permalink
Propagate the labels form the build on the pod (#559)
Browse files Browse the repository at this point in the history
* Propagate the labels from the build to the pod

This allows users to specify custom labels.

* Fix typo in comment
  • Loading branch information
Cosmin Cojocar authored and knative-prow-robot committed Mar 18, 2019
1 parent d968971 commit 326da2d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/reconciler/build/resources/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,14 @@ func MakePod(build *v1alpha1.Build, kubeclient kubernetes.Interface) (*corev1.Po
}
annotations["sidecar.istio.io/inject"] = "false"

// Copy labels on the build through to the underlying pod to allow users
// to specify pod labels.
labels := map[string]string{}
for key, val := range build.Labels {
labels[key] = val
}
labels[buildNameLabelKey] = build.Name

cred, secrets, err := makeCredentialInitializer(build, kubeclient)
if err != nil {
return nil, err
Expand Down Expand Up @@ -364,9 +372,7 @@ func MakePod(build *v1alpha1.Build, kubeclient kubernetes.Interface) (*corev1.Po
}),
},
Annotations: annotations,
Labels: map[string]string{
buildNameLabelKey: build.Name,
},
Labels: labels,
},
Spec: corev1.PodSpec{
// If the build fails, don't restart it.
Expand Down

0 comments on commit 326da2d

Please sign in to comment.