Skip to content
This repository has been archived by the owner on Nov 28, 2024. It is now read-only.

Commit

Permalink
fix: using labels instead of annotations for finding project namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Skarlso committed Oct 26, 2023
1 parent b04fdbe commit 8f2ba0f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions controllers/get_project_in_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
"fmt"

"github.com/open-component-model/mpas-project-controller/api/v1alpha1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/open-component-model/mpas-project-controller/api/v1alpha1"
)

// GetProjectFromObjectNamespace returns the Project from the annotation of the current namespace that an object
Expand All @@ -19,7 +20,7 @@ func GetProjectFromObjectNamespace(ctx context.Context, c client.Client, obj cli
return nil, fmt.Errorf("failed to retrieve namespace for object: %w", err)
}

v, ok := ns.Annotations[v1alpha1.ProjectKey]
v, ok := ns.Labels[v1alpha1.ProjectKey]
if !ok {
return nil, fmt.Errorf("project key %s not found on namespace", v1alpha1.ProjectKey)
}
Expand Down
4 changes: 2 additions & 2 deletions controllers/productdeploymentgenerator_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestProductDeploymentGeneratorReconciler(t *testing.T) {
testNamespace := &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: "test-namespace",
Annotations: map[string]string{
Labels: map[string]string{
projectv1.ProjectKey: "project",
},
},
Expand Down Expand Up @@ -266,7 +266,7 @@ func TestProductDeploymentGeneratorReconcilerWithValueFile(t *testing.T) {
testNamespace := &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: "test-namespace",
Annotations: map[string]string{
Labels: map[string]string{
projectv1.ProjectKey: "project",
},
},
Expand Down
2 changes: 1 addition & 1 deletion controllers/productdeploymentpipeline_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestProductDeploymentPipelineReconciler(t *testing.T) {
testNamespace := &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: "test-namespace",
Annotations: map[string]string{
Labels: map[string]string{
projectv1.ProjectKey: "project",
},
},
Expand Down
4 changes: 2 additions & 2 deletions controllers/validation_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestBasicReconcile(t *testing.T) {
testNamespace := &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: "test-namespace",
Annotations: map[string]string{
Labels: map[string]string{
projectv1.ProjectKey: "project",
},
},
Expand Down Expand Up @@ -194,7 +194,7 @@ func TestRemovingGitRepositoryWhenPullRequestIsMerged(t *testing.T) {
testNamespace := &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: "test-namespace",
Annotations: map[string]string{
Labels: map[string]string{
projectv1.ProjectKey: "project",
},
},
Expand Down

0 comments on commit 8f2ba0f

Please sign in to comment.