mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-08 00:37:27 +00:00
handle secret types properly while masking sops data
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
This commit is contained in:
parent
e25bb74c05
commit
5c9cbe676d
1 changed files with 6 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ import (
|
|||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
|
|
@ -343,7 +344,11 @@ func maskSopsData(res *resource.Resource) error {
|
|||
res.PipeE(yaml.FieldClearer{Name: "sops"})
|
||||
|
||||
secretType, err := res.GetFieldValue(typeField)
|
||||
if err != nil {
|
||||
// If the intented type is Opaque, then it can be omitted from the manifest, since it's the default
|
||||
// Ref: https://kubernetes.io/docs/concepts/configuration/secret/#opaque-secrets
|
||||
if errors.As(err, &yaml.NoFieldError{}) {
|
||||
secretType = "Opaque"
|
||||
} else if err != nil {
|
||||
return fmt.Errorf("failed to mask secret %s sops data: %w", res.GetName(), err)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue