Skip to content

Commit ab186cc

Browse files
author
Brian Mendoza
committed
Merge branch 'main' into add-objectstoragekey
2 parents d9ffa02 + 27f5949 commit ab186cc

File tree

64 files changed

+2541
-399
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2541
-399
lines changed

.github/workflows/e2e-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ on:
2828
- linodemachine
2929
- linodeobj
3030
- linodevpc
31-
- linodeplacementgroup
31+
# - linodeplacementgroup
3232
- all
3333
e2e-flags:
3434
type: string

PROJECT

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,19 @@ resources:
107107
webhooks:
108108
validation: true
109109
webhookVersion: v1
110+
- api:
111+
crdVersion: v1
112+
namespaced: true
113+
controller: true
114+
domain: cluster.x-k8s.io
115+
group: infrastructure
116+
kind: LinodeVPC
117+
path: github.com/linode/cluster-api-provider-linode/api/v1alpha2
118+
version: v1alpha2
119+
webhooks:
120+
conversion: true
121+
validation: true
122+
webhookVersion: v1
110123
- api:
111124
crdVersion: v1
112125
namespaced: true

Tiltfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ for resource in manager_yaml:
129129
if resource["metadata"]["name"] == "capl-manager-credentials":
130130
resource["stringData"]["apiToken"] = os.getenv("LINODE_TOKEN")
131131
resource["stringData"]["dnsToken"] = os.getenv("LINODE_DNS_TOKEN")
132+
if resource["metadata"]["name"] == "capl-akamai-edgerc-secret":
133+
resource["stringData"]["AKAMAI_HOST"] = os.getenv("AKAMAI_HOST")
134+
resource["stringData"]["AKAMAI_CLIENT_TOKEN"] = os.getenv("AKAMAI_CLIENT_TOKEN")
135+
resource["stringData"]["AKAMAI_CLIENT_SECRET"] = os.getenv("AKAMAI_CLIENT_SECRET")
136+
resource["stringData"]["AKAMAI_ACCESS_TOKEN"] = os.getenv("AKAMAI_ACCESS_TOKEN")
132137
if (
133138
resource["kind"] == "CustomResourceDefinition"
134139
and resource["spec"]["group"] == "infrastructure.cluster.x-k8s.io"
@@ -172,6 +177,7 @@ k8s_resource(
172177
"capl-manager-rolebinding:clusterrolebinding",
173178
"capl-proxy-rolebinding:clusterrolebinding",
174179
"capl-manager-credentials:secret",
180+
"capl-akamai-edgerc-secret:secret",
175181
"capl-serving-cert:certificate",
176182
"capl-selfsigned-issuer:issuer",
177183
"capl-validating-webhook-configuration:validatingwebhookconfiguration",

api/v1alpha1/linodevpc_conversion.go

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
Copyright 2023 Akamai Technologies, Inc.
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+
"errors"
21+
22+
"sigs.k8s.io/controller-runtime/pkg/conversion"
23+
24+
infrastructurev1alpha2 "github.com/linode/cluster-api-provider-linode/api/v1alpha2"
25+
)
26+
27+
// ConvertTo converts this LinodeVPC to the Hub version (v1alpha2).
28+
func (src *LinodeVPC) ConvertTo(dstRaw conversion.Hub) error {
29+
dst, ok := dstRaw.(*infrastructurev1alpha2.LinodeVPC)
30+
if !ok {
31+
return errors.New("failed to convert LinodeVPC version from v1alpha1 to v1alpha2")
32+
}
33+
34+
// ObjectMeta
35+
dst.ObjectMeta = src.ObjectMeta
36+
37+
// Spec
38+
dst.Spec.Description = src.Spec.Description
39+
dst.Spec.Region = src.Spec.Region
40+
if src.Spec.Subnets != nil {
41+
dst.Spec.Subnets = []infrastructurev1alpha2.VPCSubnetCreateOptions{}
42+
for _, subnet := range src.Spec.Subnets {
43+
dst.Spec.Subnets = append(dst.Spec.Subnets, infrastructurev1alpha2.VPCSubnetCreateOptions{
44+
Label: subnet.Label,
45+
IPv4: subnet.IPv4,
46+
})
47+
}
48+
}
49+
50+
dst.Spec.VPCID = src.Spec.VPCID
51+
dst.Spec.CredentialsRef = src.Spec.CredentialsRef
52+
53+
// Status
54+
dst.Status.Ready = src.Status.Ready
55+
dst.Status.Conditions = src.Status.Conditions
56+
dst.Status.FailureMessage = src.Status.FailureMessage
57+
dst.Status.FailureReason = (*infrastructurev1alpha2.VPCStatusError)(src.Status.FailureReason)
58+
59+
return nil
60+
}
61+
62+
// ConvertFrom converts from the Hub version (v1alpha2) to this version.
63+
func (dst *LinodeVPC) ConvertFrom(srcRaw conversion.Hub) error {
64+
src, ok := srcRaw.(*infrastructurev1alpha2.LinodeVPC)
65+
if !ok {
66+
return errors.New("failed to convert LinodeVPC version from v1alpha2 to v1alpha1")
67+
}
68+
69+
// ObjectMeta
70+
dst.ObjectMeta = src.ObjectMeta
71+
72+
// Spec
73+
dst.Spec.Description = src.Spec.Description
74+
dst.Spec.Region = src.Spec.Region
75+
if src.Spec.Subnets != nil {
76+
dst.Spec.Subnets = []VPCSubnetCreateOptions{}
77+
for _, subnet := range src.Spec.Subnets {
78+
dst.Spec.Subnets = append(dst.Spec.Subnets, VPCSubnetCreateOptions{
79+
Label: subnet.Label,
80+
IPv4: subnet.IPv4,
81+
})
82+
}
83+
}
84+
85+
dst.Spec.VPCID = src.Spec.VPCID
86+
dst.Spec.CredentialsRef = src.Spec.CredentialsRef
87+
88+
// Status
89+
dst.Status.Ready = src.Status.Ready
90+
dst.Status.Conditions = src.Status.Conditions
91+
dst.Status.FailureMessage = src.Status.FailureMessage
92+
dst.Status.FailureReason = (*VPCStatusError)(src.Status.FailureReason)
93+
94+
return nil
95+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/*
2+
Copyright 2023 Akamai Technologies, Inc.
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+
"context"
21+
"testing"
22+
23+
"github.com/google/go-cmp/cmp"
24+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
25+
"k8s.io/utils/ptr"
26+
27+
infrav1alpha2 "github.com/linode/cluster-api-provider-linode/api/v1alpha2"
28+
"github.com/linode/cluster-api-provider-linode/mock"
29+
30+
. "github.com/linode/cluster-api-provider-linode/mock/mocktest"
31+
)
32+
33+
func TestConvertVPCTo(t *testing.T) {
34+
t.Parallel()
35+
36+
src := &LinodeVPC{
37+
ObjectMeta: metav1.ObjectMeta{
38+
Name: "test-vpc",
39+
},
40+
Spec: LinodeVPCSpec{
41+
VPCID: ptr.To(1234),
42+
Description: "test vpc",
43+
Region: "us-ord",
44+
Subnets: []VPCSubnetCreateOptions{{
45+
Label: "subnet1",
46+
IPv4: "10.0.0.0/24",
47+
}},
48+
CredentialsRef: nil,
49+
},
50+
}
51+
expectedDst := &infrav1alpha2.LinodeVPC{
52+
ObjectMeta: metav1.ObjectMeta{
53+
Name: "test-vpc",
54+
},
55+
Spec: infrav1alpha2.LinodeVPCSpec{
56+
VPCID: ptr.To(1234),
57+
Description: "test vpc",
58+
Region: "us-ord",
59+
Subnets: []infrav1alpha2.VPCSubnetCreateOptions{{
60+
Label: "subnet1",
61+
IPv4: "10.0.0.0/24",
62+
}},
63+
CredentialsRef: nil,
64+
},
65+
}
66+
67+
dst := &infrav1alpha2.LinodeVPC{}
68+
69+
NewSuite(t, mock.MockLinodeClient{}).Run(
70+
OneOf(
71+
Path(
72+
Call("convert v1alpha1 to v1alpha2", func(ctx context.Context, mck Mock) {
73+
err := src.ConvertTo(dst)
74+
if err != nil {
75+
t.Fatalf("ConvertTo failed: %v", err)
76+
}
77+
}),
78+
Result("conversion succeeded", func(ctx context.Context, mck Mock) {
79+
if diff := cmp.Diff(expectedDst, dst); diff != "" {
80+
t.Errorf("ConvertTo() mismatch (-expected +got):\n%s", diff)
81+
}
82+
}),
83+
),
84+
),
85+
)
86+
}
87+
88+
func TestConvertVPCFrom(t *testing.T) {
89+
t.Parallel()
90+
91+
src := &infrav1alpha2.LinodeVPC{
92+
ObjectMeta: metav1.ObjectMeta{
93+
Name: "test-vpc",
94+
},
95+
Spec: infrav1alpha2.LinodeVPCSpec{
96+
VPCID: ptr.To(1234),
97+
Description: "test vpc",
98+
Region: "us-ord",
99+
Subnets: []infrav1alpha2.VPCSubnetCreateOptions{{
100+
Label: "subnet1",
101+
IPv4: "10.0.0.0/24",
102+
}},
103+
CredentialsRef: nil,
104+
},
105+
}
106+
expectedDst := &LinodeVPC{
107+
ObjectMeta: metav1.ObjectMeta{
108+
Name: "test-vpc",
109+
},
110+
Spec: LinodeVPCSpec{
111+
VPCID: ptr.To(1234),
112+
Description: "test vpc",
113+
Region: "us-ord",
114+
Subnets: []VPCSubnetCreateOptions{{
115+
Label: "subnet1",
116+
IPv4: "10.0.0.0/24",
117+
}},
118+
CredentialsRef: nil,
119+
},
120+
}
121+
dst := &LinodeVPC{}
122+
123+
NewSuite(t, mock.MockLinodeClient{}).Run(
124+
OneOf(
125+
Path(
126+
Call("convert v1alpha2 to v1alpha1", func(ctx context.Context, mck Mock) {
127+
err := dst.ConvertFrom(src)
128+
if err != nil {
129+
t.Fatalf("ConvertFrom failed: %v", err)
130+
}
131+
}),
132+
Result("conversion succeeded", func(ctx context.Context, mck Mock) {
133+
if diff := cmp.Diff(expectedDst, dst); diff != "" {
134+
t.Errorf("ConvertFrom() mismatch (-expected +got):\n%s", diff)
135+
}
136+
}),
137+
),
138+
),
139+
)
140+
}

api/v1alpha2/linodecluster_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ type NetworkSpec struct {
110110
// DNSProvider is provider who manages the domain
111111
// Ignored if the LoadBalancerType is set to anything other than dns
112112
// If not set, defaults linode dns
113+
// +kubebuilder:validation:Enum=linode;akamai
113114
// +optional
114-
DNSProvider int `json:"dnsProvider,omitempty"`
115+
DNSProvider string `json:"dnsProvider,omitempty"`
115116
// DNSRootDomain is the root domain used to create a DNS entry for the control-plane endpoint
116117
// Ignored if the LoadBalancerType is set to anything other than dns
117118
// +optional

api/v1alpha2/linodevpc_conversion.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
Copyright 2023 Akamai Technologies, Inc.
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+
// Hub marks LinodeMachine as a conversion hub.
20+
func (*LinodeVPC) Hub() {}

0 commit comments

Comments
 (0)