feat(cas-backends): When updating CAS Backends events are sent#2415
Merged
javirln merged 5 commits intochainloop-dev:mainfrom Sep 3, 2025
Merged
feat(cas-backends): When updating CAS Backends events are sent#2415javirln merged 5 commits intochainloop-dev:mainfrom
javirln merged 5 commits intochainloop-dev:mainfrom
Conversation
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
javirln
commented
Sep 3, 2025
| Provider string `json:"provider,omitempty"` | ||
| Location string `json:"location,omitempty"` | ||
| Default bool `json:"default,omitempty"` | ||
| Default bool `json:"default"` |
Member
Author
There was a problem hiding this comment.
I've removed all omitempty from the bool fields so they are properly serialized in JSON when stored in the database with the proper value.
| // If credentials were updated, perform validation to check if they work | ||
| // This will properly update validation status and send events | ||
| if credentialsUpdated { | ||
| if err := uc.PerformValidation(ctx, id); err != nil { |
Member
Author
There was a problem hiding this comment.
This part was missing, if we rotate the credentials from the Update, we need to perform a validation to update and send the proper status. The PerformValidation takes care of updating the status of the CAS Backend.
jiparis
approved these changes
Sep 3, 2025
| } | ||
|
|
||
| var secretName string | ||
| credentialsUpdated := false |
Member
There was a problem hiding this comment.
it can be credentialsUpdated := creds != nil, and use it everywhere.
| ID: uuid, | ||
| CASBackendOpts: &CASBackendOpts{ | ||
| SecretName: secretName, Default: defaultB, Description: description, OrgID: orgUUID, | ||
| ValidationStatus: CASBackendValidationOK, |
Member
There was a problem hiding this comment.
I think this was a hack. Thanks for taking care.
Piskoo
approved these changes
Sep 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refines how credential updates and validation status are handled when updating a CAS backend, and standardizes JSON serialization for several event types. The main improvements ensure that validation status is only updated when credentials change, and that event types consistently serialize boolean fields.
Credential update and validation handling:
Updatemethod inCASBackendUseCasenow only updates the validation status if credentials are changed, preserving the previous validation status otherwise. When credentials are updated, validation is performed and the backend is reloaded to reflect the latest status.CredentialsChangedfield in the event payload for CAS backend updates is now set based on whether credentials were actually updated, improving event accuracy.JSON serialization consistency:
Defaultfield inCASBackendBase,CredentialsChangedandPreviousDefaultinCASBackendUpdated, andIsRecoveryinCASBackendStatusChangedare now serialized without theomitemptytag, ensuring these boolean fields are always present in the JSON output. [1] [2] [3]