-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increment API version to support new reconciliation API and move rel… (…
…#232) * Increment API version to support new reconciliation API and move related fields
- Loading branch information
1 parent
ee5de6b
commit f620d39
Showing
140 changed files
with
22,488 additions
and
2,206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
Copyright (c) 2023 Oracle and/or its affiliates. | ||
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 | ||
https://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 v1beta1 | ||
|
||
import ( | ||
"errors" | ||
"github.com/oracle/cluster-api-provider-oci/api/v1beta2" | ||
"k8s.io/apimachinery/pkg/conversion" | ||
) | ||
|
||
// Convert_v1beta1_VCN_To_v1beta2_VCN converts v1beta1 VCN to v1beta2 VCN | ||
func Convert_v1beta1_VCN_To_v1beta2_VCN(in *VCN, out *v1beta2.VCN, s conversion.Scope) error { | ||
autoConvert_v1beta1_VCN_To_v1beta2_VCN(in, out, s) | ||
if in.InternetGatewayId != nil { | ||
out.InternetGateway.Id = in.InternetGatewayId | ||
} | ||
if in.NatGatewayId != nil { | ||
out.NATGateway.Id = in.NatGatewayId | ||
} | ||
if in.ServiceGatewayId != nil { | ||
out.ServiceGateway.Id = in.ServiceGatewayId | ||
} | ||
if in.PrivateRouteTableId != nil { | ||
out.RouteTable.PrivateRouteTableId = in.PrivateRouteTableId | ||
} | ||
if in.PublicRouteTableId != nil { | ||
out.RouteTable.PublicRouteTableId = in.PublicRouteTableId | ||
} | ||
if in.NetworkSecurityGroups != nil { | ||
nsgList, err := convertv1beta1NSGListTov1beta2NSGList(in.NetworkSecurityGroups) | ||
if err != nil { | ||
return err | ||
} | ||
out.NetworkSecurityGroup.List = nsgList | ||
} | ||
return nil | ||
} | ||
|
||
// Convert_v1beta2_VCN_To_v1beta1_VCN converts v1beta2 VCN to v1beta1 VCN | ||
func Convert_v1beta2_VCN_To_v1beta1_VCN(in *v1beta2.VCN, out *VCN, s conversion.Scope) error { | ||
autoConvert_v1beta2_VCN_To_v1beta1_VCN(in, out, s) | ||
if in.InternetGateway.Id != nil { | ||
out.InternetGatewayId = in.InternetGateway.Id | ||
} | ||
if in.NATGateway.Id != nil { | ||
out.NatGatewayId = in.NATGateway.Id | ||
} | ||
if in.ServiceGateway.Id != nil { | ||
out.ServiceGatewayId = in.ServiceGateway.Id | ||
} | ||
if in.RouteTable.PublicRouteTableId != nil { | ||
out.PublicRouteTableId = in.RouteTable.PublicRouteTableId | ||
} | ||
if in.RouteTable.PrivateRouteTableId != nil { | ||
out.PrivateRouteTableId = in.RouteTable.PrivateRouteTableId | ||
} | ||
if in.NetworkSecurityGroup.List != nil { | ||
nsgList, err := convertv1beta2NSGListTov1beta1NSGList(in.NetworkSecurityGroup.List) | ||
if err != nil { | ||
return err | ||
} | ||
out.NetworkSecurityGroups = nsgList | ||
} | ||
return nil | ||
} | ||
|
||
// Convert_v1beta1_OCIClusterStatus_To_v1beta2_OCIClusterStatus converts v1beta1 OCIClusterStatus to v1beta2 OCIClusterStatus | ||
func Convert_v1beta1_OCIClusterStatus_To_v1beta2_OCIClusterStatus(in *OCIClusterStatus, out *v1beta2.OCIClusterStatus, s conversion.Scope) error { | ||
return autoConvert_v1beta1_OCIClusterStatus_To_v1beta2_OCIClusterStatus(in, out, s) | ||
} | ||
|
||
// Convert_v1beta2_OCIClusterSpec_To_v1beta1_OCIClusterSpec converts v1beta2 OCIClusterStatus to v1beta1 OCIClusterStatus | ||
func Convert_v1beta2_OCIClusterSpec_To_v1beta1_OCIClusterSpec(in *v1beta2.OCIClusterSpec, out *OCIClusterSpec, s conversion.Scope) error { | ||
return autoConvert_v1beta2_OCIClusterSpec_To_v1beta1_OCIClusterSpec(in, out, s) | ||
} | ||
|
||
// Convert_v1beta1_EgressSecurityRuleForNSG_To_v1beta2_EgressSecurityRuleForNSG converts v1beta1 EgressSecurityRuleForNSG to v1beta2 EgressSecurityRuleForNSG | ||
func Convert_v1beta1_EgressSecurityRuleForNSG_To_v1beta2_EgressSecurityRuleForNSG(in *EgressSecurityRuleForNSG, out *v1beta2.EgressSecurityRuleForNSG, s conversion.Scope) error { | ||
return autoConvert_v1beta1_EgressSecurityRuleForNSG_To_v1beta2_EgressSecurityRuleForNSG(in, out, s) | ||
} | ||
|
||
// Convert_v1beta1_IngressSecurityRuleForNSG_To_v1beta2_IngressSecurityRuleForNSG converts v1beta1 IngressSecurityRuleForNSG to v1beta2 IngressSecurityRuleForNSG | ||
func Convert_v1beta1_IngressSecurityRuleForNSG_To_v1beta2_IngressSecurityRuleForNSG(in *IngressSecurityRuleForNSG, out *v1beta2.IngressSecurityRuleForNSG, s conversion.Scope) error { | ||
return autoConvert_v1beta1_IngressSecurityRuleForNSG_To_v1beta2_IngressSecurityRuleForNSG(in, out, s) | ||
} | ||
|
||
// Convert_v1beta1_NetworkDetails_To_v1beta2_NetworkDetails converts v1beta1 NetworkDetails to v1beta2 NetworkDetails | ||
func Convert_v1beta1_NetworkDetails_To_v1beta2_NetworkDetails(in *NetworkDetails, out *v1beta2.NetworkDetails, s conversion.Scope) error { | ||
return autoConvert_v1beta1_NetworkDetails_To_v1beta2_NetworkDetails(in, out, s) | ||
} | ||
|
||
// Convert_v1beta1_OCIMachineSpec_To_v1beta2_OCIMachineSpec converts v1beta1 OCIMachineSpec to v1beta2 OCIMachineSpec | ||
func Convert_v1beta1_OCIMachineSpec_To_v1beta2_OCIMachineSpec(in *OCIMachineSpec, out *v1beta2.OCIMachineSpec, s conversion.Scope) error { | ||
err := autoConvert_v1beta1_OCIMachineSpec_To_v1beta2_OCIMachineSpec(in, out, s) | ||
if err != nil { | ||
return err | ||
} | ||
if in.NetworkDetails.SubnetId != nil { | ||
return errors.New("deprecated field NetworkDetails.SubnetId is present in OCIMachineSpec") | ||
} | ||
if in.NetworkDetails.NSGId != nil { | ||
return errors.New("deprecated field NetworkDetails.NSGId is present in OCIMachineSpec") | ||
} | ||
if in.NSGName != "" && len(in.NetworkDetails.NsgNames) == 0 { | ||
out.NetworkDetails.NsgNames = []string{in.NSGName} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
/* | ||
Copyright (c) 2023 Oracle and/or its affiliates. | ||
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 | ||
https://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 v1beta1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer" | ||
"testing" | ||
|
||
fuzz "github.com/google/gofuzz" | ||
. "github.com/onsi/gomega" | ||
"github.com/oracle/cluster-api-provider-oci/api/v1beta2" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" | ||
utilconversion "sigs.k8s.io/cluster-api/util/conversion" | ||
) | ||
|
||
func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { | ||
return []interface{}{ | ||
OCIMachineFuzzer, | ||
OCIMachineTemplateFuzzer, | ||
OCIClusterFuzzer, | ||
OCIClusterTemplateFuzzer, | ||
} | ||
} | ||
|
||
func OCIMachineFuzzer(obj *OCIMachine, c fuzz.Continue) { | ||
c.FuzzNoCustom(obj) | ||
// nil fields which have been removed so that tests dont fail | ||
obj.Spec.NetworkDetails.NSGId = nil | ||
obj.Spec.NetworkDetails.SubnetId = nil | ||
obj.Spec.NSGName = "" | ||
} | ||
|
||
func OCIClusterFuzzer(obj *OCICluster, c fuzz.Continue) { | ||
c.FuzzNoCustom(obj) | ||
// nil fields which have been removed so that tests dont fail | ||
for _, nsg := range obj.Spec.NetworkSpec.Vcn.NetworkSecurityGroups { | ||
if nsg != nil { | ||
ingressRules := make([]IngressSecurityRuleForNSG, len(nsg.IngressRules)) | ||
for _, rule := range nsg.IngressRules { | ||
rule.ID = nil | ||
ingressRules = append(ingressRules, rule) | ||
} | ||
nsg.IngressRules = ingressRules | ||
|
||
egressRules := make([]EgressSecurityRuleForNSG, len(nsg.EgressRules)) | ||
for _, rule := range nsg.EgressRules { | ||
(&rule).ID = nil | ||
egressRules = append(egressRules, rule) | ||
} | ||
nsg.EgressRules = egressRules | ||
} | ||
} | ||
} | ||
|
||
func OCIClusterTemplateFuzzer(obj *OCIClusterTemplate, c fuzz.Continue) { | ||
c.FuzzNoCustom(obj) | ||
// nil fields which have been removed so that tests dont fail | ||
for _, nsg := range obj.Spec.Template.Spec.NetworkSpec.Vcn.NetworkSecurityGroups { | ||
if nsg != nil { | ||
ingressRules := make([]IngressSecurityRuleForNSG, len(nsg.IngressRules)) | ||
for _, rule := range nsg.IngressRules { | ||
rule.ID = nil | ||
ingressRules = append(ingressRules, rule) | ||
} | ||
nsg.IngressRules = ingressRules | ||
|
||
egressRules := make([]EgressSecurityRuleForNSG, len(nsg.EgressRules)) | ||
for _, rule := range nsg.EgressRules { | ||
(&rule).ID = nil | ||
egressRules = append(egressRules, rule) | ||
} | ||
nsg.EgressRules = egressRules | ||
} | ||
} | ||
} | ||
|
||
func OCIMachineTemplateFuzzer(obj *OCIMachineTemplate, c fuzz.Continue) { | ||
c.FuzzNoCustom(obj) | ||
// nil fields which ave been removed so that tests dont fail | ||
obj.Spec.Template.Spec.NetworkDetails.NSGId = nil | ||
obj.Spec.Template.Spec.NetworkDetails.SubnetId = nil | ||
obj.Spec.Template.Spec.NSGName = "" | ||
} | ||
|
||
func TestFuzzyConversion(t *testing.T) { | ||
g := NewWithT(t) | ||
scheme := runtime.NewScheme() | ||
g.Expect(AddToScheme(scheme)).To(Succeed()) | ||
g.Expect(v1beta2.AddToScheme(scheme)).To(Succeed()) | ||
|
||
t.Run("for OCICluster", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ | ||
Scheme: scheme, | ||
Hub: &v1beta2.OCICluster{}, | ||
Spoke: &OCICluster{}, | ||
FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, | ||
})) | ||
|
||
t.Run("for OCIClusterTemplate", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ | ||
Scheme: scheme, | ||
Hub: &v1beta2.OCIClusterTemplate{}, | ||
Spoke: &OCIClusterTemplate{}, | ||
FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, | ||
})) | ||
|
||
t.Run("for OCIMachine", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ | ||
Scheme: scheme, | ||
Hub: &v1beta2.OCIMachine{}, | ||
Spoke: &OCIMachine{}, | ||
FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, | ||
})) | ||
|
||
t.Run("for OCIMachineTemplate", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ | ||
Scheme: scheme, | ||
Hub: &v1beta2.OCIMachineTemplate{}, | ||
Spoke: &OCIMachineTemplate{}, | ||
FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, | ||
})) | ||
|
||
t.Run("for OCIClusterIdentity", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ | ||
Scheme: scheme, | ||
Hub: &v1beta2.OCIClusterIdentity{}, | ||
Spoke: &OCIClusterIdentity{}, | ||
FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, | ||
})) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
Copyright (c) 2023 Oracle and/or its affiliates. | ||
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 | ||
https://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. | ||
*/ | ||
|
||
// +k8s:conversion-gen=github.com/oracle/cluster-api-provider-oci/api/v1beta2 | ||
|
||
package v1beta1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.