Skip to content

Commit

Permalink
Merge pull request #739 from fluxcd/refactor-decryptor
Browse files Browse the repository at this point in the history
Refactor: Extract decrytor to internal package
  • Loading branch information
stefanprodan committed Oct 7, 2022
2 parents 5c8aa7a + 06ce60f commit 99b2eae
Show file tree
Hide file tree
Showing 6 changed files with 1,746 additions and 1,594 deletions.
5 changes: 3 additions & 2 deletions controllers/kustomization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import (
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"

kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta2"
"github.com/fluxcd/kustomize-controller/internal/decryptor"
)

// +kubebuilder:rbac:groups=kustomize.toolkit.fluxcd.io,resources=kustomizations,verbs=get;list;watch;create;update;patch;delete
Expand Down Expand Up @@ -597,7 +598,7 @@ func (r *KustomizationReconciler) generate(kustomization kustomizev1.Kustomizati
}

func (r *KustomizationReconciler) build(ctx context.Context, workDir string, kustomization kustomizev1.Kustomization, dirPath string) ([]byte, error) {
dec, cleanup, err := NewTempDecryptor(workDir, r.Client, kustomization)
dec, cleanup, err := decryptor.NewTempDecryptor(workDir, r.Client, kustomization)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -728,7 +729,7 @@ func (r *KustomizationReconciler) apply(ctx context.Context, manager *ssa.Resour
resultSet := ssa.NewChangeSet()

for _, u := range objects {
if IsEncryptedSecret(u) {
if decryptor.IsEncryptedSecret(u) {
return false, nil,
fmt.Errorf("%s is SOPS encrypted, configuring decryption is required for this secret to be reconciled",
ssa.FmtUnstructured(u))
Expand Down
Loading

0 comments on commit 99b2eae

Please sign in to comment.