Skip to content

Commit 0bf9d3c

Browse files
authored
Copy over CAPT APIs to local package (#9114)
* Copy over CAPT apis to local package Signed-off-by: Rahul Ganesh <[email protected]>
1 parent 2d73db2 commit 0bf9d3c

35 files changed

+2022
-32
lines changed

controllers/controlplaneupgrade_controller_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
"github.com/golang/mock/gomock"
1111
. "github.com/onsi/gomega"
12-
tinkerbellv1 "github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1"
1312
corev1 "k8s.io/api/core/v1"
1413
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1514
"k8s.io/apimachinery/pkg/runtime"
@@ -25,6 +24,7 @@ import (
2524
"github.com/aws/eks-anywhere/controllers"
2625
"github.com/aws/eks-anywhere/controllers/mocks"
2726
anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1"
27+
tinkerbellv1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1"
2828
"github.com/aws/eks-anywhere/pkg/constants"
2929
)
3030

go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ require (
3838
github.com/spf13/pflag v1.0.5
3939
github.com/spf13/viper v1.18.2
4040
github.com/stretchr/testify v1.9.0
41-
github.com/tinkerbell/cluster-api-provider-tinkerbell v0.1.1-0.20220615214617-9e9c2a397288
4241
github.com/tinkerbell/tink v0.8.0
4342
github.com/vmware/govmomi v0.37.2
4443
go.uber.org/zap v1.26.0

go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,6 @@ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8
862862
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
863863
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
864864
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
865-
github.com/tinkerbell/cluster-api-provider-tinkerbell v0.1.1-0.20220615214617-9e9c2a397288 h1:HkBPnM4/DdLKJvcUNsFePYuTAFOHPMSzr3DvH7ZKBds=
866-
github.com/tinkerbell/cluster-api-provider-tinkerbell v0.1.1-0.20220615214617-9e9c2a397288/go.mod h1:IjRbGnQtoplJEW5UgKHsCp1WukkAyjhIdDBsxjYq2dM=
867865
github.com/tinkerbell/tink v0.8.0 h1:qgl/rglpO5Rvq6UKZd29O6X9mDgZZYgf841+Y0IYWak=
868866
github.com/tinkerbell/tink v0.8.0/go.mod h1:bfAkSH7J/QQYIyqZRR6IQp8w78aac6l8Z2Lws5uXz6A=
869867
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=

internal/aws-sdk-go-v2/internal/auth/smithy/v4signer_adapter.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import (
55
"fmt"
66

77
v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
8-
"github.com/aws/eks-anywhere/internal/aws-sdk-go-v2/internal/sdk"
98
"github.com/aws/smithy-go"
109
"github.com/aws/smithy-go/auth"
1110
"github.com/aws/smithy-go/logging"
1211
smithyhttp "github.com/aws/smithy-go/transport/http"
12+
13+
"github.com/aws/eks-anywhere/internal/aws-sdk-go-v2/internal/sdk"
1314
)
1415

1516
// V4SignerAdapter adapts v4.HTTPSigner to smithy http.Signer.

internal/aws-sdk-go-v2/internal/endpoints/v2/endpoints.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import (
55
"regexp"
66
"strings"
77

8-
"github.com/aws/smithy-go/logging"
9-
108
"github.com/aws/aws-sdk-go-v2/aws"
9+
"github.com/aws/smithy-go/logging"
1110
)
1211

1312
// DefaultKey is a compound map key of a variant and other values.

internal/test/e2e/packages.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
)
99

1010
const (
11-
packagesRegex = `^.*CuratedPackages.*$`
11+
packagesRegex = `^.*CuratedPackages.*$`
1212
nonRegionalPackagesRegex = `^.*NonRegionalCuratedPackages.*$`
13-
certManagerRegex = "^.*CuratedPackagesCertManager.*$"
13+
certManagerRegex = "^.*CuratedPackagesCertManager.*$"
1414
)
1515

1616
func (e *E2ESession) setupPackagesEnv(testRegex string) error {

internal/test/envtest/config/capt-crds.yaml

+734
Large diffs are not rendered by default.

internal/test/envtest/environment.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414

1515
eksdv1alpha1 "github.com/aws/eks-distro-build-tooling/release/api/v1alpha1"
1616
etcdv1 "github.com/aws/etcdadm-controller/api/v1beta1"
17-
tinkerbellv1 "github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1"
1817
tinkv1alpha1 "github.com/tinkerbell/tink/pkg/apis/core/v1alpha1"
1918
admissionv1beta1 "k8s.io/api/admission/v1beta1"
2019
corev1 "k8s.io/api/core/v1"
@@ -39,6 +38,7 @@ import (
3938
"sigs.k8s.io/controller-runtime/pkg/webhook"
4039

4140
anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1"
41+
tinkerbellv1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1"
4242
rufiov1alpha1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/rufio"
4343
snowv1 "github.com/aws/eks-anywhere/pkg/providers/snow/api/v1beta1"
4444
releasev1 "github.com/aws/eks-anywhere/release/api/v1alpha1"
@@ -48,7 +48,6 @@ const (
4848
capiPackage = "sigs.k8s.io/cluster-api"
4949
capdPackage = "sigs.k8s.io/cluster-api/test"
5050
capvPackage = "sigs.k8s.io/cluster-api-provider-vsphere"
51-
captPackage = "github.com/tinkerbell/cluster-api-provider-tinkerbell"
5251
tinkerbellPackage = "github.com/tinkerbell/tink"
5352
etcdProviderPackage = "github.com/aws/etcdadm-controller"
5453
capcPackage = "sigs.k8s.io/cluster-api-provider-cloudstack"
@@ -83,9 +82,6 @@ var packages = []moduleWithCRD{
8382
withAdditionalCustomCRDPath("bootstrap/kubeadm/config/crd/bases"),
8483
withAdditionalCustomCRDPath("controlplane/kubeadm/config/crd/bases"),
8584
),
86-
mustBuildModuleWithCRDs(captPackage,
87-
withMainCustomCRDPath("config/crd/bases/infrastructure.cluster.x-k8s.io_tinkerbellclusters.yaml"),
88-
withAdditionalCustomCRDPath("config/crd/bases/infrastructure.cluster.x-k8s.io_tinkerbellmachinetemplates.yaml")),
8985
mustBuildModuleWithCRDs(tinkerbellPackage),
9086
mustBuildModuleWithCRDs(capvPackage,
9187
withMainCustomCRDPath("config/default/crd/bases"),
@@ -153,6 +149,7 @@ func newEnvironment(ctx context.Context) (*Environment, error) {
153149
filepath.Join(currentDir, "config", "eks-d-crds.yaml"),
154150
filepath.Join(currentDir, "config", "snow-crds.yaml"),
155151
filepath.Join(currentDir, "config", "rufio-crds.yaml"),
152+
filepath.Join(currentDir, "config", "capt-crds.yaml"),
156153
filepath.Join(root, "internal", "thirdparty", "capc", "config", "crd", "bases"),
157154
)
158155
extraCRDPaths, err := getPathsToPackagesCRDs(root, packages...)

manager/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/go-logr/logr"
1111
nutanixv1 "github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1"
1212
"github.com/spf13/pflag"
13-
tinkerbellv1 "github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1"
1413
tinkv1alpha1 "github.com/tinkerbell/tink/pkg/apis/core/v1alpha1"
1514
"k8s.io/apimachinery/pkg/runtime"
1615
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -34,6 +33,7 @@ import (
3433

3534
"github.com/aws/eks-anywhere/controllers"
3635
anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1"
36+
tinkerbellv1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1"
3737
rufiov1alpha1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/rufio"
3838
"github.com/aws/eks-anywhere/pkg/clusterapi"
3939
"github.com/aws/eks-anywhere/pkg/controller/clientutil"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
Copyright 2022 The Tinkerbell 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 v1beta1 contains API Schema definitions for the infrastructure v1beta1 API group.
18+
package v1beta1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright 2022 The Tinkerbell 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+
// +kubebuilder:object:generate=true
18+
// +groupName=infrastructure.cluster.x-k8s.io
19+
20+
package v1beta1
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
//nolint:gochecknoglobals
28+
var (
29+
// GroupVersion is group version used to register these objects.
30+
GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1beta1"}
31+
32+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
33+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
34+
35+
// AddToScheme adds the types in this group-version to the given scheme.
36+
AddToScheme = SchemeBuilder.AddToScheme
37+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
Copyright 2022 The Tinkerbell 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 v1beta1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
22+
)
23+
24+
const (
25+
// ClusterFinalizer allows ReconcileTinkerbellCluster to clean up Tinkerbell resources before
26+
// removing it from the apiserver.
27+
ClusterFinalizer = "tinkerbellcluster.infrastructure.cluster.x-k8s.io"
28+
)
29+
30+
// TinkerbellClusterSpec defines the desired state of TinkerbellCluster.
31+
type TinkerbellClusterSpec struct {
32+
// ControlPlaneEndpoint is a required field by ClusterAPI v1beta1.
33+
//
34+
// See https://cluster-api.sigs.k8s.io/developer/architecture/controllers/cluster.html
35+
// for more details.
36+
//
37+
// +optional
38+
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint,omitempty"`
39+
40+
// ImageLookupFormat is the URL naming format to use for machine images when
41+
// a machine does not specify. When set, this will be used for all cluster machines
42+
// unless a machine specifies a different ImageLookupFormat. Supports substitutions
43+
// for {{.BaseRegistry}}, {{.OSDistro}}, {{.OSVersion}} and {{.KubernetesVersion}} with
44+
// the basse URL, OS distribution, OS version, and kubernetes version, respectively.
45+
// BaseRegistry will be the value in ImageLookupBaseRegistry or ghcr.io/tinkerbell/cluster-api-provider-tinkerbell
46+
// (the default), OSDistro will be the value in ImageLookupOSDistro or ubuntu (the default),
47+
// OSVersion will be the value in ImageLookupOSVersion or default based on the OSDistro
48+
// (if known), and the kubernetes version as defined by the packages produced by
49+
// kubernetes/release: v1.13.0, v1.12.5-mybuild.1, or v1.17.3. For example, the default
50+
// image format of {{.BaseRegistry}}/{{.OSDistro}}-{{.OSVersion}}:{{.KubernetesVersion}}.gz will
51+
// attempt to pull the image from that location. See also: https://golang.org/pkg/text/template/
52+
// +optional
53+
ImageLookupFormat string `json:"imageLookupFormat,omitempty"`
54+
55+
// ImageLookupBaseRegistry is the base Registry URL that is used for pulling images,
56+
// if not set, the default will be to use ghcr.io/tinkerbell/cluster-api-provider-tinkerbell.
57+
// +optional
58+
// +kubebuilder:default=ghcr.io/tinkerbell/cluster-api-provider-tinkerbell
59+
ImageLookupBaseRegistry string `json:"imageLookupBaseRegistry,omitempty"`
60+
61+
// ImageLookupOSDistro is the name of the OS distro to use when fetching machine images,
62+
// if not set it will default to ubuntu.
63+
// +optional
64+
// +kubebuilder:default=ubuntu
65+
ImageLookupOSDistro string `json:"imageLookupOSDistro,omitempty"`
66+
67+
// ImageLookupOSVersion is the version of the OS distribution to use when fetching machine
68+
// images. If not set it will default based on ImageLookupOSDistro.
69+
// +optional
70+
ImageLookupOSVersion string `json:"imageLookupOSVersion,omitempty"`
71+
}
72+
73+
// TinkerbellClusterStatus defines the observed state of TinkerbellCluster.
74+
type TinkerbellClusterStatus struct {
75+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
76+
// Important: Run "make" to regenerate code after modifying this file.
77+
78+
// Ready denotes that the cluster (infrastructure) is ready.
79+
// +optional
80+
Ready bool `json:"ready"`
81+
}
82+
83+
// +kubebuilder:subresource:status
84+
// +kubebuilder:resource:path=tinkerbellclusters,scope=Namespaced,categories=cluster-api
85+
// +kubebuilder:object:root=true
86+
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this TinkerbellCluster belongs"
87+
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="TinkerbellCluster ready status"
88+
89+
// TinkerbellCluster is the Schema for the tinkerbellclusters API.
90+
type TinkerbellCluster struct {
91+
metav1.TypeMeta `json:",inline"`
92+
metav1.ObjectMeta `json:"metadata,omitempty"`
93+
94+
Spec TinkerbellClusterSpec `json:"spec,omitempty"`
95+
Status TinkerbellClusterStatus `json:"status,omitempty"`
96+
}
97+
98+
// +kubebuilder:object:root=true
99+
100+
// TinkerbellClusterList contains a list of TinkerbellCluster.
101+
type TinkerbellClusterList struct {
102+
metav1.TypeMeta `json:",inline"`
103+
metav1.ListMeta `json:"metadata,omitempty"`
104+
Items []TinkerbellCluster `json:"items"`
105+
}
106+
107+
//nolint:gochecknoinits
108+
func init() {
109+
SchemeBuilder.Register(&TinkerbellCluster{}, &TinkerbellClusterList{})
110+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
Copyright 2022 The Tinkerbell 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 v1beta1
18+
19+
import (
20+
"strings"
21+
22+
"k8s.io/apimachinery/pkg/runtime"
23+
ctrl "sigs.k8s.io/controller-runtime"
24+
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
25+
)
26+
27+
const (
28+
osUbuntu = "ubuntu"
29+
defaultUbuntuVersion = "20.04"
30+
)
31+
32+
var _ admission.Validator = &TinkerbellCluster{}
33+
34+
// SetupWebhookWithManager sets up and registers the webhook with the manager.
35+
func (c *TinkerbellCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
36+
return ctrl.NewWebhookManagedBy(mgr).For(c).Complete() //nolint:wrapcheck
37+
}
38+
39+
// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-tinkerbellcluster,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=tinkerbellclusters,versions=v1beta1,name=validation.tinkerbellcluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1
40+
// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-tinkerbellcluster,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=tinkerbellclusters,versions=v1beta1,name=default.tinkerbellcluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1
41+
42+
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
43+
func (c *TinkerbellCluster) ValidateCreate() (admission.Warnings, error) {
44+
return nil, nil
45+
}
46+
47+
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
48+
func (c *TinkerbellCluster) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
49+
return nil, nil
50+
}
51+
52+
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
53+
func (c *TinkerbellCluster) ValidateDelete() (admission.Warnings, error) {
54+
return nil, nil
55+
}
56+
57+
func defaultVersionForOSDistro(distro string) string {
58+
if strings.ToLower(distro) == osUbuntu {
59+
return defaultUbuntuVersion
60+
}
61+
62+
return ""
63+
}
64+
65+
// Default implements webhookutil.defaulter so a webhook will be registered for the type.
66+
func (c *TinkerbellCluster) Default() {
67+
if c.Spec.ImageLookupFormat == "" {
68+
c.Spec.ImageLookupFormat = "{{.BaseRegistry}}/{{.OSDistro}}-{{.OSVersion}}:{{.KubernetesVersion}}.gz"
69+
}
70+
71+
if c.Spec.ImageLookupOSVersion == "" {
72+
c.Spec.ImageLookupOSVersion = defaultVersionForOSDistro(c.Spec.ImageLookupOSDistro)
73+
}
74+
}

0 commit comments

Comments
 (0)