Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add v1beta1 APIs support in CAPA #2803

Closed
wants to merge 11 commits into from
Closed
  •  
  •  
  •  
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,16 @@ generate-go-core: ## Runs Go related generate targets

$(CONVERSION_GEN) \
--input-dirs=./api/v1alpha3 \
--input-dirs=./api/v1alpha4 \
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1alpha3 \
--build-tag=ignore_autogenerated_core_v1alpha3 \
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1alpha4 \
--build-tag=ignore_autogenerated_core \
--output-file-base=zz_generated.conversion $(GEN_OUTPUT_BASE) \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt

$(CONVERSION_GEN) \
--input-dirs=./$(EXP_DIR)/api/v1alpha3 \
--input-dirs=./$(EXP_DIR)/api/v1alpha4 \
--output-file-base=zz_generated.conversion \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt $(GEN_OUTPUT_BASE)

Expand All @@ -295,6 +298,7 @@ generate-go-eks-bootstrap: $(CONTROLLER_GEN)
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt
$(CONVERSION_GEN) \
--input-dirs=./bootstrap/eks/api/v1alpha3 \
--input-dirs=./bootstrap/eks/api/v1alpha4 \
--output-file-base=zz_generated.conversion $(GEN_OUTPUT_BASE) \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt

Expand All @@ -305,6 +309,7 @@ generate-go-eks-controlplane: $(CONTROLLER_GEN) $(CONVERSION_GEN)
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt
$(CONVERSION_GEN) \
--input-dirs=./controlplane/eks/api/v1alpha3 \
--input-dirs=./controlplane/eks/api/v1alpha4 \
--output-file-base=zz_generated.conversion $(GEN_OUTPUT_BASE) \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt

Expand Down
24 changes: 24 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: "2"
domain: cluster.x-k8s.io
repo: sigs.k8s.io/cluster-api-provider-aws
resources:
# v1alpha3 types
- group: infrastructure
version: v1alpha3
kind: AWSMachine
Expand All @@ -20,6 +21,7 @@ resources:
- group: infrastructure
version: v1alpha3
kind: AWSClusterControllerIdentity
# v1alpha4 types
- group: infrastructure
version: v1alpha4
kind: AWSMachine
Expand All @@ -41,3 +43,25 @@ resources:
- group: infrastructure
version: v1alpha4
kind: AWSClusterTemplate
# v1beta1 types
- group: infrastructure
version: v1beta1
kind: AWSMachine
- group: infrastructure
version: v1beta1
kind: AWSCluster
- group: infrastructure
version: v1beta1
kind: AWSMachineTemplate
- group: infrastructure
version: v1beta1
kind: AWSClusterStaticIdentity
- group: infrastructure
version: v1beta1
kind: AWSClusterRoleIdentity
- group: infrastructure
version: v1beta1
kind: AWSClusterControllerIdentity
- group: infrastructure
version: v1beta1
kind: AWSClusterTemplate
246 changes: 123 additions & 123 deletions api/v1alpha3/conversion.go

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions api/v1alpha3/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
runtime "k8s.io/apimachinery/pkg/runtime"
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
v1alpha4 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha4"
v1beta1 "sigs.k8s.io/cluster-api-provider-aws/api/v1beta1"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
)

Expand All @@ -40,22 +40,22 @@ func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
func AWSClusterStaticIdentityFuzzer(obj *AWSClusterStaticIdentity, c fuzz.Continue) {
c.FuzzNoCustom(obj)

// AWSClusterStaticIdentity.Spec.SecretRef.Namespace has been removed in v1alpha4, so setting it to nil in order to avoid v1alpha3 --> v1alpha4 --> v1alpha3 round trip errors.
// AWSClusterStaticIdentity.Spec.SecretRef.Namespace has been removed in v1beta1, so setting it to nil in order to avoid v1alpha3 --> <hub> --> v1alpha3 round trip errors.
obj.Spec.SecretRef.Namespace = ""
}

func AWSMachineFuzzer(obj *AWSMachine, c fuzz.Continue) {
c.FuzzNoCustom(obj)

// AWSMachine.Spec.AMI.ARN and AWSMachine.Spec.AMI.Filters has been removed in v1alpha4, so setting it to nil in order to avoid v1alpha3 --> v1alpha4 --> v1alpha3 round trip errors.
// AWSMachine.Spec.AMI.ARN and AWSMachine.Spec.AMI.Filters has been removed in v1beta1, so setting it to nil in order to avoid v1alpha3 --> <hub> --> v1alpha3 round trip errors.
obj.Spec.AMI.ARN = nil
obj.Spec.AMI.Filters = nil
}

func AWSMachineTemplateFuzzer(obj *AWSMachineTemplate, c fuzz.Continue) {
c.FuzzNoCustom(obj)

// AWSMachineTemplate.Spec.Template.Spec.AMI.ARN and AWSMachineTemplate.Spec.Template.Spec.AMI.Filters has been removed in v1alpha4, so setting it to nil in order to avoid v1alpha3 --> v1alpha4 --> v1alpha3 round trip errors.
// AWSMachineTemplate.Spec.Template.Spec.AMI.ARN and AWSMachineTemplate.Spec.Template.Spec.AMI.Filters has been removed in v1beta1, so setting it to nil in order to avoid v1alpha3 --> v1beta1 --> v1alpha3 round trip errors.
obj.Spec.Template.Spec.AMI.ARN = nil
obj.Spec.Template.Spec.AMI.Filters = nil
}
Expand All @@ -64,44 +64,44 @@ func TestFuzzyConversion(t *testing.T) {
g := NewWithT(t)
scheme := runtime.NewScheme()
g.Expect(AddToScheme(scheme)).To(Succeed())
g.Expect(v1alpha4.AddToScheme(scheme)).To(Succeed())
g.Expect(v1beta1.AddToScheme(scheme)).To(Succeed())

t.Run("for AWSCluster", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
Scheme: scheme,
Hub: &v1alpha4.AWSCluster{},
Hub: &v1beta1.AWSCluster{},
Spoke: &AWSCluster{},
}))

t.Run("for AWSMachine", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
Scheme: scheme,
Hub: &v1alpha4.AWSMachine{},
Hub: &v1beta1.AWSMachine{},
Spoke: &AWSMachine{},
FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs},
}))

t.Run("for AWSMachineTemplate", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
Scheme: scheme,
Hub: &v1alpha4.AWSMachineTemplate{},
Hub: &v1beta1.AWSMachineTemplate{},
Spoke: &AWSMachineTemplate{},
FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs},
}))

t.Run("for AWSClusterStaticIdentity", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
Scheme: scheme,
Hub: &v1alpha4.AWSClusterStaticIdentity{},
Hub: &v1beta1.AWSClusterStaticIdentity{},
Spoke: &AWSClusterStaticIdentity{},
FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs},
}))

t.Run("for AWSClusterControllerIdentity", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
Scheme: scheme,
Hub: &v1alpha4.AWSClusterControllerIdentity{},
Hub: &v1beta1.AWSClusterControllerIdentity{},
Spoke: &AWSClusterControllerIdentity{},
}))

t.Run("for AWSClusterRoleIdentity", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
Scheme: scheme,
Hub: &v1alpha4.AWSClusterRoleIdentity{},
Hub: &v1beta1.AWSClusterRoleIdentity{},
Spoke: &AWSClusterRoleIdentity{},
}))
}
3 changes: 2 additions & 1 deletion api/v1alpha3/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// +k8s:conversion-gen=sigs.k8s.io/cluster-api-provider-aws/api/v1alpha4
// Package v1alpha3 contains the v1alpha3 API implementation.
// +k8s:conversion-gen=sigs.k8s.io/cluster-api-provider-aws/api/v1beta1

package v1alpha3
2 changes: 1 addition & 1 deletion api/v1alpha3/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"path"
"testing"

infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha4"
infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1beta1"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down
Loading