Skip to content

Commit

Permalink
Merge pull request #9525 from rvanderp3/ISSUE-8694
Browse files Browse the repository at this point in the history
✨ promote IPAM types to v1beta1
  • Loading branch information
k8s-ci-robot committed Oct 11, 2023
2 parents 416991d + f7f5431 commit 8ffa1ed
Show file tree
Hide file tree
Showing 24 changed files with 1,047 additions and 8 deletions.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ generate-go-conversions: ## Run all generate-go-conversions-* targets
generate-go-conversions-core: ## Run all generate-go-conversions-core-* targets
$(MAKE) generate-go-conversions-core-api
$(MAKE) generate-go-conversions-core-exp
$(MAKE) generate-go-conversions-core-exp-ipam
$(MAKE) generate-go-conversions-core-runtime

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

.PHONY: generate-go-conversions-core-exp-ipam
generate-go-conversions-core-exp-ipam: $(CONVERSION_GEN) ## Generate conversions go code for core exp IPAM
$(MAKE) clean-generated-conversions SRC_DIRS="./$(EXP_DIR)/ipam/api/v1alpha1"
$(CONVERSION_GEN) \
--input-dirs=./$(EXP_DIR)/ipam/api/v1alpha1 \
--output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE) \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt

.PHONY: generate-go-conversions-core-runtime
generate-go-conversions-core-runtime: $(CONVERSION_GEN) ## Generate conversions go code for core runtime
$(MAKE) clean-generated-conversions SRC_DIRS="./internal/runtime/test/v1alpha1,./internal/runtime/test/v1alpha2"
Expand Down
117 changes: 117 additions & 0 deletions config/crd/bases/ipam.cluster.x-k8s.io_ipaddressclaims.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 84 additions & 0 deletions config/crd/bases/ipam.cluster.x-k8s.io_ipaddresses.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ maintainers of providers and consumers of our Go API.
- sigs.k8s.io/controller-tools: v0.12.x

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

### Deprecation
- The function `sigs.k8s.io/cluster-api/addons/api/v1beta1` `DeleteBinding` has been deprecated. Please use `RemoveBinding` from the same package instead.
Expand Down
71 changes: 71 additions & 0 deletions exp/ipam/api/v1alpha1/conversion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
"sigs.k8s.io/controller-runtime/pkg/conversion"

ipamv1beta1 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta1"
)

func (src *IPAddress) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*ipamv1beta1.IPAddress)

return Convert_v1alpha1_IPAddress_To_v1beta1_IPAddress(src, dst, nil)
}

func (dst *IPAddress) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*ipamv1beta1.IPAddress)

return Convert_v1beta1_IPAddress_To_v1alpha1_IPAddress(src, dst, nil)
}

func (src *IPAddressList) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*ipamv1beta1.IPAddressList)

return Convert_v1alpha1_IPAddressList_To_v1beta1_IPAddressList(src, dst, nil)
}

func (dst *IPAddressList) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*ipamv1beta1.IPAddressList)

return Convert_v1beta1_IPAddressList_To_v1alpha1_IPAddressList(src, dst, nil)
}

func (src *IPAddressClaim) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*ipamv1beta1.IPAddressClaim)

return Convert_v1alpha1_IPAddressClaim_To_v1beta1_IPAddressClaim(src, dst, nil)
}

func (dst *IPAddressClaim) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*ipamv1beta1.IPAddressClaim)

return Convert_v1beta1_IPAddressClaim_To_v1alpha1_IPAddressClaim(src, dst, nil)
}

func (src *IPAddressClaimList) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*ipamv1beta1.IPAddressClaimList)

return Convert_v1alpha1_IPAddressClaimList_To_v1beta1_IPAddressClaimList(src, dst, nil)
}

func (dst *IPAddressClaimList) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*ipamv1beta1.IPAddressClaimList)

return Convert_v1beta1_IPAddressClaimList_To_v1alpha1_IPAddressClaimList(src, dst, nil)
}
39 changes: 39 additions & 0 deletions exp/ipam/api/v1alpha1/conversion_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
"testing"

"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"

ipamv1beta1 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta1"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
)

func TestFuzzyConversion(t *testing.T) {
t.Run("for IPAddress", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
Hub: &ipamv1beta1.IPAddress{},
Spoke: &IPAddress{},
FuzzerFuncs: []fuzzer.FuzzerFuncs{},
}))
t.Run("for IPAddressClaim", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
Hub: &ipamv1beta1.IPAddressClaim{},
Spoke: &IPAddressClaim{},
FuzzerFuncs: []fuzzer.FuzzerFuncs{},
}))
}
1 change: 1 addition & 0 deletions exp/ipam/api/v1alpha1/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the exp v1alpha1 IPAM API.
// +k8s:conversion-gen=sigs.k8s.io/cluster-api/exp/ipam/api/v1beta1
package v1alpha1
3 changes: 3 additions & 0 deletions exp/ipam/api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ var (
AddToScheme = schemeBuilder.AddToScheme

objectTypes = []runtime.Object{}

// localSchemeBuilder is used for type conversions.
localSchemeBuilder = schemeBuilder
)

func addKnownTypes(scheme *runtime.Scheme) error {
Expand Down
1 change: 0 additions & 1 deletion exp/ipam/api/v1alpha1/ipaddress_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ type IPAddressSpec struct {

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=ipaddresses,scope=Namespaced,categories=cluster-api
// +kubebuilder:storageversion
// +kubebuilder:printcolumn:name="Address",type="string",JSONPath=".spec.address",description="Address"
// +kubebuilder:printcolumn:name="Pool Name",type="string",JSONPath=".spec.poolRef.name",description="Name of the pool the address is from"
// +kubebuilder:printcolumn:name="Pool Kind",type="string",JSONPath=".spec.poolRef.kind",description="Kind of the pool the address is from"
Expand Down
1 change: 0 additions & 1 deletion exp/ipam/api/v1alpha1/ipaddressclaim_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type IPAddressClaimStatus struct {
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=ipaddressclaims,scope=Namespaced,categories=cluster-api
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +kubebuilder:printcolumn:name="Pool Name",type="string",JSONPath=".spec.poolRef.name",description="Name of the pool to allocate an address from"
// +kubebuilder:printcolumn:name="Pool Kind",type="string",JSONPath=".spec.poolRef.kind",description="Kind of the pool to allocate an address from"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of IPAdressClaim"
Expand Down
Loading

0 comments on commit 8ffa1ed

Please sign in to comment.