Skip to content

Commit

Permalink
Mark Component image repository secret as internal to prevent editing…
Browse files Browse the repository at this point in the history
… it from UI
  • Loading branch information
mmorhun committed Sep 7, 2023
1 parent 75d3928 commit 50e6be6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions controllers/component_image_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,9 @@ func (r *ComponentReconciler) ensureComponentPullSecretRemoteSecret(ctx context.
Name: remoteSecretName,
Namespace: component.Namespace,
Labels: map[string]string{
ApplicationNameLabelName: component.Spec.Application,
ComponentNameLabelName: component.Name,
ApplicationNameLabelName: component.Spec.Application,
ComponentNameLabelName: component.Name,
InternalRemoteSecretLabelName: "true",
},
OwnerReferences: []metav1.OwnerReference{
{
Expand Down
2 changes: 2 additions & 0 deletions controllers/component_image_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ var _ = Describe("Component image controller", func() {
remoteSecret := waitRemoteSecretExist(remoteSecretKey)
Expect(remoteSecret.Labels[ApplicationNameLabelName]).To(Equal(component.Spec.Application))
Expect(remoteSecret.Labels[ComponentNameLabelName]).To(Equal(component.Spec.ComponentName))
Expect(remoteSecret.Labels[InternalRemoteSecretLabelName]).To(Equal("true"))
Expect(remoteSecret.OwnerReferences).To(HaveLen(1))
Expect(remoteSecret.OwnerReferences[0].Name).To(Equal(component.Name))
Expect(remoteSecret.OwnerReferences[0].Kind).To(Equal("Component"))
Expand Down Expand Up @@ -682,6 +683,7 @@ var _ = Describe("Component image controller", func() {
remoteSecret := waitRemoteSecretExist(remoteSecretKey)
Expect(remoteSecret.Labels[ApplicationNameLabelName]).To(Equal(component.Spec.Application))
Expect(remoteSecret.Labels[ComponentNameLabelName]).To(Equal(component.Spec.ComponentName))
Expect(remoteSecret.Labels[InternalRemoteSecretLabelName]).To(Equal("true"))
Expect(remoteSecret.OwnerReferences).To(HaveLen(1))
Expect(remoteSecret.OwnerReferences[0].Name).To(Equal(component.Name))
Expect(remoteSecret.OwnerReferences[0].Kind).To(Equal("Component"))
Expand Down
7 changes: 5 additions & 2 deletions controllers/imagerepository_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import (
)

const (
InternalRemoteSecretLabelName = "appstudio.redhat.com/internal"

ImageRepositoryFinalizer = "appstudio.openshift.io/image-repository"
)

Expand Down Expand Up @@ -503,8 +505,9 @@ func (r *ImageRepositoryReconciler) EnsureRemotePullSecret(ctx context.Context,
Name: remoteSecretName,
Namespace: imageRepository.Namespace,
Labels: map[string]string{
ApplicationNameLabelName: imageRepository.Labels[ApplicationNameLabelName],
ComponentNameLabelName: imageRepository.Labels[ComponentNameLabelName],
ApplicationNameLabelName: imageRepository.Labels[ApplicationNameLabelName],
ComponentNameLabelName: imageRepository.Labels[ComponentNameLabelName],
InternalRemoteSecretLabelName: "true",
},
},
Spec: remotesecretv1beta1.RemoteSecretSpec{
Expand Down
1 change: 1 addition & 0 deletions controllers/imagerepository_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ var _ = Describe("Image repository controller", func() {
remoteSecret := waitRemoteSecretExist(remoteSecretKey)
Expect(remoteSecret.Labels[ApplicationNameLabelName]).To(Equal(defaultComponentApplication))
Expect(remoteSecret.Labels[ComponentNameLabelName]).To(Equal(defaultComponentName))
Expect(remoteSecret.Labels[InternalRemoteSecretLabelName]).To(Equal("true"))
Expect(remoteSecret.OwnerReferences).To(HaveLen(1))
Expect(remoteSecret.OwnerReferences[0].Name).To(Equal(imageRepository.Name))
Expect(remoteSecret.OwnerReferences[0].Kind).To(Equal("ImageRepository"))
Expand Down

0 comments on commit 50e6be6

Please sign in to comment.