Skip to content

Commit

Permalink
Merge pull request #5493 from php-coder/gh4810_namespaced_build_confg
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Oct 30, 2015
2 parents 0aae762 + 9dff7b1 commit 27c0ca8
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions pkg/api/graph/graphview/veneering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func TestGraph(t *testing.T) {
{
ObjectMeta: kapi.ObjectMeta{
Name: "build1-1-abc",
Labels: map[string]string{buildapi.BuildConfigLabel: "build1"},
Labels: map[string]string{buildapi.DeprecatedBuildConfigLabel: "build1"},
CreationTimestamp: unversioned.NewTime(now.Add(-10 * time.Second)),
},
Status: buildapi.BuildStatus{
Expand All @@ -172,7 +172,7 @@ func TestGraph(t *testing.T) {
{
ObjectMeta: kapi.ObjectMeta{
Name: "build1-2-abc",
Labels: map[string]string{buildapi.BuildConfigLabel: "build1"},
Labels: map[string]string{buildapi.DeprecatedBuildConfigLabel: "build1"},
CreationTimestamp: unversioned.NewTime(now.Add(-5 * time.Second)),
},
Status: buildapi.BuildStatus{
Expand All @@ -182,7 +182,7 @@ func TestGraph(t *testing.T) {
{
ObjectMeta: kapi.ObjectMeta{
Name: "build1-3-abc",
Labels: map[string]string{buildapi.BuildConfigLabel: "build1"},
Labels: map[string]string{buildapi.DeprecatedBuildConfigLabel: "build1"},
CreationTimestamp: unversioned.NewTime(now.Add(-15 * time.Second)),
},
Status: buildapi.BuildStatus{
Expand Down
11 changes: 8 additions & 3 deletions pkg/build/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,14 @@ type BuildOutput struct {
PushSecret *kapi.LocalObjectReference
}

// BuildConfigLabel is the key of a Build label whose value is the ID of a BuildConfig
// on which the Build is based.
const BuildConfigLabel = "buildconfig"
const (
// BuildConfigLabel is the key of a Build label whose value is the ID of a BuildConfig
// on which the Build is based.
BuildConfigLabel = "openshift.io/build-config.name"
// DeprecatedBuildConfigLabel was used as BuildConfigLabel before adding namespaces.
// We keep it for backward compatibility.
DeprecatedBuildConfigLabel = "buildconfig"
)

// BuildConfig is a template which can be used to create new builds.
type BuildConfig struct {
Expand Down
4 changes: 0 additions & 4 deletions pkg/build/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,6 @@ type BuildOutput struct {
PushSecret *kapi.LocalObjectReference `json:"pushSecret,omitempty" description:"supported type: dockercfg"`
}

// BuildConfigLabel is the key of a Build label whose value is the ID of a BuildConfig
// on which the Build is based.
const BuildConfigLabel = "buildconfig"

// BuildConfig is a template which can be used to create new builds.
type BuildConfig struct {
unversioned.TypeMeta `json:",inline"`
Expand Down
4 changes: 0 additions & 4 deletions pkg/build/api/v1beta3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,6 @@ type BuildOutput struct {
PushSecret *kapi.LocalObjectReference `json:"pushSecret,omitempty" description:"supported type: dockercfg"`
}

// BuildConfigLabel is the key of a Build label whose value is the ID of a BuildConfig
// on which the Build is based.
const BuildConfigLabel = "buildconfig"

// BuildConfig is a template which can be used to create new builds.
type BuildConfig struct {
unversioned.TypeMeta `json:",inline"`
Expand Down
1 change: 1 addition & 0 deletions pkg/build/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ func (g *BuildGenerator) generateBuildFromConfig(ctx kapi.Context, bc *buildapi.
if build.Labels == nil {
build.Labels = make(map[string]string)
}
build.Labels[buildapi.DeprecatedBuildConfigLabel] = bcCopy.Name
build.Labels[buildapi.BuildConfigLabel] = bcCopy.Name

builderSecrets, err := g.FetchServiceAccountSecrets(bc.Namespace, serviceAccount)
Expand Down
3 changes: 3 additions & 0 deletions pkg/build/generator/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,9 @@ func TestGenerateBuildFromConfig(t *testing.T) {
if build.Labels[buildapi.BuildConfigLabel] != bc.Name {
t.Errorf("Build does not contain labels from BuildConfig")
}
if build.Labels[buildapi.DeprecatedBuildConfigLabel] != bc.Name {
t.Errorf("Build does not contain labels from BuildConfig")
}
if build.Status.Config.Name != bc.Name || build.Status.Config.Namespace != bc.Namespace || build.Status.Config.Kind != "BuildConfig" {
t.Errorf("Build does not contain correct BuildConfig reference: %v", build.Status.Config)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/build/graph/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func belongsToBuildConfig(config *buildapi.BuildConfig, b *buildapi.Build) bool
if b.Labels == nil {
return false
}
if b.Labels[buildapi.BuildConfigLabel] == config.Name {
if b.Labels[buildapi.DeprecatedBuildConfigLabel] == config.Name {
return true
}
return false
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cli/describe/describer.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func (d *BuildConfigDescriber) Describe(namespace, name string) (string, error)
if err != nil {
return "", err
}
buildList, err := d.Builds(namespace).List(labels.SelectorFromSet(labels.Set{buildapi.BuildConfigLabel: name}), fields.Everything())
buildList, err := d.Builds(namespace).List(labels.SelectorFromSet(labels.Set{buildapi.DeprecatedBuildConfigLabel: name}), fields.Everything())
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/util/clientcmd/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func NewFactory(clientConfig kclientcmd.ClientConfig) *Factory {
if !ok {
return nil, errors.New("provided options object is not a BuildLogOptions")
}
buildsForBCSelector := labels.SelectorFromSet(map[string]string{buildapi.BuildConfigLabel: t.Name})
buildsForBCSelector := labels.SelectorFromSet(map[string]string{buildapi.DeprecatedBuildConfigLabel: t.Name})
builds, err := oc.Builds(t.Namespace).List(buildsForBCSelector, fields.Everything())
if err != nil {
return nil, err
Expand Down

0 comments on commit 27c0ca8

Please sign in to comment.