@@ -29,6 +29,12 @@ import (
29
29
"time"
30
30
31
31
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"
32
38
"github.com/go-logr/logr"
33
39
apierrors "k8s.io/apimachinery/pkg/api/errors"
34
40
apimeta "k8s.io/apimachinery/pkg/api/meta"
@@ -47,16 +53,6 @@ import (
47
53
"sigs.k8s.io/controller-runtime/pkg/predicate"
48
54
"sigs.k8s.io/controller-runtime/pkg/source"
49
55
"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"
60
56
61
57
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta1"
62
58
)
@@ -506,22 +502,9 @@ func (r *KustomizationReconciler) build(kustomization kustomizev1.Kustomization,
506
502
}
507
503
508
504
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 )
523
506
if err != nil {
524
- return nil , err
507
+ return nil , fmt . Errorf ( "kustomize build failed: %w" , err )
525
508
}
526
509
527
510
// check if resources are encrypted and decrypt them before generating the final YAML
@@ -543,9 +526,10 @@ func (r *KustomizationReconciler) build(kustomization kustomizev1.Kustomization,
543
526
544
527
resources , err := m .AsYaml ()
545
528
if err != nil {
546
- return nil , err
529
+ return nil , fmt . Errorf ( "kustomize build failed: %w" , err )
547
530
}
548
531
532
+ manifestsFile := filepath .Join (dirPath , fmt .Sprintf ("%s.yaml" , kustomization .GetUID ()))
549
533
if err := fs .WriteFile (manifestsFile , resources ); err != nil {
550
534
return nil , err
551
535
}
0 commit comments