Feat/add validations to external secret data from remote ref#2962
Conversation
Signed-off-by: Lucas Pimentel <luk.2001@hotmail.com>
…oteRef Signed-off-by: Lucas Pimentel <luk.2001@hotmail.com>
|
There was a problem hiding this comment.
Thank you for your PR, @LucasPimentel123 🙂 I've left some comments, so please take a look at them! Also, some of the jobs failed, so would you resolve them as well?
| errs = errors.Join(errs, fmt.Errorf("generator must be set if SourceRef is used")) | ||
| } | ||
|
|
||
| if !findOrExtract && (ref.SourceRef != nil || ref.SourceRef.GeneratorRef != nil) { |
There was a problem hiding this comment.
This condition seems to be wrong. It should be
!findOrExtract && (ref.SourceRef == nil || ref.SourceRef.GeneratorRef == nil)
Also, I found that !findOrExtract is hard to understand. Why don't we just use the following condition?
ref.Find == nil && ref.Extract == nil && (ref.SourceRef == nil || ref.SourceRef.GeneratorRef == nil)
There was a problem hiding this comment.
Would you add test cases to cover the four cases?
| } | ||
|
|
||
| if !findOrExtract && (ref.SourceRef != nil || ref.SourceRef.GeneratorRef != nil) { | ||
| errs = errors.Join(errs, fmt.Errorf("either find, extract or source and generator must be set")) |
There was a problem hiding this comment.
| errs = errors.Join(errs, fmt.Errorf("either find, extract or source and generator must be set")) | |
| errs = errors.Join(errs, fmt.Errorf("either extract, find, or sourceRef with generatorRef must be set to dataFrom")) |
| } | ||
|
|
||
| if ref.SourceRef != nil && ref.SourceRef.GeneratorRef == nil { | ||
| errs = errors.Join(errs, fmt.Errorf("generator must be set if SourceRef is used")) |
There was a problem hiding this comment.
| errs = errors.Join(errs, fmt.Errorf("generator must be set if SourceRef is used")) | |
| errs = errors.Join(errs, fmt.Errorf("generatorRef cannot be empty when using sourceRef in dataFrom")) |
|
Hi @LucasPimentel123 👋 Are you still working on this PR? |
|
Hi @LucasPimentel123 ! Are you still working on this PR? |
|
I will take it over from here |
|
Closing in favor of #3390 |



Problem Statement
Currently, there are no validations on the ExternalSecretDataFromRemoteRef, but it should
Related Issue
Relates to #2916
Proposed Changes
I added the validations on the validateExternalSecret function
Checklist
git commit --signoffmake testmake reviewable