Skip to content

Commit

Permalink
Merge pull request #13 from uselagoon/feature/fix-secret-delete
Browse files Browse the repository at this point in the history
Feature/fix secret delete
  • Loading branch information
bomoko authored Oct 18, 2023
2 parents 6faf645 + adeb29b commit 843696d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions controllers/namespace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ func (r *NamespaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
// let's verify this to make sure it looks good
if val, ok := v.Data["INSIGHTS_TOKEN"]; ok {
namespaceDetails, err := tokens.ValidateAndExtractNamespaceDetailsFromToken(r.InsightsJWTSecret, string(val))

if err != nil {
log.Error(err, "Unable to decode token")
return ctrl.Result{}, err
// If we can't validate this secret, we should really just recreate it
deleteSecretMessage = fmt.Sprintf("Token is invalid - namespaces '%v'!='%v'.", ns.GetName(), namespaceDetails.Namespace)
}
if namespaceDetails.Namespace != ns.GetName() {
if deleteSecretMessage != "" && namespaceDetails.Namespace != ns.GetName() {
deleteSecretMessage = fmt.Sprintf("Token is invalid - namespaces '%v'!='%v'.", ns.GetName(), namespaceDetails.Namespace)
} else {
foundItem = true
}
foundItem = true
} else {
//we delete this secret straight
deleteSecretMessage = "key INSIGHTS_TOKEN does not exist. Secret is invalid."
Expand Down

0 comments on commit 843696d

Please sign in to comment.