Skip to content

Commit d9f9a51

Browse files
committed
Fix names/doc in transformation config code.
1 parent 111f417 commit d9f9a51

27 files changed

+475
-305
lines changed

internal/k8sdeps/transformer/hash/namehash.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import (
2424
"sigs.k8s.io/kustomize/pkg/transformers"
2525
)
2626

27-
// nameHashTransformer contains the prefix and the path config for each field that
28-
// the name prefix will be applied.
2927
type nameHashTransformer struct{}
3028

3129
var _ transformers.Transformer = &nameHashTransformer{}

pkg/commands/misc/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (o *saveOptions) Complete(fsys fs.FileSystem) error {
102102

103103
// RunSave saves the default transformer configurations local directory
104104
func (o *saveOptions) RunSave(fsys fs.FileSystem) error {
105-
m := defaultconfig.GetDefaultPathConfigStrings()
105+
m := defaultconfig.GetDefaultFieldSpecsAsMap()
106106
for tname, tcfg := range m {
107107
filename := filepath.Join(o.saveDirectory, tname+".yaml")
108108
err := fsys.WriteFile(filename, []byte(tcfg))

pkg/target/kusttarget.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ func (kt *KustTarget) loadCustomizedResMap() (resmap.ResMap, error) {
132132
if err != nil {
133133
errs.Append(errors.Wrap(err, "loadResMapFromBasesAndResources"))
134134
}
135-
crdPathConfigs, err := config.NewFactory(kt.ldr).LoadCRDs(kt.kustomization.Crds)
136-
kt.tcfg = kt.tcfg.Merge(crdPathConfigs)
135+
crdTc, err := config.NewFactory(kt.ldr).LoadCRDs(kt.kustomization.Crds)
136+
kt.tcfg = kt.tcfg.Merge(crdTc)
137137
if err != nil {
138138
errs.Append(errors.Wrap(err, "LoadCRDs"))
139139
}

pkg/transformers/config/defaultconfig/commonannotations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
package defaultconfig
1818

19-
const commonAnnotationPathConfigs = `
19+
const commonAnnotationFieldSpecs = `
2020
commonAnnotations:
2121
- path: metadata/annotations
2222
create: true

pkg/transformers/config/defaultconfig/commonlabels.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
package defaultconfig
1818

19-
const commonLabelPathConfigs = `
19+
const commonLabelFieldSpecs = `
2020
commonLabels:
2121
- path: metadata/labels
2222
create: true

pkg/transformers/config/defaultconfig/defaultconfig.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,28 @@ import (
2222
"bytes"
2323
)
2424

25-
// GetDefaultPathConfigs returns the default pathConfigs data
26-
func GetDefaultPathConfigs() []byte {
25+
// GetDefaultFieldSpecs returns default fieldSpecs.
26+
func GetDefaultFieldSpecs() []byte {
2727
configData := [][]byte{
28-
[]byte(namePrefixPathConfigs),
29-
[]byte(commonLabelPathConfigs),
30-
[]byte(commonAnnotationPathConfigs),
31-
[]byte(namespacePathConfigs),
32-
[]byte(varReferencePathConfigs),
33-
[]byte(nameReferencePathConfigs),
28+
[]byte(namePrefixFieldSpecs),
29+
[]byte(commonLabelFieldSpecs),
30+
[]byte(commonAnnotationFieldSpecs),
31+
[]byte(namespaceFieldSpecs),
32+
[]byte(varReferenceFieldSpecs),
33+
[]byte(nameReferenceFieldSpecs),
3434
}
3535
return bytes.Join(configData, []byte("\n"))
3636
}
3737

38-
// GetDefaultPathConfigStrings returns the default pathConfigs in string format
39-
func GetDefaultPathConfigStrings() map[string]string {
38+
// GetDefaultFieldSpecsAsMap returns default fieldSpecs
39+
// as a string->string map.
40+
func GetDefaultFieldSpecsAsMap() map[string]string {
4041
result := make(map[string]string)
41-
result["nameprefix"] = namePrefixPathConfigs
42-
result["commonlabels"] = commonLabelPathConfigs
43-
result["commonannotations"] = commonAnnotationPathConfigs
44-
result["namespace"] = namespacePathConfigs
45-
result["varreference"] = varReferencePathConfigs
46-
result["namereference"] = namespacePathConfigs
42+
result["nameprefix"] = namePrefixFieldSpecs
43+
result["commonlabels"] = commonLabelFieldSpecs
44+
result["commonannotations"] = commonAnnotationFieldSpecs
45+
result["namespace"] = namespaceFieldSpecs
46+
result["varreference"] = varReferenceFieldSpecs
47+
result["namereference"] = nameReferenceFieldSpecs
4748
return result
4849
}

pkg/transformers/config/defaultconfig/nameprefix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
package defaultconfig
1818

1919
const (
20-
namePrefixPathConfigs = `
20+
namePrefixFieldSpecs = `
2121
namePrefix:
2222
- path: metadata/name
2323
`

pkg/transformers/config/defaultconfig/namereference.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,26 @@ limitations under the License.
1717
package defaultconfig
1818

1919
const (
20-
nameReferencePathConfigs = `
20+
nameReferenceFieldSpecs = `
2121
nameReference:
2222
- kind: Deployment
23-
pathConfigs:
23+
fieldSpecs:
2424
- path: spec/scaleTargetRef/name
2525
kind: HorizontalPodAutoscaler
2626
2727
- kind: ReplicationController
28-
pathConfigs:
28+
fieldSpecs:
2929
- path: spec/scaleTargetRef/name
3030
kind: HorizontalPodAutoscaler
3131
3232
- kind: ReplicaSet
33-
pathConfigs:
33+
fieldSpecs:
3434
- path: spec/scaleTargetRef/name
3535
kind: HorizontalPodAutoscaler
3636
3737
- kind: ConfigMap
3838
version: v1
39-
pathConfigs:
39+
fieldSpecs:
4040
- path: spec/volumes/configMap/name
4141
version: v1
4242
kind: Pod
@@ -119,7 +119,7 @@ nameReference:
119119
120120
- kind: Secret
121121
version: v1
122-
pathConfigs:
122+
fieldSpecs:
123123
- path: spec/volumes/secret/secretName
124124
version: v1
125125
kind: Pod
@@ -229,7 +229,7 @@ nameReference:
229229
230230
- kind: Service
231231
version: v1
232-
pathConfigs:
232+
fieldSpecs:
233233
- path: spec/serviceName
234234
kind: StatefulSet
235235
group: apps
@@ -240,14 +240,14 @@ nameReference:
240240
241241
- kind: Role
242242
group: rbac.authorization.k8s.io
243-
pathConfigs:
243+
fieldSpecs:
244244
- path: roleRef/name
245245
kind: RoleBinding
246246
group: rbac.authorization.k8s.io
247247
248248
- kind: ClusterRole
249249
group: rbac.authorization.k8s.io
250-
pathConfigs:
250+
fieldSpecs:
251251
- path: roleRef/name
252252
kind: RoleBinding
253253
group: rbac.authorization.k8s.io
@@ -257,7 +257,7 @@ nameReference:
257257
258258
- kind: ServiceAccount
259259
version: v1
260-
pathConfigs:
260+
fieldSpecs:
261261
- path: subjects/name
262262
kind: RoleBinding
263263
group: rbac.authorization.k8s.io
@@ -281,7 +281,7 @@ nameReference:
281281
282282
- kind: PersistentVolumeClaim
283283
version: v1
284-
pathConfigs:
284+
fieldSpecs:
285285
- path: spec/volumes/persistentVolumeClaim/claimName
286286
kind: Pod
287287
- path: spec/template/spec/volumes/persistentVolumeClaim/claimName
@@ -299,7 +299,7 @@ nameReference:
299299
300300
- kind: PersistentVolume
301301
version: v1
302-
pathConfigs:
302+
fieldSpecs:
303303
- path: spec/volumeName
304304
kind: PersistentVolumeClaim
305305
`

pkg/transformers/config/defaultconfig/namespace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
package defaultconfig
1818

1919
const (
20-
namespacePathConfigs = `
20+
namespaceFieldSpecs = `
2121
namespace:
2222
- path: metadata/namespace
2323
create: true

pkg/transformers/config/defaultconfig/varreference.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
package defaultconfig
1818

1919
const (
20-
varReferencePathConfigs = `
20+
varReferenceFieldSpecs = `
2121
varReference:
2222
- path: spec/template/spec/initContainers/command
2323
kind: StatefulSet

0 commit comments

Comments
 (0)