Skip to content

Commit

Permalink
fix interfaces
Browse files Browse the repository at this point in the history
Signed-off-by: cpanato <ctadeu@gmail.com>
  • Loading branch information
cpanato committed May 15, 2024
1 parent 8501be3 commit 94f22b1
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 41 deletions.
10 changes: 6 additions & 4 deletions cloud/services/compute/firewalls/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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 @@ -211,7 +211,7 @@ func TestService_createOrGetInstance(t *testing.T) {
mockInstance: &cloud.MockInstances{
ProjectRouter: &cloud.SingleProjectRouter{ID: "proj-id"},
Objects: map[meta.Key]*cloud.MockInstancesObj{},
GetHook: func(ctx context.Context, key *meta.Key, m *cloud.MockInstances) (bool, *compute.Instance, error) {
GetHook: func(ctx context.Context, key *meta.Key, m *cloud.MockInstances, _ ...cloud.Option) (bool, *compute.Instance, error) {

Check warning on line 214 in cloud/services/compute/instances/reconcile_test.go

View workflow job for this annotation

GitHub Actions / lint

unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
return true, &compute.Instance{}, &googleapi.Error{Code: http.StatusBadRequest}
},
},
Expand Down
14 changes: 8 additions & 6 deletions cloud/services/compute/instances/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions cloud/services/compute/loadbalancers/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ 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"
)
Expand Down
42 changes: 22 additions & 20 deletions cloud/services/compute/loadbalancers/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 8 additions & 6 deletions cloud/services/compute/networks/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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 @@ -111,7 +111,7 @@ func TestService_Reconcile(t *testing.T) {
mockSubnetworks: &cloud.MockSubnetworks{
ProjectRouter: &cloud.SingleProjectRouter{ID: "my-proj"},
Objects: map[meta.Key]*cloud.MockSubnetworksObj{},
GetHook: func(ctx context.Context, key *meta.Key, m *cloud.MockSubnetworks) (bool, *compute.Subnetwork, error) {
GetHook: func(ctx context.Context, key *meta.Key, m *cloud.MockSubnetworks, _ ...cloud.Option) (bool, *compute.Subnetwork, error) {

Check warning on line 114 in cloud/services/compute/subnets/reconcile_test.go

View workflow job for this annotation

GitHub Actions / lint

unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
return true, &compute.Subnetwork{}, &googleapi.Error{Code: http.StatusBadRequest}
},
},
Expand Down
8 changes: 5 additions & 3 deletions cloud/services/compute/subnets/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 94f22b1

Please sign in to comment.