@@ -21,7 +21,6 @@ import (
21
21
"encoding/json"
22
22
"fmt"
23
23
"reflect"
24
- "strings"
25
24
"sync"
26
25
27
26
"k8s.io/apimachinery/pkg/api/meta"
@@ -71,7 +70,7 @@ type ApplySet struct {
71
70
// deployment manifests.
72
71
parent Parent
73
72
// If not given, the tooling value will be the `Parent` Kind.
74
- tooling kubectlapply. ApplySetTooling
73
+ tooling string
75
74
}
76
75
77
76
// Options holds the parameters for building an ApplySet.
@@ -94,16 +93,7 @@ type Options struct {
94
93
func New (options Options ) (* ApplySet , error ) {
95
94
parent := options .Parent
96
95
parentRef := & kubectlapply.ApplySetParentRef {Name : parent .Name (), Namespace : parent .Namespace (), RESTMapping : parent .RESTMapping ()}
97
-
98
- // The tooling string slash cutting is to support the ApplySetTooling struct that kubectlapply.NewApplySet() expects.
99
- // For instance, 'kpt/v1.0.0' will map to ApplySetTooling{Name: "kpt", Version: "v1.0.0"}.
100
- toolName , toolVersion , _ := strings .Cut (options .Tooling , "/" )
101
- if toolName == "" {
102
- toolName = parent .GetSubject ().GetObjectKind ().GroupVersionKind ().Kind
103
- }
104
- tooling := kubectlapply.ApplySetTooling {Name : toolName , Version : toolVersion }
105
-
106
- kapplyset := kubectlapply .NewApplySet (parentRef , tooling , options .RESTMapper )
96
+ kapplyset := kubectlapply .NewApplySet (parentRef , kubectlapply.ApplySetTooling {Name : options .Tooling }, options .RESTMapper )
107
97
if options .PatchOptions .FieldManager == "" {
108
98
options .PatchOptions .FieldManager = kapplyset .FieldManager ()
109
99
}
@@ -115,7 +105,7 @@ func New(options Options) (*ApplySet, error) {
115
105
deleteOptions : options .DeleteOptions ,
116
106
prune : options .Prune ,
117
107
parent : parent ,
118
- tooling : tooling ,
108
+ tooling : options . Tooling ,
119
109
}
120
110
a .trackers = & objectTrackerList {}
121
111
return a , nil
@@ -159,7 +149,7 @@ func (a *ApplySet) ApplyOnce(ctx context.Context) (*ApplyResults, error) {
159
149
// single actuation and not for reconciliation.
160
150
// Note: The Kubectl ApplySet will share the RESTMapper with k-d-p/ApplySet, which caches all the manifests in the past.
161
151
parentRef := & kubectlapply.ApplySetParentRef {Name : a .parent .Name (), Namespace : a .parent .Namespace (), RESTMapping : a .parent .RESTMapping ()}
162
- kapplyset := kubectlapply .NewApplySet (parentRef , a .tooling , a .restMapper )
152
+ kapplyset := kubectlapply .NewApplySet (parentRef , kubectlapply. ApplySetTooling { Name : a .tooling } , a .restMapper )
163
153
164
154
// Cache the current RESTMappings to avoid re-fetching the bad ones.
165
155
restMappings := make (map [schema.GroupVersionKind ]restMappingResult )
@@ -375,7 +365,7 @@ func (a *ApplySet) WithParent(ctx context.Context, kapplyset *kubectlapply.Apply
375
365
if annotations == nil {
376
366
annotations = make (map [string ]string )
377
367
}
378
- annotations [kubectlapply .ApplySetToolingAnnotation ] = a .tooling . String ()
368
+ annotations [kubectlapply .ApplySetToolingAnnotation ] = a .tooling
379
369
if _ , ok := annotations [kubectlapply .ApplySetGRsAnnotation ]; ! ok {
380
370
annotations [kubectlapply .ApplySetGRsAnnotation ] = ""
381
371
}
0 commit comments