Skip to content

Commit 2f6834f

Browse files
authored
Merge pull request #1329 from noamran/1204
🏃 Add v1alpha2 to v1alpha3 conversion webhooks
2 parents d2b5087 + 1a194d1 commit 2f6834f

21 files changed

+1585
-9
lines changed

api/v1alpha2/awscluster_conversion.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
Copyright 2019 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 v1alpha2
18+
19+
import (
20+
apiconversion "k8s.io/apimachinery/pkg/conversion"
21+
infrav1alpha3 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3"
22+
"sigs.k8s.io/controller-runtime/pkg/conversion"
23+
)
24+
25+
// ConvertTo converts this AWSCluster to the Hub version (v1alpha3).
26+
func (src *AWSCluster) ConvertTo(dstRaw conversion.Hub) error { // nolint
27+
dst := dstRaw.(*infrav1alpha3.AWSCluster)
28+
return Convert_v1alpha2_AWSCluster_To_v1alpha3_AWSCluster(src, dst, nil)
29+
}
30+
31+
// ConvertFrom converts from the Hub version (v1alpha3) to this version.
32+
func (dst *AWSCluster) ConvertFrom(srcRaw conversion.Hub) error { // nolint
33+
src := srcRaw.(*infrav1alpha3.AWSCluster)
34+
return Convert_v1alpha3_AWSCluster_To_v1alpha2_AWSCluster(src, dst, nil)
35+
}
36+
37+
// ConvertTo converts this AWSClusterList to the Hub version (v1alpha3).
38+
func (src *AWSClusterList) ConvertTo(dstRaw conversion.Hub) error { // nolint
39+
dst := dstRaw.(*infrav1alpha3.AWSClusterList)
40+
return Convert_v1alpha2_AWSClusterList_To_v1alpha3_AWSClusterList(src, dst, nil)
41+
}
42+
43+
// ConvertFrom converts from the Hub version (v1alpha3) to this version.
44+
func (dst *AWSClusterList) ConvertFrom(srcRaw conversion.Hub) error { // nolint
45+
src := srcRaw.(*infrav1alpha3.AWSClusterList)
46+
return Convert_v1alpha3_AWSClusterList_To_v1alpha2_AWSClusterList(src, dst, nil)
47+
}
48+
49+
// Convert_v1alpha3_AWSClusterSpec_To_v1alpha2_AWSClusterSpec converts from the Hub version (v1alpha3) of the AWSClusterSpec to this version.
50+
// Requires manual conversion as infrav1alpha3.AWSClusterSpec.ImageLookupOrg does not exist in AWSClusterSpec.
51+
func Convert_v1alpha3_AWSClusterSpec_To_v1alpha2_AWSClusterSpec(in *infrav1alpha3.AWSClusterSpec, out *AWSClusterSpec, s apiconversion.Scope) error { // nolint
52+
if err := autoConvert_v1alpha3_AWSClusterSpec_To_v1alpha2_AWSClusterSpec(in, out, s); err != nil {
53+
return err
54+
}
55+
56+
// Discards ImageLookupOrg
57+
58+
return nil
59+
}

api/v1alpha2/awsmachine_conversion.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Copyright 2019 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 v1alpha2
18+
19+
import (
20+
infrav1alpha3 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3"
21+
"sigs.k8s.io/controller-runtime/pkg/conversion"
22+
)
23+
24+
// ConvertTo converts this AWSMachine to the Hub version (v1alpha3).
25+
func (src *AWSMachine) ConvertTo(dstRaw conversion.Hub) error { // nolint
26+
dst := dstRaw.(*infrav1alpha3.AWSMachine)
27+
return Convert_v1alpha2_AWSMachine_To_v1alpha3_AWSMachine(src, dst, nil)
28+
}
29+
30+
// ConvertFrom converts from the Hub version (v1alpha3) to this version.
31+
func (dst *AWSMachine) ConvertFrom(srcRaw conversion.Hub) error { // nolint
32+
src := srcRaw.(*infrav1alpha3.AWSMachine)
33+
return Convert_v1alpha3_AWSMachine_To_v1alpha2_AWSMachine(src, dst, nil)
34+
}
35+
36+
// ConvertTo converts this AWSMachineList to the Hub version (v1alpha3).
37+
func (src *AWSMachineList) ConvertTo(dstRaw conversion.Hub) error { // nolint
38+
dst := dstRaw.(*infrav1alpha3.AWSMachineList)
39+
return Convert_v1alpha2_AWSMachineList_To_v1alpha3_AWSMachineList(src, dst, nil)
40+
}
41+
42+
// ConvertFrom converts from the Hub version (v1alpha3) to this version.
43+
func (dst *AWSMachineList) ConvertFrom(srcRaw conversion.Hub) error { // nolint
44+
src := srcRaw.(*infrav1alpha3.AWSMachineList)
45+
return Convert_v1alpha3_AWSMachineList_To_v1alpha2_AWSMachineList(src, dst, nil)
46+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Copyright 2019 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 v1alpha2
18+
19+
import (
20+
infrav1alpha3 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3"
21+
"sigs.k8s.io/controller-runtime/pkg/conversion"
22+
)
23+
24+
// ConvertTo converts this AWSMachineTemplate to the Hub version (v1alpha3).
25+
func (src *AWSMachineTemplate) ConvertTo(dstRaw conversion.Hub) error { // nolint
26+
dst := dstRaw.(*infrav1alpha3.AWSMachineTemplate)
27+
return Convert_v1alpha2_AWSMachineTemplate_To_v1alpha3_AWSMachineTemplate(src, dst, nil)
28+
}
29+
30+
// ConvertFrom converts from the Hub version (v1alpha3) to this version.
31+
func (dst *AWSMachineTemplate) ConvertFrom(srcRaw conversion.Hub) error { // nolint
32+
src := srcRaw.(*infrav1alpha3.AWSMachineTemplate)
33+
return Convert_v1alpha3_AWSMachineTemplate_To_v1alpha2_AWSMachineTemplate(src, dst, nil)
34+
}
35+
36+
// ConvertTo converts this AWSMachineTemplateList to the Hub version (v1alpha3).
37+
func (src *AWSMachineTemplateList) ConvertTo(dstRaw conversion.Hub) error { // nolint
38+
dst := dstRaw.(*infrav1alpha3.AWSMachineTemplateList)
39+
return Convert_v1alpha2_AWSMachineTemplateList_To_v1alpha3_AWSMachineTemplateList(src, dst, nil)
40+
}
41+
42+
// ConvertFrom converts from the Hub version (v1alpha3) to this version.
43+
func (dst *AWSMachineTemplateList) ConvertFrom(srcRaw conversion.Hub) error { // nolint
44+
src := srcRaw.(*infrav1alpha3.AWSMachineTemplateList)
45+
return Convert_v1alpha3_AWSMachineTemplateList_To_v1alpha2_AWSMachineTemplateList(src, dst, nil)
46+
}

api/v1alpha2/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
16+
// +k8s:conversion-gen=sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3
1717
package v1alpha2

api/v1alpha2/groupversion_info.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,7 @@ var (
3333

3434
// AddToScheme adds the types in this group-version to the given scheme.
3535
AddToScheme = SchemeBuilder.AddToScheme
36+
37+
// localSchemeBuilder is used for type conversions.
38+
localSchemeBuilder = SchemeBuilder.SchemeBuilder
3639
)

0 commit comments

Comments
 (0)