diff --git a/cloud/services/compute/firewalls/reconcile.go b/cloud/services/compute/firewalls/reconcile.go index 9c1daa07f..d76add182 100644 --- a/cloud/services/compute/firewalls/reconcile.go +++ b/cloud/services/compute/firewalls/reconcile.go @@ -20,6 +20,7 @@ import ( "context" "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" + "sigs.k8s.io/cluster-api-provider-gcp/cloud/gcperrors" "sigs.k8s.io/controller-runtime/pkg/log" ) diff --git a/cloud/services/compute/firewalls/service.go b/cloud/services/compute/firewalls/service.go index 81360ad92..1e5ee5736 100644 --- a/cloud/services/compute/firewalls/service.go +++ b/cloud/services/compute/firewalls/service.go @@ -19,16 +19,18 @@ package firewalls import ( "context" + k8scloud "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" "google.golang.org/api/compute/v1" + "sigs.k8s.io/cluster-api-provider-gcp/cloud" ) type firewallsInterface interface { - Get(ctx context.Context, key *meta.Key) (*compute.Firewall, error) - Insert(ctx context.Context, key *meta.Key, obj *compute.Firewall) error - Update(ctx context.Context, key *meta.Key, obj *compute.Firewall) error - Delete(ctx context.Context, key *meta.Key) error + Get(ctx context.Context, key *meta.Key, options ...k8scloud.Option) (*compute.Firewall, error) + Insert(ctx context.Context, key *meta.Key, obj *compute.Firewall, options ...k8scloud.Option) error + Update(ctx context.Context, key *meta.Key, obj *compute.Firewall, options ...k8scloud.Option) error + Delete(ctx context.Context, key *meta.Key, options ...k8scloud.Option) error } // Scope is an interfaces that hold used methods. diff --git a/cloud/services/compute/instances/reconcile.go b/cloud/services/compute/instances/reconcile.go index 623fd992f..76277d072 100644 --- a/cloud/services/compute/instances/reconcile.go +++ b/cloud/services/compute/instances/reconcile.go @@ -20,14 +20,17 @@ import ( "context" "fmt" + "github.com/pkg/errors" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" - "github.com/pkg/errors" "google.golang.org/api/compute/v1" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-gcp/cloud/gcperrors" "sigs.k8s.io/controller-runtime/pkg/log" ) diff --git a/cloud/services/compute/instances/reconcile_test.go b/cloud/services/compute/instances/reconcile_test.go index e12d360a9..fba51b7a6 100644 --- a/cloud/services/compute/instances/reconcile_test.go +++ b/cloud/services/compute/instances/reconcile_test.go @@ -27,10 +27,12 @@ import ( "github.com/google/go-cmp/cmp" "google.golang.org/api/compute/v1" "google.golang.org/api/googleapi" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/scheme" "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" @@ -211,7 +213,7 @@ func TestService_createOrGetInstance(t *testing.T) { mockInstance: &cloud.MockInstances{ ProjectRouter: &cloud.SingleProjectRouter{ID: "proj-id"}, Objects: map[meta.Key]*cloud.MockInstancesObj{}, - GetHook: func(_ context.Context, _ *meta.Key, _ *cloud.MockInstances) (bool, *compute.Instance, error) { + GetHook: func(_ context.Context, _ *meta.Key, _ *cloud.MockInstances, _ ...cloud.Option) (bool, *compute.Instance, error) { return true, &compute.Instance{}, &googleapi.Error{Code: http.StatusBadRequest} }, }, diff --git a/cloud/services/compute/instances/service.go b/cloud/services/compute/instances/service.go index b8ec3a2a4..a5a415d52 100644 --- a/cloud/services/compute/instances/service.go +++ b/cloud/services/compute/instances/service.go @@ -21,22 +21,24 @@ import ( "github.com/go-logr/logr" + k8scloud "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" "google.golang.org/api/compute/v1" + "sigs.k8s.io/cluster-api-provider-gcp/cloud" ) type instancesInterface interface { - Get(ctx context.Context, key *meta.Key) (*compute.Instance, error) - Insert(ctx context.Context, key *meta.Key, obj *compute.Instance) error - Delete(ctx context.Context, key *meta.Key) error + Get(ctx context.Context, key *meta.Key, options ...k8scloud.Option) (*compute.Instance, error) + Insert(ctx context.Context, key *meta.Key, obj *compute.Instance, options ...k8scloud.Option) error + Delete(ctx context.Context, key *meta.Key, options ...k8scloud.Option) error } type instancegroupsInterface interface { - AddInstances(ctx context.Context, key *meta.Key, req *compute.InstanceGroupsAddInstancesRequest) error - ListInstances(ctx context.Context, key *meta.Key, req *compute.InstanceGroupsListInstancesRequest, fl *filter.F) ([]*compute.InstanceWithNamedPorts, error) - RemoveInstances(ctx context.Context, key *meta.Key, req *compute.InstanceGroupsRemoveInstancesRequest) error + AddInstances(ctx context.Context, key *meta.Key, req *compute.InstanceGroupsAddInstancesRequest, options ...k8scloud.Option) error + ListInstances(ctx context.Context, key *meta.Key, req *compute.InstanceGroupsListInstancesRequest, fl *filter.F, options ...k8scloud.Option) ([]*compute.InstanceWithNamedPorts, error) + RemoveInstances(ctx context.Context, key *meta.Key, req *compute.InstanceGroupsRemoveInstancesRequest, options ...k8scloud.Option) error } // Scope is an interfaces that hold used methods. diff --git a/cloud/services/compute/loadbalancers/reconcile.go b/cloud/services/compute/loadbalancers/reconcile.go index 7a2e69e30..e6b723ec0 100644 --- a/cloud/services/compute/loadbalancers/reconcile.go +++ b/cloud/services/compute/loadbalancers/reconcile.go @@ -21,6 +21,7 @@ import ( "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" "google.golang.org/api/compute/v1" + "k8s.io/utils/ptr" "sigs.k8s.io/cluster-api-provider-gcp/cloud/gcperrors" "sigs.k8s.io/controller-runtime/pkg/log" diff --git a/cloud/services/compute/loadbalancers/reconcile_test.go b/cloud/services/compute/loadbalancers/reconcile_test.go index 27982675b..0a66157fd 100644 --- a/cloud/services/compute/loadbalancers/reconcile_test.go +++ b/cloud/services/compute/loadbalancers/reconcile_test.go @@ -96,7 +96,7 @@ func TestService_createOrGetInstanceGroup(t *testing.T) { mockInstanceGroup: &cloud.MockInstanceGroups{ ProjectRouter: &cloud.SingleProjectRouter{ID: "proj-id"}, Objects: map[meta.Key]*cloud.MockInstanceGroupsObj{}, - GetHook: func(_ context.Context, _ *meta.Key, _ *cloud.MockInstanceGroups) (bool, *compute.InstanceGroup, error) { + GetHook: func(_ context.Context, _ *meta.Key, _ *cloud.MockInstanceGroups, _ ...cloud.Option) (bool, *compute.InstanceGroup, error) { return true, &compute.InstanceGroup{}, &googleapi.Error{Code: http.StatusBadRequest} }, }, diff --git a/cloud/services/compute/loadbalancers/service.go b/cloud/services/compute/loadbalancers/service.go index 41e256d2d..8a1067054 100644 --- a/cloud/services/compute/loadbalancers/service.go +++ b/cloud/services/compute/loadbalancers/service.go @@ -19,48 +19,50 @@ package loadbalancers import ( "context" + k8scloud "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" "google.golang.org/api/compute/v1" + "sigs.k8s.io/cluster-api-provider-gcp/cloud" ) type addressesInterface interface { - Get(ctx context.Context, key *meta.Key) (*compute.Address, error) - Insert(ctx context.Context, key *meta.Key, obj *compute.Address) error - Delete(ctx context.Context, key *meta.Key) error + Get(ctx context.Context, key *meta.Key, options ...k8scloud.Option) (*compute.Address, error) + Insert(ctx context.Context, key *meta.Key, obj *compute.Address, options ...k8scloud.Option) error + Delete(ctx context.Context, key *meta.Key, options ...k8scloud.Option) error } type backendservicesInterface interface { - Get(ctx context.Context, key *meta.Key) (*compute.BackendService, error) - Insert(ctx context.Context, key *meta.Key, obj *compute.BackendService) error - Update(context.Context, *meta.Key, *compute.BackendService) error - Delete(ctx context.Context, key *meta.Key) error + Get(ctx context.Context, key *meta.Key, options ...k8scloud.Option) (*compute.BackendService, error) + Insert(ctx context.Context, key *meta.Key, obj *compute.BackendService, options ...k8scloud.Option) error + Update(ctx context.Context, key *meta.Key, obj *compute.BackendService, options ...k8scloud.Option) error + Delete(ctx context.Context, key *meta.Key, options ...k8scloud.Option) error } type forwardingrulesInterface interface { - Get(ctx context.Context, key *meta.Key) (*compute.ForwardingRule, error) - Insert(ctx context.Context, key *meta.Key, obj *compute.ForwardingRule) error - Delete(ctx context.Context, key *meta.Key) error + Get(ctx context.Context, key *meta.Key, options ...k8scloud.Option) (*compute.ForwardingRule, error) + Insert(ctx context.Context, key *meta.Key, obj *compute.ForwardingRule, options ...k8scloud.Option) error + Delete(ctx context.Context, key *meta.Key, options ...k8scloud.Option) error } type healthchecksInterface interface { - Get(ctx context.Context, key *meta.Key) (*compute.HealthCheck, error) - Insert(ctx context.Context, key *meta.Key, obj *compute.HealthCheck) error - Delete(ctx context.Context, key *meta.Key) error + Get(ctx context.Context, key *meta.Key, options ...k8scloud.Option) (*compute.HealthCheck, error) + Insert(ctx context.Context, key *meta.Key, obj *compute.HealthCheck, options ...k8scloud.Option) error + Delete(ctx context.Context, key *meta.Key, options ...k8scloud.Option) error } type instancegroupsInterface interface { - Get(ctx context.Context, key *meta.Key) (*compute.InstanceGroup, error) - List(ctx context.Context, zone string, fl *filter.F) ([]*compute.InstanceGroup, error) - Insert(ctx context.Context, key *meta.Key, obj *compute.InstanceGroup) error - Delete(ctx context.Context, key *meta.Key) error + Get(ctx context.Context, key *meta.Key, options ...k8scloud.Option) (*compute.InstanceGroup, error) + List(ctx context.Context, zone string, fl *filter.F, options ...k8scloud.Option) ([]*compute.InstanceGroup, error) + Insert(ctx context.Context, key *meta.Key, obj *compute.InstanceGroup, options ...k8scloud.Option) error + Delete(ctx context.Context, key *meta.Key, options ...k8scloud.Option) error } type targettcpproxiesInterface interface { - Get(ctx context.Context, key *meta.Key) (*compute.TargetTcpProxy, error) - Insert(ctx context.Context, key *meta.Key, obj *compute.TargetTcpProxy) error - Delete(ctx context.Context, key *meta.Key) error + Get(ctx context.Context, key *meta.Key, options ...k8scloud.Option) (*compute.TargetTcpProxy, error) + Insert(ctx context.Context, key *meta.Key, obj *compute.TargetTcpProxy, options ...k8scloud.Option) error + Delete(ctx context.Context, key *meta.Key, options ...k8scloud.Option) error } // Scope is an interfaces that hold used methods. diff --git a/cloud/services/compute/networks/reconcile.go b/cloud/services/compute/networks/reconcile.go index 0beaaaf68..192c2ccfc 100644 --- a/cloud/services/compute/networks/reconcile.go +++ b/cloud/services/compute/networks/reconcile.go @@ -21,7 +21,9 @@ import ( "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" "google.golang.org/api/compute/v1" + "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1" "sigs.k8s.io/cluster-api-provider-gcp/cloud/gcperrors" "sigs.k8s.io/controller-runtime/pkg/log" diff --git a/cloud/services/compute/networks/service.go b/cloud/services/compute/networks/service.go index 6d01d0faf..a21eabf92 100644 --- a/cloud/services/compute/networks/service.go +++ b/cloud/services/compute/networks/service.go @@ -19,21 +19,23 @@ package networks import ( "context" + k8scloud "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" "google.golang.org/api/compute/v1" + "sigs.k8s.io/cluster-api-provider-gcp/cloud" ) type networksInterface interface { - Get(ctx context.Context, key *meta.Key) (*compute.Network, error) - Insert(ctx context.Context, key *meta.Key, obj *compute.Network) error - Delete(ctx context.Context, key *meta.Key) error + Get(ctx context.Context, key *meta.Key, options ...k8scloud.Option) (*compute.Network, error) + Insert(ctx context.Context, key *meta.Key, obj *compute.Network, options ...k8scloud.Option) error + Delete(ctx context.Context, key *meta.Key, options ...k8scloud.Option) error } type routersInterface interface { - Get(ctx context.Context, key *meta.Key) (*compute.Router, error) - Insert(ctx context.Context, key *meta.Key, obj *compute.Router) error - Delete(ctx context.Context, key *meta.Key) error + Get(ctx context.Context, key *meta.Key, options ...k8scloud.Option) (*compute.Router, error) + Insert(ctx context.Context, key *meta.Key, obj *compute.Router, options ...k8scloud.Option) error + Delete(ctx context.Context, key *meta.Key, options ...k8scloud.Option) error } // Scope is an interfaces that hold used methods. diff --git a/cloud/services/compute/subnets/reconcile.go b/cloud/services/compute/subnets/reconcile.go index 2a186d6aa..95705a08d 100644 --- a/cloud/services/compute/subnets/reconcile.go +++ b/cloud/services/compute/subnets/reconcile.go @@ -21,6 +21,7 @@ import ( "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" "google.golang.org/api/compute/v1" + "sigs.k8s.io/cluster-api-provider-gcp/cloud/gcperrors" "sigs.k8s.io/controller-runtime/pkg/log" ) diff --git a/cloud/services/compute/subnets/reconcile_test.go b/cloud/services/compute/subnets/reconcile_test.go index d3cc14b26..e50995baf 100644 --- a/cloud/services/compute/subnets/reconcile_test.go +++ b/cloud/services/compute/subnets/reconcile_test.go @@ -26,9 +26,11 @@ import ( "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" "google.golang.org/api/compute/v1" "google.golang.org/api/googleapi" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/scheme" "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" @@ -111,7 +113,7 @@ func TestService_Reconcile(t *testing.T) { mockSubnetworks: &cloud.MockSubnetworks{ ProjectRouter: &cloud.SingleProjectRouter{ID: "my-proj"}, Objects: map[meta.Key]*cloud.MockSubnetworksObj{}, - GetHook: func(_ context.Context, _ *meta.Key, _ *cloud.MockSubnetworks) (bool, *compute.Subnetwork, error) { + GetHook: func(_ context.Context, _ *meta.Key, _ *cloud.MockSubnetworks, _ ...cloud.Option) (bool, *compute.Subnetwork, error) { return true, &compute.Subnetwork{}, &googleapi.Error{Code: http.StatusBadRequest} }, }, diff --git a/cloud/services/compute/subnets/service.go b/cloud/services/compute/subnets/service.go index 14ddad9e1..565442d20 100644 --- a/cloud/services/compute/subnets/service.go +++ b/cloud/services/compute/subnets/service.go @@ -19,15 +19,17 @@ package subnets import ( "context" + k8scloud "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" "google.golang.org/api/compute/v1" + "sigs.k8s.io/cluster-api-provider-gcp/cloud" ) type subnetsInterface interface { - Get(ctx context.Context, key *meta.Key) (*compute.Subnetwork, error) - Insert(ctx context.Context, key *meta.Key, obj *compute.Subnetwork) error - Delete(ctx context.Context, key *meta.Key) error + Get(ctx context.Context, key *meta.Key, options ...k8scloud.Option) (*compute.Subnetwork, error) + Insert(ctx context.Context, key *meta.Key, obj *compute.Subnetwork, options ...k8scloud.Option) error + Delete(ctx context.Context, key *meta.Key, options ...k8scloud.Option) error } // Scope is an interfaces that hold used methods.