-
Notifications
You must be signed in to change notification settings - Fork 36
[WIP] Create new namespace pull secret based on namespace pull robot account #267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
e1e02af to
58b370f
Compare
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]>
58b370f to
b4b1066
Compare
mmorhun
left a comment
There was a problem hiding this 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 |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ForRobotAccount -> FromRobotAccount
| namespaceRobotName, err := r.getNamespaceRobotName(ctx, imageRepository.Namespace) | ||
| if err == nil { |
There was a problem hiding this comment.
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
| if imageRepository.Annotations == nil { | ||
| imageRepository.Annotations = make(map[string]string) | ||
| } | ||
| imageRepository.Annotations[ensureNamespacePullSecretAnnotation] = "false" | ||
|
|
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
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