Skip to content

Commit 594aaee

Browse files
committed
fix for failing tests
1 parent 17d5c26 commit 594aaee

File tree

4 files changed

+17
-34
lines changed

4 files changed

+17
-34
lines changed

api/krusty/complexcomposition_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ apiVersion: builtin
8181
kind: PatchTransformer
8282
metadata:
8383
name: svcNameTran
84-
target:
84+
target:
8585
group: apps
8686
version: v1
8787
kind: StatefulSet
@@ -153,7 +153,7 @@ apiVersion: builtin
153153
kind: PatchTransformer
154154
metadata:
155155
name: envFromConfigTrans
156-
target:
156+
target:
157157
group: apps
158158
version: v1
159159
kind: StatefulSet
@@ -213,7 +213,7 @@ apiVersion: builtin
213213
kind: PatchTransformer
214214
metadata:
215215
name: tolTrans
216-
target:
216+
target:
217217
group: apps
218218
version: v1
219219
kind: StatefulSet
@@ -264,7 +264,7 @@ apiVersion: builtin
264264
kind: PatchTransformer
265265
metadata:
266266
name: storageTrans
267-
target:
267+
target:
268268
group: apps
269269
version: v1
270270
kind: StatefulSet
@@ -365,10 +365,10 @@ resources:
365365
`)
366366
err := th.RunWithErr("dev", th.MakeDefaultOptions())
367367
if err == nil {
368-
t.Fatalf("Expected resource accumulation error")
368+
t.Fatalf("Expected resource accumulation error:\n%s\n", th.Run("dev", th.MakeDefaultOptions()))
369369
}
370-
if !strings.Contains(
371-
err.Error(), "already registered id: StatefulSet.v1.apps/my-sts.[noNs]") {
370+
if !strings.Contains(err.Error(),
371+
`resid.ResId{Gvk:resid.Gvk{Group:"apps", Version:"v1", Kind:"StatefulSet", isClusterScoped:false}, Name:"my-sts", Namespace:""} exists`) {
372372
t.Fatalf("Unexpected err: %v", err)
373373
}
374374
}
@@ -459,7 +459,7 @@ resources:
459459
t.Fatalf("Expected resource accumulation error")
460460
}
461461
if !strings.Contains(
462-
err.Error(), "already registered id: StatefulSet.v1.apps/my-sts.[noNs]") {
462+
err.Error(), `id resid.ResId{Gvk:resid.Gvk{Group:"apps", Version:"v1", Kind:"StatefulSet", isClusterScoped:false}, Name:"my-sts", Namespace:""} exists`) {
463463
t.Fatalf("Unexpected err: %v", err)
464464
}
465465
}

api/krusty/component_test.go

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ spec:
380380
`,
381381
},
382382
// See how nameSuffix "-b" is also added to the resources included by "comp-a" because they are in the
383-
// accumulator when "comp-b" is accumulated. In practice we could use simple Kustomizations for this example.
383+
// accumulator when "comp-b" is accumulated.
384+
// In practice we could use simple Kustomizations for this example.
384385
"components-can-add-the-same-base-if-the-first-renames-resources": {
385386
input: []FileGen{writeTestBase,
386387
deployment("proxy", "comp-a/proxy.yaml"),
@@ -391,9 +392,6 @@ resources:
391392
nameSuffix: "-a"
392393
`),
393394
writeC("comp-b", `
394-
resources:
395-
- ../base
396-
397395
nameSuffix: "-b"
398396
`),
399397
writeK("prod", `
@@ -417,21 +415,6 @@ data:
417415
kind: ConfigMap
418416
metadata:
419417
name: my-configmap-a-b-9cd648hm8f
420-
---
421-
apiVersion: v1
422-
kind: Deployment
423-
metadata:
424-
name: storefront-b
425-
spec:
426-
replicas: 1
427-
---
428-
apiVersion: v1
429-
data:
430-
otherValue: green
431-
testValue: purple
432-
kind: ConfigMap
433-
metadata:
434-
name: my-configmap-b-9cd648hm8f
435418
`,
436419
},
437420

@@ -590,7 +573,7 @@ components:
590573
- ../comp-b`),
591574
},
592575
runPath: "prod",
593-
expectedError: "may not add resource with an already registered id: Deployment.v1.[noGrp]/proxy.[noNs]",
576+
expectedError: `id resid.ResId{Gvk:resid.Gvk{Group:\"\", Version:\"v1\", Kind:\"Deployment\", isClusterScoped:false}, Name:\"proxy\", Namespace:\"\"} exists`,
594577
},
595578
"components-cannot-add-the-same-base": {
596579
input: []FileGen{writeTestBase,
@@ -609,7 +592,7 @@ components:
609592
- ../comp-b`),
610593
},
611594
runPath: "prod",
612-
expectedError: "may not add resource with an already registered id: Deployment.v1.[noGrp]/storefront.[noNs]",
595+
expectedError: `resid.ResId{Gvk:resid.Gvk{Group:\"\", Version:\"v1\", Kind:\"Deployment\", isClusterScoped:false}, Name:\"storefront\", Namespace:\"\"} exists`,
613596
},
614597
"components-cannot-add-bases-containing-the-same-resource": {
615598
input: []FileGen{writeTestBase,
@@ -640,7 +623,7 @@ components:
640623
- ../comp-b`),
641624
},
642625
runPath: "prod",
643-
expectedError: "may not add resource with an already registered id: Deployment.v1.[noGrp]/proxy.[noNs]",
626+
expectedError: `resid.ResId{Gvk:resid.Gvk{Group:\"\", Version:\"v1\", Kind:\"Deployment\", isClusterScoped:false}, Name:\"proxy\", Namespace:\"\"} exists`,
644627
},
645628
}
646629

api/krusty/remoteloader_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ cp -r $ROOT/simple.git/. $ROOT/$HASH_DIR
105105
git commit -m "relative submodule"
106106
git checkout main
107107
git submodule add $ROOT/simple.git submodule
108-
git commit -m "submodule"
108+
git commit -m "submodule"
109109
)
110110
`, root, hashDir))
111111
return testRepos{
@@ -176,7 +176,7 @@ resources:
176176
{
177177
name: "has ref",
178178
kustomization: `
179-
resources:
179+
resources:
180180
- "file://$ROOT/simple.git?ref=change-image"
181181
`,
182182

@@ -383,7 +383,7 @@ resources:
383383
resources:
384384
- https://github.com/thisisa404.yaml
385385
`,
386-
err: "accumulating resources: accumulating resources from 'https://github.com/thisisa404.yaml': HTTP Error: status code 404 (Not Found)",
386+
err: `accumulating resources from 'https://github.com/thisisa404.yaml': HTTP Error: status code 404 (Not Found)`,
387387
errT: loader.ErrHTTP,
388388
},
389389
}

api/resmap/resmap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ type KustTargetInterface interface {
8383
func (c *PluginHelpers) AccumulateResource(path string) (ResMap, error) {
8484
resmap, err := c.kt.AccumulateResource(path)
8585
if err != nil {
86-
return nil, fmt.Errorf("failed to AccumulateResource in internal `target` pkg: %w", err)
86+
return nil, fmt.Errorf("failed to AccumulateResource in internal 'target' pkg: %w", err)
8787
}
8888
return resmap, nil
8989
}

0 commit comments

Comments
 (0)