Skip to content
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

[FE]: Add the associated RemoteUserBinding in the status of the RemoteUser #48

Open
damsien opened this issue Dec 23, 2024 · 0 comments
Labels
enhancement Request for enhancement

Comments

@damsien
Copy link
Collaborator

damsien commented Dec 23, 2024

Roadmap 2025/02 Add the associated RemoteUserBinding in the status of the RemoteUser.
As the developer of my team, I want to see the RemoteUserBindings that are associated to my RemoteUser.

What to do

1. Add the status.remoteUserBindings field

Add this field her in order to use it later:

type RemoteUserStatus struct {
// +listType=map
// +listMapKey=type
// +patchStrategy=merge
// +patchMergeKey=type
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
// +optional
ConnexionStatus RemoteUserConnexionStatus `json:"connexionStatus,omitempty"`
// +optional
GitUser string `json:"gitUser,omitempty"`
// +optional
LastAuthTime metav1.Time `json:"lastAuthTime,omitempty"`
// +optional
SecretBoundStatus SecretBoundStatus `json:"secretBoundStatus,omitempty"`
}

The field is a list of RemoteUserBindings.

2. Set the RemoteUser status from the RemoteUserBinding controller

We already loop over each associated RemoteUsers in the remoteuserbinding-controller. Inside this loop, we already Get() the RemoteUser. For each of these remoteusers, loop over the status.remoteUserBindings field. If the current remoteuserbinding is already present, skip the loop. Otherwise, add it to the list.

} else {
gitUserHost.GitFQDN = remoteUser.Spec.GitBaseDomainFQDN
gitUserHost.SecretRef = remoteUser.Spec.SecretRef
gitUserHost.State = syngit.Bound
r.Recorder.Event(&remoteUserBinding, "Normal", "Bound", gitUserHost.RemoteUserUsed+" bound")
isGloballyBound = true
}

3. Unset the RemoteUser status when the the RemoteUserBinding is deleted

Same as the previous step, but remove the current remoteuserbinding if already exists. The loop does not exist yet, you need to create it.

if err := r.Get(ctx, req.NamespacedName, &remoteUserBinding); err != nil {
// does not exists -> deleted
return ctrl.Result{}, client.IgnoreNotFound(err)
}

Additional context

If you have any questions, please tag @damsien.

@damsien damsien added the enhancement Request for enhancement label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Request for enhancement
Projects
None yet
Development

No branches or pull requests

1 participant