Skip to content

Commit 38a5fab

Browse files
authored
refactor: Remove api module dependency from common module (#1019)
Move CAPA and CAPX specific test requests to root module. This allows other projects to use the common module without also pulling in the CAREN api module. Also remove some unused code.
1 parent 0944f23 commit 38a5fab

File tree

26 files changed

+207
-306
lines changed

26 files changed

+207
-306
lines changed

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/ap
55

66
go 1.22.0
77

8-
toolchain go1.23.3
8+
toolchain go1.23.5
99

1010
replace github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common => ../common
1111

common/go.mod

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ module github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/co
55

66
go 1.22.0
77

8-
toolchain go1.23.3
9-
10-
replace github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api => ../api
8+
toolchain go1.23.5
119

1210
require (
1311
github.com/evanphx/json-patch/v5 v5.9.0
1412
github.com/go-logr/logr v1.4.2
15-
github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api v0.0.0-00010101000000-000000000000
1613
github.com/onsi/ginkgo/v2 v2.22.0
1714
github.com/onsi/gomega v1.36.0
1815
github.com/samber/lo v1.47.0
@@ -31,7 +28,6 @@ require (
3128
require (
3229
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df // indirect
3330
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
34-
github.com/aws/aws-sdk-go v1.55.5 // indirect
3531
github.com/beorn7/perks v1.0.1 // indirect
3632
github.com/blang/semver/v4 v4.0.0 // indirect
3733
github.com/cespare/xxhash/v2 v2.2.0 // indirect
@@ -52,15 +48,13 @@ require (
5248
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect
5349
github.com/google/uuid v1.6.0 // indirect
5450
github.com/imdario/mergo v0.3.13 // indirect
55-
github.com/jmespath/go-jmespath v0.4.0 // indirect
5651
github.com/josharian/intern v1.0.0 // indirect
5752
github.com/json-iterator/go v1.1.12 // indirect
5853
github.com/mailru/easyjson v0.7.7 // indirect
5954
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
6055
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
6156
github.com/modern-go/reflect2 v1.0.2 // indirect
6257
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
63-
github.com/nutanix-cloud-native/prism-go-client v0.5.1 // indirect
6458
github.com/pkg/errors v0.9.1 // indirect
6559
github.com/pmezard/go-difflib v1.0.0 // indirect
6660
github.com/prometheus/client_golang v1.18.0 // indirect

common/go.sum

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df h
22
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM=
33
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
44
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
5-
github.com/aws/aws-sdk-go v1.55.5 h1:KKUZBfBoyqy5d3swXyiC7Q76ic40rYcbqH7qjh59kzU=
6-
github.com/aws/aws-sdk-go v1.55.5/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
75
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
86
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
97
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
@@ -72,10 +70,6 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rH
7270
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg=
7371
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
7472
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
75-
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
76-
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
77-
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
78-
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
7973
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
8074
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
8175
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
@@ -97,8 +91,6 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
9791
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
9892
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
9993
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
100-
github.com/nutanix-cloud-native/prism-go-client v0.5.1 h1:ykiXPCILzEMORHz7XvI8KXNomChsdLIpOAlT/YqBCmo=
101-
github.com/nutanix-cloud-native/prism-go-client v0.5.1/go.mod h1:QhLX+sEep0cStzHVYU6mPgIlnA8U3DySskagrbDprRk=
10294
github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg=
10395
github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
10496
github.com/onsi/gomega v1.36.0 h1:Pb12RlruUtj4XUuPUqeEWc6j5DkVVVA49Uf6YLfC95Y=

common/pkg/capi/apis/decoders.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

common/pkg/capi/apis/schemes.go

Lines changed: 0 additions & 54 deletions
This file was deleted.

common/pkg/capi/apis/unstructured_fallback.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

common/pkg/testutils/capitest/request/items.go

Lines changed: 0 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import (
1515
runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1"
1616
capdv1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1beta1"
1717

18-
capxv1 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/external/github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1"
19-
capav1 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/external/sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
2018
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest/serializer"
2119
)
2220

@@ -131,72 +129,6 @@ func NewKubeadmControlPlaneTemplateRequestItem(
131129
return NewKubeadmControlPlaneTemplateRequest(uid, kubeadmControlPlaneTemplateRequestObjectName)
132130
}
133131

134-
func NewAWSClusterTemplateRequestItem(
135-
uid types.UID,
136-
existingSpec ...capav1.AWSClusterTemplateSpec,
137-
) runtimehooksv1.GeneratePatchesRequestItem {
138-
awsClusterTemplate := &capav1.AWSClusterTemplate{
139-
TypeMeta: metav1.TypeMeta{
140-
APIVersion: capav1.GroupVersion.String(),
141-
Kind: "AWSClusterTemplate",
142-
},
143-
}
144-
145-
switch len(existingSpec) {
146-
case 0:
147-
// Do nothing.
148-
case 1:
149-
awsClusterTemplate.Spec = existingSpec[0]
150-
default:
151-
panic("can only take at most one existing spec")
152-
}
153-
154-
return NewRequestItem(
155-
awsClusterTemplate,
156-
&runtimehooksv1.HolderReference{
157-
APIVersion: clusterv1.GroupVersion.String(),
158-
Kind: "Cluster",
159-
FieldPath: "spec.infrastructureRef",
160-
Name: ClusterName,
161-
Namespace: Namespace,
162-
},
163-
uid,
164-
)
165-
}
166-
167-
func NewNutanixClusterTemplateRequestItem(
168-
uid types.UID,
169-
existingSpec ...capxv1.NutanixClusterTemplateSpec,
170-
) runtimehooksv1.GeneratePatchesRequestItem {
171-
nutanixClusterTemplate := &capxv1.NutanixClusterTemplate{
172-
TypeMeta: metav1.TypeMeta{
173-
APIVersion: capxv1.GroupVersion.String(),
174-
Kind: "NutanixClusterTemplate",
175-
},
176-
}
177-
178-
switch len(existingSpec) {
179-
case 0:
180-
// Do nothing.
181-
case 1:
182-
nutanixClusterTemplate.Spec = existingSpec[0]
183-
default:
184-
panic("can only take at most one existing spec")
185-
}
186-
187-
return NewRequestItem(
188-
nutanixClusterTemplate,
189-
&runtimehooksv1.HolderReference{
190-
APIVersion: clusterv1.GroupVersion.String(),
191-
Kind: "Cluster",
192-
FieldPath: "spec.infrastructureRef",
193-
Name: ClusterName,
194-
Namespace: Namespace,
195-
},
196-
uid,
197-
)
198-
}
199-
200132
func NewCPDockerMachineTemplateRequestItem(
201133
uid types.UID,
202134
) runtimehooksv1.GeneratePatchesRequestItem {
@@ -242,95 +174,3 @@ func NewWorkerDockerMachineTemplateRequestItem(
242174
uid,
243175
)
244176
}
245-
246-
func NewCPAWSMachineTemplateRequestItem(
247-
uid types.UID,
248-
) runtimehooksv1.GeneratePatchesRequestItem {
249-
return NewRequestItem(
250-
&capav1.AWSMachineTemplate{
251-
TypeMeta: metav1.TypeMeta{
252-
APIVersion: capav1.GroupVersion.String(),
253-
Kind: "AWSMachineTemplate",
254-
},
255-
ObjectMeta: metav1.ObjectMeta{
256-
Name: "aws-machine-template",
257-
Namespace: "aws-cluster",
258-
},
259-
},
260-
&runtimehooksv1.HolderReference{
261-
APIVersion: controlplanev1.GroupVersion.String(),
262-
Kind: "KubeadmControlPlane",
263-
FieldPath: "spec.machineTemplate.infrastructureRef",
264-
},
265-
uid,
266-
)
267-
}
268-
269-
func NewWorkerAWSMachineTemplateRequestItem(
270-
uid types.UID,
271-
) runtimehooksv1.GeneratePatchesRequestItem {
272-
return NewRequestItem(
273-
&capav1.AWSMachineTemplate{
274-
TypeMeta: metav1.TypeMeta{
275-
APIVersion: capav1.GroupVersion.String(),
276-
Kind: "AWSMachineTemplate",
277-
},
278-
ObjectMeta: metav1.ObjectMeta{
279-
Name: "aws-machine-template",
280-
Namespace: "aws-cluster",
281-
},
282-
},
283-
&runtimehooksv1.HolderReference{
284-
APIVersion: clusterv1.GroupVersion.String(),
285-
Kind: "MachineDeployment",
286-
FieldPath: "spec.template.spec.infrastructureRef",
287-
},
288-
uid,
289-
)
290-
}
291-
292-
func NewCPNutanixMachineTemplateRequestItem(
293-
uid types.UID,
294-
) runtimehooksv1.GeneratePatchesRequestItem {
295-
return NewRequestItem(
296-
&capxv1.NutanixMachineTemplate{
297-
TypeMeta: metav1.TypeMeta{
298-
APIVersion: capxv1.GroupVersion.String(),
299-
Kind: "NutanixMachineTemplate",
300-
},
301-
ObjectMeta: metav1.ObjectMeta{
302-
Name: "nutanix-machine-template",
303-
Namespace: "nutanix-cluster",
304-
},
305-
},
306-
&runtimehooksv1.HolderReference{
307-
APIVersion: controlplanev1.GroupVersion.String(),
308-
Kind: "KubeadmControlPlane",
309-
FieldPath: "spec.machineTemplate.infrastructureRef",
310-
},
311-
uid,
312-
)
313-
}
314-
315-
func NewWorkerNutanixMachineTemplateRequestItem(
316-
uid types.UID,
317-
) runtimehooksv1.GeneratePatchesRequestItem {
318-
return NewRequestItem(
319-
&capxv1.NutanixMachineTemplate{
320-
TypeMeta: metav1.TypeMeta{
321-
APIVersion: capxv1.GroupVersion.String(),
322-
Kind: "NutanixMachineTemplate",
323-
},
324-
ObjectMeta: metav1.ObjectMeta{
325-
Name: "nutanix-machine-template",
326-
Namespace: "nutanix-cluster",
327-
},
328-
},
329-
&runtimehooksv1.HolderReference{
330-
APIVersion: clusterv1.GroupVersion.String(),
331-
Kind: "MachineDeployment",
332-
FieldPath: "spec.template.spec.infrastructureRef",
333-
},
334-
uid,
335-
)
336-
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix
55

66
go 1.23
77

8-
toolchain go1.23.3
8+
toolchain go1.23.5
99

1010
replace (
1111
github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api => ./api

0 commit comments

Comments
 (0)