@@ -29,6 +29,12 @@ import (
2929 "time"
3030
3131 securejoin "github.com/cyphar/filepath-securejoin"
32+ "github.com/fluxcd/pkg/apis/meta"
33+ "github.com/fluxcd/pkg/runtime/events"
34+ "github.com/fluxcd/pkg/runtime/metrics"
35+ "github.com/fluxcd/pkg/runtime/predicates"
36+ "github.com/fluxcd/pkg/untar"
37+ sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
3238 "github.com/go-logr/logr"
3339 apierrors "k8s.io/apimachinery/pkg/api/errors"
3440 apimeta "k8s.io/apimachinery/pkg/api/meta"
@@ -47,16 +53,6 @@ import (
4753 "sigs.k8s.io/controller-runtime/pkg/predicate"
4854 "sigs.k8s.io/controller-runtime/pkg/source"
4955 "sigs.k8s.io/kustomize/api/filesys"
50- "sigs.k8s.io/kustomize/api/konfig"
51- "sigs.k8s.io/kustomize/api/krusty"
52- kustypes "sigs.k8s.io/kustomize/api/types"
53-
54- "github.com/fluxcd/pkg/apis/meta"
55- "github.com/fluxcd/pkg/runtime/events"
56- "github.com/fluxcd/pkg/runtime/metrics"
57- "github.com/fluxcd/pkg/runtime/predicates"
58- "github.com/fluxcd/pkg/untar"
59- sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
6056
6157 kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta1"
6258)
@@ -506,22 +502,9 @@ func (r *KustomizationReconciler) build(kustomization kustomizev1.Kustomization,
506502 }
507503
508504 fs := filesys .MakeFsOnDisk ()
509- manifestsFile := filepath .Join (dirPath , fmt .Sprintf ("%s.yaml" , kustomization .GetUID ()))
510-
511- buildOptions := & krusty.Options {
512- DoLegacyResourceSort : true ,
513- AddManagedbyLabel : false ,
514- LoadRestrictions : kustypes .LoadRestrictionsNone ,
515- DoPrune : false ,
516- PluginConfig : konfig .DisabledPluginConfig (),
517- UseKyaml : false ,
518- AllowResourceIdChanges : false ,
519- }
520-
521- k := krusty .MakeKustomizer (fs , buildOptions )
522- m , err := k .Run (dirPath )
505+ m , err := buildKustomization (fs , dirPath )
523506 if err != nil {
524- return nil , err
507+ return nil , fmt . Errorf ( "kustomize build failed: %w" , err )
525508 }
526509
527510 // check if resources are encrypted and decrypt them before generating the final YAML
@@ -543,9 +526,10 @@ func (r *KustomizationReconciler) build(kustomization kustomizev1.Kustomization,
543526
544527 resources , err := m .AsYaml ()
545528 if err != nil {
546- return nil , err
529+ return nil , fmt . Errorf ( "kustomize build failed: %w" , err )
547530 }
548531
532+ manifestsFile := filepath .Join (dirPath , fmt .Sprintf ("%s.yaml" , kustomization .GetUID ()))
549533 if err := fs .WriteFile (manifestsFile , resources ); err != nil {
550534 return nil , err
551535 }
0 commit comments