Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ linters:
text: (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
- path: (.+)\.go$
text: (G104|G307)

# Temporary exclusion during upgrade from CAPI 1.10 to CAPI 1.11
- linters:
- staticcheck
text: 'SA1019: .* This package is deprecated and is going to be removed when support for v1beta1 will be dropped'

paths:
- zz_generated.*\.go$
- .*conversion.*\.go$
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

# Build the manager binary
FROM golang:1.23.9@sha256:1cc01afde44821895ea712b5b4b802ef3c3ddeb7a7bb3f2e69c19bbc5877dace as builder
FROM golang:1.24.6@sha256:ec428de7d307550fb36d383524328a30701b1f5c3e72c30d35ab9c64498441bb as builder
WORKDIR /workspace

# Run this with docker build --build_arg $(go env GOPROXY) to override the goproxy
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export GOPROXY
export GO111MODULE=on

# Go version
GOLANG_VERSION := 1.23.9
GOLANG_VERSION := 1.24.6

# Kubebuilder
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.32.0
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.33.0
export KUBEBUILDER_CONTROLPLANE_START_TIMEOUT ?=60s
export KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT ?=60s

Expand Down Expand Up @@ -99,7 +99,7 @@ KUBECTL := $(TOOLS_BIN_DIR)/$(KUBECTL_BIN)-$(KUBECTL_VER)

TIMEOUT := $(shell command -v timeout || command -v gtimeout)

SETUP_ENVTEST_VER := v0.0.0-20240522175850-2e9781e9fc60
SETUP_ENVTEST_VER := v0.0.0-20250827153409-7085be7a745a
SETUP_ENVTEST_BIN := setup-envtest
SETUP_ENVTEST := $(TOOLS_BIN_DIR)/$(SETUP_ENVTEST_BIN)

Expand Down
10 changes: 5 additions & 5 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ settings = {
"deploy_cert_manager": True,
"preload_images_for_kind": True,
"kind_cluster_name": "capg",
"capi_version": "v1.7.3",
"capi_version": "v1.11.0",
"cert_manager_version": "v1.14.4",
"kubernetes_version": "v1.29.3",
"kubernetes_version": "v1.33.2",
}

keys = ["GCP_B64ENCODED_CREDENTIALS"]
Expand Down Expand Up @@ -98,9 +98,9 @@ def validate_auth():

tilt_helper_dockerfile_header = """
# Tilt image
FROM golang:1.23.6 as tilt-helper
FROM golang:1.24.6 as tilt-helper
# Install delve. Note this should be kept in step with the Go release minor version.
RUN go install github.com/go-delve/delve/cmd/dlv@v1.23
RUN go install github.com/go-delve/delve/cmd/dlv@v1.24
# Support live reloading with Tilt
RUN wget --output-document /restart.sh --quiet https://raw.githubusercontent.com/tilt-dev/rerun-process-wrapper/master/restart.sh && \
wget --output-document /start.sh --quiet https://raw.githubusercontent.com/tilt-dev/rerun-process-wrapper/master/start.sh && \
Expand All @@ -109,7 +109,7 @@ RUN wget --output-document /restart.sh --quiet https://raw.githubusercontent.com
"""

tilt_dockerfile_header = """
FROM golang:1.23.6 as tilt
FROM golang:1.24.6 as tilt
WORKDIR /
COPY --from=tilt-helper /process.txt .
COPY --from=tilt-helper /start.sh .
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/gcpcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/gcpclustertemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
)

// GCPClusterTemplateSpec defines the desired state of GCPClusterTemplate.
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1beta1
import (
"fmt"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
)

// GCPMachineTemplateResource describes the data needed to create am GCPMachine from a template.
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cloud/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud"
corev1 "k8s.io/api/core/v1"
infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
)

// Cloud alias for cloud.Cloud interface.
Expand Down
2 changes: 1 addition & 1 deletion cloud/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"k8s.io/utils/ptr"
infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-gcp/cloud"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
"sigs.k8s.io/cluster-api/util/patch"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down
13 changes: 9 additions & 4 deletions cloud/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ import (
"sigs.k8s.io/cluster-api-provider-gcp/cloud"
"sigs.k8s.io/cluster-api-provider-gcp/cloud/providerid"
"sigs.k8s.io/cluster-api-provider-gcp/cloud/services/shared"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/util"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
"sigs.k8s.io/cluster-api/util/patch"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -138,18 +137,24 @@ func (m *MachineScope) ControlPlaneGroupName() string {

// IsControlPlane returns true if the machine is a control plane.
func (m *MachineScope) IsControlPlane() bool {
return util.IsControlPlaneMachine(m.Machine)
return IsControlPlaneMachine(m.Machine)
}

// Role returns the machine role from the labels.
func (m *MachineScope) Role() string {
if util.IsControlPlaneMachine(m.Machine) {
if IsControlPlaneMachine(m.Machine) {
return "control-plane"
}

return "node"
}

// IsControlPlaneMachine checks machine is a control plane node.
func IsControlPlaneMachine(machine *clusterv1.Machine) bool {
_, ok := machine.Labels[clusterv1.MachineControlPlaneLabel]
return ok
}

// GetInstanceID returns the GCPMachine instance id by parsing Spec.ProviderID.
func (m *MachineScope) GetInstanceID() *string {
parsed, err := NewProviderID(m.GetProviderID())
Expand Down
2 changes: 1 addition & 1 deletion cloud/scope/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/stretchr/testify/assert"
infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

Expand Down
2 changes: 1 addition & 1 deletion cloud/scope/managedcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-gcp/cloud"
infrav1exp "sigs.k8s.io/cluster-api-provider-gcp/exp/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
"sigs.k8s.io/cluster-api/util/patch"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down
13 changes: 6 additions & 7 deletions cloud/scope/managedcontrolplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ import (

"sigs.k8s.io/cluster-api-provider-gcp/util/location"

"sigs.k8s.io/cluster-api/util/conditions"
"sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"

container "cloud.google.com/go/container/apiv1"
credentials "cloud.google.com/go/iam/credentials/apiv1"
resourcemanager "cloud.google.com/go/resourcemanager/apiv3"
"github.com/pkg/errors"
infrav1exp "sigs.k8s.io/cluster-api-provider-gcp/exp/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterv1exp "sigs.k8s.io/cluster-api/exp/api/v1beta1"
"sigs.k8s.io/cluster-api/util/patch"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -123,7 +122,7 @@ type ManagedControlPlaneScope struct {
credentialsClient *credentials.IamCredentialsClient
credential *Credential

AllMachinePools []clusterv1exp.MachinePool
AllMachinePools []clusterv1.MachinePool
AllManagedMachinePools []infrav1exp.GCPManagedMachinePool
}

Expand Down Expand Up @@ -179,14 +178,14 @@ func (s *ManagedControlPlaneScope) GetCredential() *Credential {
}

// GetAllNodePools gets all node pools for the control plane.
func (s *ManagedControlPlaneScope) GetAllNodePools(ctx context.Context) ([]infrav1exp.GCPManagedMachinePool, []clusterv1exp.MachinePool, error) {
func (s *ManagedControlPlaneScope) GetAllNodePools(ctx context.Context) ([]infrav1exp.GCPManagedMachinePool, []clusterv1.MachinePool, error) {
if len(s.AllManagedMachinePools) == 0 {
listOptions := []client.ListOption{
client.InNamespace(s.GCPManagedControlPlane.Namespace),
client.MatchingLabels(map[string]string{clusterv1.ClusterNameLabel: s.Cluster.Name}),
}

machinePoolList := &clusterv1exp.MachinePoolList{}
machinePoolList := &clusterv1.MachinePoolList{}
if err := s.client.List(ctx, machinePoolList, listOptions...); err != nil {
return nil, nil, err
}
Expand Down
15 changes: 7 additions & 8 deletions cloud/scope/managedmachinepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@ import (
"sigs.k8s.io/cluster-api-provider-gcp/cloud"
"sigs.k8s.io/cluster-api-provider-gcp/util/location"

"sigs.k8s.io/cluster-api/util/conditions"
"sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"

compute "cloud.google.com/go/compute/apiv1"
container "cloud.google.com/go/container/apiv1"
"cloud.google.com/go/container/apiv1/containerpb"
"github.com/pkg/errors"
infrav1exp "sigs.k8s.io/cluster-api-provider-gcp/exp/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterv1exp "sigs.k8s.io/cluster-api/exp/api/v1beta1"
"sigs.k8s.io/cluster-api/util/patch"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand All @@ -45,7 +44,7 @@ type ManagedMachinePoolScopeParams struct {
InstanceGroupManagersClient *compute.InstanceGroupManagersClient
Client client.Client
Cluster *clusterv1.Cluster
MachinePool *clusterv1exp.MachinePool
MachinePool *clusterv1.MachinePool
GCPManagedCluster *infrav1exp.GCPManagedCluster
GCPManagedControlPlane *infrav1exp.GCPManagedControlPlane
GCPManagedMachinePool *infrav1exp.GCPManagedMachinePool
Expand Down Expand Up @@ -108,7 +107,7 @@ type ManagedMachinePoolScope struct {
patchHelper *patch.Helper

Cluster *clusterv1.Cluster
MachinePool *clusterv1exp.MachinePool
MachinePool *clusterv1.MachinePool
GCPManagedCluster *infrav1exp.GCPManagedCluster
GCPManagedControlPlane *infrav1exp.GCPManagedControlPlane
GCPManagedMachinePool *infrav1exp.GCPManagedMachinePool
Expand Down Expand Up @@ -167,7 +166,7 @@ func NodePoolResourceLabels(additionalLabels infrav1.Labels, clusterName string)
}

// ConvertToSdkNodePool converts a node pool to format that is used by GCP SDK.
func ConvertToSdkNodePool(nodePool infrav1exp.GCPManagedMachinePool, machinePool clusterv1exp.MachinePool, regional bool, clusterName string) *containerpb.NodePool {
func ConvertToSdkNodePool(nodePool infrav1exp.GCPManagedMachinePool, machinePool clusterv1.MachinePool, regional bool, clusterName string) *containerpb.NodePool {
replicas := *machinePool.Spec.Replicas
if regional {
if len(nodePool.Spec.NodeLocations) != 0 {
Expand Down Expand Up @@ -276,7 +275,7 @@ func ConvertToSdkNodePool(nodePool infrav1exp.GCPManagedMachinePool, machinePool
}

// ConvertToSdkNodePools converts node pools to format that is used by GCP SDK.
func ConvertToSdkNodePools(nodePools []infrav1exp.GCPManagedMachinePool, machinePools []clusterv1exp.MachinePool, regional bool, clusterName string) []*containerpb.NodePool {
func ConvertToSdkNodePools(nodePools []infrav1exp.GCPManagedMachinePool, machinePools []clusterv1.MachinePool, regional bool, clusterName string) []*containerpb.NodePool {
res := []*containerpb.NodePool{}
for i := range nodePools {
res = append(res, ConvertToSdkNodePool(nodePools[i], machinePools[i], regional, clusterName))
Expand Down
2 changes: 1 addition & 1 deletion cloud/scope/managedmachinepool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-gcp/cloud"
"sigs.k8s.io/cluster-api-provider-gcp/exp/api/v1beta1"
clusterv1exp "sigs.k8s.io/cluster-api/exp/api/v1beta1"
clusterv1exp "sigs.k8s.io/cluster-api/api/core/v1beta1"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cloud/services/compute/firewalls/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"k8s.io/utils/ptr"
infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-gcp/cloud/scope"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

Expand Down
2 changes: 1 addition & 1 deletion cloud/services/compute/instances/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (

infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-gcp/cloud/scope"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

Expand Down
2 changes: 1 addition & 1 deletion cloud/services/compute/loadbalancers/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"k8s.io/utils/ptr"
infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-gcp/cloud/scope"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

Expand Down
2 changes: 1 addition & 1 deletion cloud/services/compute/networks/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"k8s.io/utils/ptr"
infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-gcp/cloud/scope"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

Expand Down
2 changes: 1 addition & 1 deletion cloud/services/compute/subnets/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-gcp/cloud/scope"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

Expand Down
4 changes: 2 additions & 2 deletions cloud/services/container/clusters/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import (
"google.golang.org/grpc/codes"
infrav1exp "sigs.k8s.io/cluster-api-provider-gcp/exp/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-gcp/util/reconciler"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/util/conditions"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
"sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log"
)
Expand Down
4 changes: 2 additions & 2 deletions cloud/services/container/nodepools/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import (
"sigs.k8s.io/cluster-api-provider-gcp/cloud/services/shared"
infrav1exp "sigs.k8s.io/cluster-api-provider-gcp/exp/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-gcp/util/reconciler"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/util/conditions"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
"sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log"
)
Expand Down
2 changes: 1 addition & 1 deletion cloud/services/shared/machinepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"strings"

clusterv1exp "sigs.k8s.io/cluster-api/exp/api/v1beta1"
clusterv1exp "sigs.k8s.io/cluster-api/api/core/v1beta1"

"sigs.k8s.io/cluster-api-provider-gcp/cloud"
infrav1exp "sigs.k8s.io/cluster-api-provider-gcp/exp/api/v1beta1"
Expand Down
Loading