Skip to content

Commit 453f205

Browse files
authored
Merge pull request #557 from projectsveltos/revert-556-prep
Revert "(chore) postpone advancing to clusterAPI core v1beta2"
2 parents a1a0e38 + e2979ac commit 453f205

17 files changed

+75
-83
lines changed

api/v1beta1/accessrequest_type.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ package v1beta1
1919
import (
2020
corev1 "k8s.io/api/core/v1"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22-
23-
//nolint:staticcheck // SA1019: We are unable to update the dependency at this time.
24-
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
22+
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
2523
)
2624

2725
const (

config/crd/bases/lib.projectsveltos.io_accessrequests.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,19 @@ spec:
4444
ControlPlaneEndpoint represents the endpoint used to communicate with the
4545
management cluster controlplane endpoint. It will be used when generating the
4646
kubeconfig.
47+
minProperties: 1
4748
properties:
4849
host:
4950
description: host is the hostname on which the API server is serving.
5051
maxLength: 512
52+
minLength: 1
5153
type: string
5254
port:
5355
description: port is the port on which the API server is serving.
5456
format: int32
57+
maximum: 65535
58+
minimum: 1
5559
type: integer
56-
required:
57-
- host
58-
- port
5960
type: object
6061
name:
6162
description: |-

internal/test/helpers/external/cluster-api-const.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ package external
1515

1616
const (
1717
clusterAPIGroup = "cluster.x-k8s.io"
18-
clusterAPITestVersion = "v1beta1"
18+
clusterAPITestVersion = "v1beta2"
1919
)

lib/cel/cel_suite_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ import (
2828
"k8s.io/apimachinery/pkg/runtime"
2929
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
3030
"k8s.io/klog/v2"
31-
32-
//nolint:staticcheck // SA1019: We are unable to update the dependency at this time.
33-
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
31+
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3432
ctrl "sigs.k8s.io/controller-runtime"
3533

3634
"github.com/projectsveltos/libsveltos/internal/test/helpers"

lib/clusterproxy/cluster_utils.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ import (
3333
"k8s.io/apimachinery/pkg/types"
3434
"k8s.io/client-go/rest"
3535
"k8s.io/client-go/tools/clientcmd"
36-
37-
//nolint:staticcheck // SA1019: We are unable to update the dependency at this time.
38-
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
36+
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3937
"sigs.k8s.io/controller-runtime/pkg/client"
4038

4139
libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1"
@@ -105,7 +103,10 @@ func isCAPIClusterPaused(ctx context.Context, c client.Client,
105103
return false, err
106104
}
107105

108-
paused := cluster.Spec.Paused
106+
paused := false
107+
if cluster.Spec.Paused != nil {
108+
paused = *cluster.Spec.Paused
109+
}
109110

110111
return paused, nil
111112
}

lib/clusterproxy/cluster_utils_test.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ import (
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727
"k8s.io/apimachinery/pkg/types"
2828
"k8s.io/klog/v2/textlogger"
29-
30-
//nolint:staticcheck // SA1019: We are unable to update the dependency at this time.
31-
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
29+
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3230
"sigs.k8s.io/controller-runtime/pkg/client"
3331
"sigs.k8s.io/controller-runtime/pkg/client/fake"
3432

@@ -46,16 +44,20 @@ var _ = Describe("Cluster utils", func() {
4644
BeforeEach(func() {
4745
namespace = "cluster-utils" + randomString()
4846

47+
paused := true
48+
initialized := true
4949
cluster = &clusterv1.Cluster{
5050
ObjectMeta: metav1.ObjectMeta{
5151
Name: randomString(),
5252
Namespace: namespace,
5353
},
5454
Spec: clusterv1.ClusterSpec{
55-
Paused: true,
55+
Paused: &paused,
5656
},
5757
Status: clusterv1.ClusterStatus{
58-
ControlPlaneReady: true,
58+
Initialization: clusterv1.ClusterInitializationStatus{
59+
ControlPlaneInitialized: &initialized,
60+
},
5961
},
6062
}
6163

@@ -93,7 +95,7 @@ var _ = Describe("Cluster utils", func() {
9395

9496
It("IsClusterPaused returns false when Spec.Paused is set to false", func() {
9597
paused := false
96-
cluster.Spec.Paused = paused
98+
cluster.Spec.Paused = &paused
9799
sveltosCluster.Spec.Paused = paused
98100
initObjects := []client.Object{
99101
cluster, sveltosCluster,
@@ -541,6 +543,7 @@ var _ = Describe("Cluster utils", func() {
541543

542544
onboardAnnotation := randomString()
543545

546+
initialized := true
544547
matchingCapiCluster := &clusterv1.Cluster{
545548
ObjectMeta: metav1.ObjectMeta{
546549
Name: randomString(),
@@ -551,7 +554,9 @@ var _ = Describe("Cluster utils", func() {
551554
},
552555
},
553556
Status: clusterv1.ClusterStatus{
554-
ControlPlaneReady: true,
557+
Initialization: clusterv1.ClusterInitializationStatus{
558+
ControlPlaneInitialized: &initialized,
559+
},
555560
},
556561
}
557562

@@ -563,7 +568,9 @@ var _ = Describe("Cluster utils", func() {
563568
Annotations: map[string]string{},
564569
},
565570
Status: clusterv1.ClusterStatus{
566-
ControlPlaneReady: true,
571+
Initialization: clusterv1.ClusterInitializationStatus{
572+
ControlPlaneInitialized: &initialized,
573+
},
567574
},
568575
}
569576

lib/clusterproxy/clusterproxy.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ import (
2929
"k8s.io/apimachinery/pkg/types"
3030
"k8s.io/client-go/rest"
3131
"k8s.io/client-go/tools/clientcmd"
32-
33-
//nolint:staticcheck // SA1019: We are unable to update the dependency at this time.
34-
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
32+
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3533
utilkubeconfig "sigs.k8s.io/cluster-api/util/kubeconfig"
3634
"sigs.k8s.io/controller-runtime/pkg/client"
3735

@@ -330,16 +328,11 @@ func isCAPIClusterReadyToBeConfigured(ctx context.Context, c client.Client,
330328
}
331329

332330
func isCAPIClusterReady(capiCluster *clusterv1.Cluster) bool {
333-
for i := range capiCluster.Status.Conditions {
334-
c := capiCluster.Status.Conditions[i]
335-
if c.Type == clusterv1.ControlPlaneInitializedCondition &&
336-
c.Status == corev1.ConditionTrue {
337-
338-
return true
339-
}
331+
if capiCluster.Status.Initialization.ControlPlaneInitialized != nil {
332+
return *capiCluster.Status.Initialization.ControlPlaneInitialized
340333
}
341334

342-
return capiCluster.Status.ControlPlaneReady
335+
return false
343336
}
344337

345338
// GetMachinesForCluster find all Machines for a given CAPI Cluster.

lib/clusterproxy/clusterproxy_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ import (
3333
"k8s.io/apimachinery/pkg/types"
3434
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
3535
"k8s.io/klog/v2/textlogger"
36-
37-
//nolint:staticcheck // SA1019: We are unable to update the dependency at this time.
38-
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
36+
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3937
"sigs.k8s.io/controller-runtime/pkg/client"
4038
"sigs.k8s.io/controller-runtime/pkg/client/fake"
4139

@@ -227,7 +225,9 @@ var _ = Describe("clusterproxy ", func() {
227225

228226
It("IsCAPIClusterReadyToBeConfigured returns false for a cluster with Status.Initialization.ControlPlaneInitialized set to false", func() {
229227
initialized := false
230-
cluster.Status.ControlPlaneReady = initialized
228+
cluster.Status.Initialization = clusterv1.ClusterInitializationStatus{
229+
ControlPlaneInitialized: &initialized,
230+
}
231231

232232
initObjects := []client.Object{
233233
cluster,
@@ -244,7 +244,9 @@ var _ = Describe("clusterproxy ", func() {
244244

245245
It("IsCAPIClusterReadyToBeConfigured returns true for a cluster with Status.Initialization.ControlPlaneInitialized set to true", func() {
246246
initialized := true
247-
cluster.Status.ControlPlaneReady = initialized
247+
cluster.Status.Initialization = clusterv1.ClusterInitializationStatus{
248+
ControlPlaneInitialized: &initialized,
249+
}
248250
initObjects := []client.Object{
249251
cluster,
250252
}
@@ -261,7 +263,9 @@ var _ = Describe("clusterproxy ", func() {
261263
It("IsCAPIClusterReadyToBeConfigured returns false when there are no ready replicas", func() {
262264
initialized := false
263265
cluster.Status = clusterv1.ClusterStatus{
264-
ControlPlaneReady: initialized,
266+
Initialization: clusterv1.ClusterInitializationStatus{
267+
ControlPlaneInitialized: &initialized,
268+
},
265269
}
266270

267271
initObjects := []client.Object{

lib/crd/accessrequests.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,19 @@ spec:
6262
ControlPlaneEndpoint represents the endpoint used to communicate with the
6363
management cluster controlplane endpoint. It will be used when generating the
6464
kubeconfig.
65+
minProperties: 1
6566
properties:
6667
host:
6768
description: host is the hostname on which the API server is serving.
6869
maxLength: 512
70+
minLength: 1
6971
type: string
7072
port:
7173
description: port is the port on which the API server is serving.
7274
format: int32
75+
maximum: 65535
76+
minimum: 1
7377
type: integer
74-
required:
75-
- host
76-
- port
7778
type: object
7879
name:
7980
description: |-

lib/crd/crd_suite_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ import (
3030
"k8s.io/apimachinery/pkg/runtime"
3131
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
3232
"k8s.io/klog/v2"
33-
34-
//nolint:staticcheck // SA1019: We are unable to update the dependency at this time.
35-
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
33+
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3634
ctrl "sigs.k8s.io/controller-runtime"
3735

3836
"github.com/projectsveltos/libsveltos/internal/test/helpers"

0 commit comments

Comments
 (0)