-
Notifications
You must be signed in to change notification settings - Fork 209
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
Client profiles reconciliation #2243
base: main
Are you sure you want to change the base?
Client profiles reconciliation #2243
Conversation
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.
change name to secrets
|
||
err := ctrl.NewControllerManagedBy(mgr). | ||
For(&corev1.Secret{}). | ||
Named("odigos-pro"). |
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.
nit: consider aligning the name with other files in this component
|
||
type odigosConfigController struct { | ||
client.Client | ||
Scheme *runtime.Scheme |
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.
remove
odigosNs := env.GetCurrentNamespace() | ||
clientTokenConfig := &ClientProConfig{} | ||
|
||
err := r.Client.Get(ctx, client.ObjectKey{Namespace: odigosNs, Name: k8sconsts.OdigosProSecretName}, proSecret) |
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.
move proSecret
one line above the get
delete(odigosDeploymentConfig.Data, "expiry") | ||
delete(odigosDeploymentConfig.Data, "profiles") | ||
|
||
err := client.Update(ctx, odigosDeploymentConfig) |
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.
consider using r.Client
instead of sending the client as function argument
return ctrl.Result{}, fmt.Errorf("failed to parse JWT token: %w", err) | ||
} | ||
if claims, ok := token.Claims.(jwt.MapClaims); ok { | ||
*clientTokenConfig = ClientProConfig{ |
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.
*clientTokenConfig = ClientProConfig{ | |
clientTokenConfig := ClientProConfig{ |
return nil | ||
} | ||
|
||
func (r *odigosConfigController) updateOdigosDeploymentConfigMap(clientConfig *ClientProConfig, odigosDeploymentConfig *corev1.ConfigMap) { |
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 function handleSecretDeletion
is very similar and also calls Update
on the cm. consider aligning them so they both Update the resource or both do not update the resource
Audience: claims["aud"].(string), | ||
// TODO: what time format should be used? | ||
Expiry: time.Unix(int64(claims["exp"].(float64)), 0).UTC().Format("02/01/2006 03:04:05 PM"), | ||
Profiles: toStringSlice(claims["profiles"]), |
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.
you can use strings.Split(claims["profiles"], ",")
for that
odigosDeploymentConfig.Data["expiry"] = clientConfig.Expiry | ||
|
||
if len(clientConfig.Profiles) > 0 { | ||
odigosDeploymentConfig.Data["profiles"] = strings.Join(clientConfig.Profiles, ",") |
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.
you can simply pass the value from the jwt without spliting and joining it
Scheme *runtime.Scheme | ||
} | ||
|
||
type ClientProConfig struct { |
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.
type ClientProConfig struct { | |
type clientProConfig struct { |
Watch over changes in odigos-pro secret and updates odigos-deployment respectively.
TODOs question about implementation in Reconcile function.