Skip to content

Commit a274f4f

Browse files
committed
Added test for cluster inventory API provider
Signed-off-by: Shingo Omura <everpeace@gmail.com>
1 parent cefe93a commit a274f4f

File tree

6 files changed

+536
-3
lines changed

6 files changed

+536
-3
lines changed

hack/test-all.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ if [[ -n ${ARTIFACTS:-} ]]; then
2525
fi
2626

2727
result=0
28-
go test -v -race ${P_FLAG} ${MOD_OPT} ./... --ginkgo.fail-fast ${GINKGO_ARGS} || result=$?
28+
go test -v -race ${P_FLAG} ${MOD_OPT} ./... --ginkgo.fail-fast ${GINKGO_ARGS} \
29+
&& ( cd providers/cluster-inventory-api; go test -v -race ${P_FLAG} ${MOD_OPT} ./... --ginkgo.fail-fast ${GINKGO_ARGS}) \
30+
|| result=$?
2931

3032
if [[ -n ${ARTIFACTS:-} ]]; then
3133
mkdir -p ${ARTIFACTS}

providers/cluster-inventory-api/go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ go 1.24.2
44

55
require (
66
github.com/go-logr/logr v1.4.2
7+
github.com/onsi/ginkgo/v2 v2.22.0
8+
github.com/onsi/gomega v1.36.1
79
k8s.io/api v0.33.0
810
k8s.io/apimachinery v0.33.0
911
k8s.io/client-go v0.33.0
@@ -14,19 +16,23 @@ require (
1416

1517
require (
1618
github.com/beorn7/perks v1.0.1 // indirect
19+
github.com/blang/semver/v4 v4.0.0 // indirect
1720
github.com/cespare/xxhash/v2 v2.3.0 // indirect
1821
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
1922
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
2023
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
2124
github.com/fsnotify/fsnotify v1.7.0 // indirect
2225
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
26+
github.com/go-logr/zapr v1.3.0 // indirect
2327
github.com/go-openapi/jsonpointer v0.21.1 // indirect
2428
github.com/go-openapi/jsonreference v0.21.0 // indirect
2529
github.com/go-openapi/swag v0.23.1 // indirect
30+
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
2631
github.com/gogo/protobuf v1.3.2 // indirect
2732
github.com/google/btree v1.1.3 // indirect
2833
github.com/google/gnostic-models v0.6.9 // indirect
2934
github.com/google/go-cmp v0.7.0 // indirect
35+
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect
3036
github.com/google/uuid v1.6.0 // indirect
3137
github.com/josharian/intern v1.0.0 // indirect
3238
github.com/json-iterator/go v1.1.12 // indirect
@@ -41,13 +47,16 @@ require (
4147
github.com/prometheus/procfs v0.15.1 // indirect
4248
github.com/spf13/pflag v1.0.5 // indirect
4349
github.com/x448/float16 v0.8.4 // indirect
50+
go.uber.org/multierr v1.11.0 // indirect
51+
go.uber.org/zap v1.27.0 // indirect
4452
golang.org/x/net v0.38.0 // indirect
4553
golang.org/x/oauth2 v0.28.0 // indirect
4654
golang.org/x/sync v0.12.0 // indirect
4755
golang.org/x/sys v0.31.0 // indirect
4856
golang.org/x/term v0.30.0 // indirect
4957
golang.org/x/text v0.23.0 // indirect
5058
golang.org/x/time v0.11.0 // indirect
59+
golang.org/x/tools v0.26.0 // indirect
5160
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
5261
google.golang.org/protobuf v1.36.5 // indirect
5362
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect

providers/cluster-inventory-api/go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
6969
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
7070
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
7171
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
72-
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
7372
github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg=
7473
github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
7574
github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw=

providers/cluster-inventory-api/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ func (p *Provider) Reconcile(ctx context.Context, req reconcile.Request) (reconc
318318
}
319319
for _, idx := range p.indexers {
320320
if err := cl.GetCache().IndexField(ctx, idx.object, idx.field, idx.extractValue); err != nil {
321-
return reconcile.Result{}, fmt.Errorf("failed to index field %q for ClusterProfile=%s: %w", idx.field, key, err)
321+
return reconcile.Result{}, fmt.Errorf("failed to index field %q for %s=%s: %w", idx.field, idx.object.GetObjectKind().GroupVersionKind().String(), key, err)
322322
}
323323
}
324324
clusterCtx, cancel := context.WithCancel(ctx)

0 commit comments

Comments
 (0)