Skip to content

Commit 8ffa1ed

Browse files
authored
Merge pull request kubernetes-sigs#9525 from rvanderp3/ISSUE-8694
✨ promote IPAM types to v1beta1
2 parents 416991d + f7f5431 commit 8ffa1ed

24 files changed

+1047
-8
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ generate-go-conversions: ## Run all generate-go-conversions-* targets
422422
generate-go-conversions-core: ## Run all generate-go-conversions-core-* targets
423423
$(MAKE) generate-go-conversions-core-api
424424
$(MAKE) generate-go-conversions-core-exp
425+
$(MAKE) generate-go-conversions-core-exp-ipam
425426
$(MAKE) generate-go-conversions-core-runtime
426427

427428
.PHONY: generate-go-conversions-core-api
@@ -443,6 +444,14 @@ generate-go-conversions-core-exp: $(CONVERSION_GEN) ## Generate conversions go c
443444
--output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE) \
444445
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
445446

447+
.PHONY: generate-go-conversions-core-exp-ipam
448+
generate-go-conversions-core-exp-ipam: $(CONVERSION_GEN) ## Generate conversions go code for core exp IPAM
449+
$(MAKE) clean-generated-conversions SRC_DIRS="./$(EXP_DIR)/ipam/api/v1alpha1"
450+
$(CONVERSION_GEN) \
451+
--input-dirs=./$(EXP_DIR)/ipam/api/v1alpha1 \
452+
--output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE) \
453+
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
454+
446455
.PHONY: generate-go-conversions-core-runtime
447456
generate-go-conversions-core-runtime: $(CONVERSION_GEN) ## Generate conversions go code for core runtime
448457
$(MAKE) clean-generated-conversions SRC_DIRS="./internal/runtime/test/v1alpha1,./internal/runtime/test/v1alpha2"

config/crd/bases/ipam.cluster.x-k8s.io_ipaddressclaims.yaml

Lines changed: 117 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/ipam.cluster.x-k8s.io_ipaddresses.yaml

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/book/src/developer/providers/migrations/v1.5-to-v1.6.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ maintainers of providers and consumers of our Go API.
1616
- sigs.k8s.io/controller-tools: v0.12.x
1717

1818
## Changes by Kind
19+
- Introduced `v1beta1` for ipam.cluster.x-k8s.io IPAddresses and IPAddressClaims. Conversion webhooks handle translation between the hub version `v1beta1` and spoke `v1alpha1`.
1920

2021
### Deprecation
2122
- The function `sigs.k8s.io/cluster-api/addons/api/v1beta1` `DeleteBinding` has been deprecated. Please use `RemoveBinding` from the same package instead.

exp/ipam/api/v1alpha1/conversion.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
Copyright 2021 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
"sigs.k8s.io/controller-runtime/pkg/conversion"
21+
22+
ipamv1beta1 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta1"
23+
)
24+
25+
func (src *IPAddress) ConvertTo(dstRaw conversion.Hub) error {
26+
dst := dstRaw.(*ipamv1beta1.IPAddress)
27+
28+
return Convert_v1alpha1_IPAddress_To_v1beta1_IPAddress(src, dst, nil)
29+
}
30+
31+
func (dst *IPAddress) ConvertFrom(srcRaw conversion.Hub) error {
32+
src := srcRaw.(*ipamv1beta1.IPAddress)
33+
34+
return Convert_v1beta1_IPAddress_To_v1alpha1_IPAddress(src, dst, nil)
35+
}
36+
37+
func (src *IPAddressList) ConvertTo(dstRaw conversion.Hub) error {
38+
dst := dstRaw.(*ipamv1beta1.IPAddressList)
39+
40+
return Convert_v1alpha1_IPAddressList_To_v1beta1_IPAddressList(src, dst, nil)
41+
}
42+
43+
func (dst *IPAddressList) ConvertFrom(srcRaw conversion.Hub) error {
44+
src := srcRaw.(*ipamv1beta1.IPAddressList)
45+
46+
return Convert_v1beta1_IPAddressList_To_v1alpha1_IPAddressList(src, dst, nil)
47+
}
48+
49+
func (src *IPAddressClaim) ConvertTo(dstRaw conversion.Hub) error {
50+
dst := dstRaw.(*ipamv1beta1.IPAddressClaim)
51+
52+
return Convert_v1alpha1_IPAddressClaim_To_v1beta1_IPAddressClaim(src, dst, nil)
53+
}
54+
55+
func (dst *IPAddressClaim) ConvertFrom(srcRaw conversion.Hub) error {
56+
src := srcRaw.(*ipamv1beta1.IPAddressClaim)
57+
58+
return Convert_v1beta1_IPAddressClaim_To_v1alpha1_IPAddressClaim(src, dst, nil)
59+
}
60+
61+
func (src *IPAddressClaimList) ConvertTo(dstRaw conversion.Hub) error {
62+
dst := dstRaw.(*ipamv1beta1.IPAddressClaimList)
63+
64+
return Convert_v1alpha1_IPAddressClaimList_To_v1beta1_IPAddressClaimList(src, dst, nil)
65+
}
66+
67+
func (dst *IPAddressClaimList) ConvertFrom(srcRaw conversion.Hub) error {
68+
src := srcRaw.(*ipamv1beta1.IPAddressClaimList)
69+
70+
return Convert_v1beta1_IPAddressClaimList_To_v1alpha1_IPAddressClaimList(src, dst, nil)
71+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
Copyright 2021 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
"testing"
21+
22+
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
23+
24+
ipamv1beta1 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta1"
25+
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
26+
)
27+
28+
func TestFuzzyConversion(t *testing.T) {
29+
t.Run("for IPAddress", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
30+
Hub: &ipamv1beta1.IPAddress{},
31+
Spoke: &IPAddress{},
32+
FuzzerFuncs: []fuzzer.FuzzerFuncs{},
33+
}))
34+
t.Run("for IPAddressClaim", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
35+
Hub: &ipamv1beta1.IPAddressClaim{},
36+
Spoke: &IPAddressClaim{},
37+
FuzzerFuncs: []fuzzer.FuzzerFuncs{},
38+
}))
39+
}

exp/ipam/api/v1alpha1/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ limitations under the License.
1515
*/
1616

1717
// Package v1alpha1 contains API Schema definitions for the exp v1alpha1 IPAM API.
18+
// +k8s:conversion-gen=sigs.k8s.io/cluster-api/exp/ipam/api/v1beta1
1819
package v1alpha1

exp/ipam/api/v1alpha1/groupversion_info.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ var (
3636
AddToScheme = schemeBuilder.AddToScheme
3737

3838
objectTypes = []runtime.Object{}
39+
40+
// localSchemeBuilder is used for type conversions.
41+
localSchemeBuilder = schemeBuilder
3942
)
4043

4144
func addKnownTypes(scheme *runtime.Scheme) error {

exp/ipam/api/v1alpha1/ipaddress_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ type IPAddressSpec struct {
4242

4343
// +kubebuilder:object:root=true
4444
// +kubebuilder:resource:path=ipaddresses,scope=Namespaced,categories=cluster-api
45-
// +kubebuilder:storageversion
4645
// +kubebuilder:printcolumn:name="Address",type="string",JSONPath=".spec.address",description="Address"
4746
// +kubebuilder:printcolumn:name="Pool Name",type="string",JSONPath=".spec.poolRef.name",description="Name of the pool the address is from"
4847
// +kubebuilder:printcolumn:name="Pool Kind",type="string",JSONPath=".spec.poolRef.kind",description="Kind of the pool the address is from"

exp/ipam/api/v1alpha1/ipaddressclaim_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ type IPAddressClaimStatus struct {
4343
// +kubebuilder:object:root=true
4444
// +kubebuilder:resource:path=ipaddressclaims,scope=Namespaced,categories=cluster-api
4545
// +kubebuilder:subresource:status
46-
// +kubebuilder:storageversion
4746
// +kubebuilder:printcolumn:name="Pool Name",type="string",JSONPath=".spec.poolRef.name",description="Name of the pool to allocate an address from"
4847
// +kubebuilder:printcolumn:name="Pool Kind",type="string",JSONPath=".spec.poolRef.kind",description="Kind of the pool to allocate an address from"
4948
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of IPAdressClaim"

0 commit comments

Comments
 (0)