Skip to content

Conversation

@rcerven
Copy link
Contributor

@rcerven rcerven commented Dec 23, 2025

which is granted read permisssions for all ImageRepositories in the namespace,
namespace pull secret is also linked to component build SA and integration SA,
new annotation
'image-controller.appstudio.redhat.com/ensure-namespace-pull-secret' is introduced as well, which is set to 'false' after namespace pull secret is created,
when set to 'true' it will force to create namespace pull robot account and namespace secret,
component linking check is based now only on component label, as new model won't have anymore application

STONEBLD-4018

@rcerven rcerven requested a review from a team as a code owner December 23, 2025 17:56
@snyk-io
Copy link

snyk-io bot commented Dec 23, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@rcerven rcerven force-pushed the namespacerobot branch 2 times, most recently from e1e02af to 58b370f Compare December 23, 2025 18:27
which is granted read permisssions for all ImageRepositories in the namespace,
namespace pull secret is also linked to component build SA and integration SA,
new annotation 'image-controller.appstudio.redhat.com/ensure-namespace-pull-secret' is
introduced as well, which is set to 'false' after namespace pull secret is created,
when set to 'true' it will force to create namespace pull robot account and namespace secret,
component linking check is based now only on component label, as new model won't have anymore application

STONEBLD-4018

Signed-off-by: Robert Cerven <[email protected]>
Copy link
Member

@mmorhun mmorhun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general, a few remarks below.

}

// udateServiceAccountWithApplicationPullSecret updates the ServiceAccount to include
// updateServiceAccountWithApplicationPullSecret updates the ServiceAccount to include
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is misleading and unclear.
What about updateIntegrationServiceAccountWithNamespacePullSecret?
But then why it happens in the application controller? Do we need to even have this controller?

deleteImageRepository(imageRepositoryName)
})

It("should do image repository provision, component doesn't have application", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: I'd replace , with when

"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"

appstudioapiv1alpha1 "github.com/konflux-ci/application-api/api/v1alpha1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep appstudio now?

CreateRobotAccount(organization string, robotName string) (*RobotAccount, error)
DeleteRobotAccount(organization string, robotName string) (bool, error)
AddPermissionsForRepositoryToAccount(organization, imageRepository, accountName string, isRobot, isWrite bool) error
RemovePermissionsToRepositoryForAccount(organization, imageRepository, accountName string, isRobot bool) error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think RemovePermissionsForRepositoryFromAccount would be consistent with other method names.

}
}

func TestRemovePermissionsForRobotAccount(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ForRobotAccount -> FromRobotAccount

Comment on lines +177 to +178
namespaceRobotName, err := r.getNamespaceRobotName(ctx, imageRepository.Namespace)
if err == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: can be one line

Comment on lines +606 to +610
if imageRepository.Annotations == nil {
imageRepository.Annotations = make(map[string]string)
}
imageRepository.Annotations[ensureNamespacePullSecretAnnotation] = "false"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this? Does it make sense to assume that missing annotation is the same as false?

log := ctrllog.FromContext(ctx).WithName("RegenerateNamespaceRobotAccessToken")
ctx = ctrllog.IntoContext(ctx, log)

quayImageURL := fmt.Sprintf("quay.io/%s/%s", r.QuayOrganization, imageRepository.Namespace)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: does it make sense to move it closer to the usage below?

hostnameParts := strings.Split(hostname, ".")
hostnameLen := len(hostnameParts)

if hostnameLen < 4 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An example and / or a comment would be nice to have here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants