Skip to content

Commit 80c55d2

Browse files
authored
fix: update method receiver name (#136)
Updated the method receiver name to use the Go idiom of the first letter of the corresponding type.
1 parent db26abb commit 80c55d2

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

internal/provider/instances_v2.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ type InstancesV2 struct {
2424

2525
// InstanceExists checks whether the provided Kubernetes node exists as instance
2626
// in Oxide.
27-
func (c *InstancesV2) InstanceExists(ctx context.Context, node *v1.Node) (bool, error) {
27+
func (i *InstancesV2) InstanceExists(ctx context.Context, node *v1.Node) (bool, error) {
2828
instanceID := strings.TrimPrefix(node.Spec.ProviderID, "oxide://")
2929

30-
if _, err := c.client.InstanceView(ctx, oxide.InstanceViewParams{
30+
if _, err := i.client.InstanceView(ctx, oxide.InstanceViewParams{
3131
Instance: oxide.NameOrId(instanceID),
3232
}); err != nil {
3333
if strings.Contains(err.Error(), "NotFound") {
@@ -42,7 +42,7 @@ func (c *InstancesV2) InstanceExists(ctx context.Context, node *v1.Node) (bool,
4242

4343
// InstanceMetadata populates the metadata for the provided node, notably
4444
// setting its provider ID.
45-
func (c *InstancesV2) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloudprovider.InstanceMetadata, error) {
45+
func (i *InstancesV2) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloudprovider.InstanceMetadata, error) {
4646
var (
4747
err error
4848
instance *oxide.Instance
@@ -52,15 +52,15 @@ func (c *InstancesV2) InstanceMetadata(ctx context.Context, node *v1.Node) (*clo
5252
if node.Spec.ProviderID != "" {
5353
instanceID = strings.TrimPrefix(node.Spec.ProviderID, "oxide://")
5454

55-
instance, err = c.client.InstanceView(ctx, oxide.InstanceViewParams{
55+
instance, err = i.client.InstanceView(ctx, oxide.InstanceViewParams{
5656
Instance: oxide.NameOrId(instanceID),
5757
})
5858
if err != nil {
5959
return nil, fmt.Errorf("failed viewing oxide instance by id: %v", err)
6060
}
6161
} else {
62-
instance, err = c.client.InstanceView(ctx, oxide.InstanceViewParams{
63-
Project: oxide.NameOrId(c.project),
62+
instance, err = i.client.InstanceView(ctx, oxide.InstanceViewParams{
63+
Project: oxide.NameOrId(i.project),
6464
Instance: oxide.NameOrId(node.GetName()),
6565
})
6666
if err != nil {
@@ -70,14 +70,14 @@ func (c *InstancesV2) InstanceMetadata(ctx context.Context, node *v1.Node) (*clo
7070
instanceID = instance.Id
7171
}
7272

73-
nics, err := c.client.InstanceNetworkInterfaceList(ctx, oxide.InstanceNetworkInterfaceListParams{
73+
nics, err := i.client.InstanceNetworkInterfaceList(ctx, oxide.InstanceNetworkInterfaceListParams{
7474
Instance: oxide.NameOrId(instanceID),
7575
})
7676
if err != nil {
7777
return nil, fmt.Errorf("failed listing instance network interfaces: %v", err)
7878
}
7979

80-
externalIPs, err := c.client.InstanceExternalIpList(ctx, oxide.InstanceExternalIpListParams{
80+
externalIPs, err := i.client.InstanceExternalIpList(ctx, oxide.InstanceExternalIpListParams{
8181
Instance: oxide.NameOrId(instanceID),
8282
})
8383
if err != nil {
@@ -116,10 +116,10 @@ func (c *InstancesV2) InstanceMetadata(ctx context.Context, node *v1.Node) (*clo
116116
}
117117

118118
// InstanceShutdown checks whether the provided node is shut down in Oxide.
119-
func (c *InstancesV2) InstanceShutdown(ctx context.Context, node *v1.Node) (bool, error) {
119+
func (i *InstancesV2) InstanceShutdown(ctx context.Context, node *v1.Node) (bool, error) {
120120
instanceID := strings.TrimPrefix(node.Spec.ProviderID, "oxide://")
121121

122-
instance, err := c.client.InstanceView(ctx, oxide.InstanceViewParams{
122+
instance, err := i.client.InstanceView(ctx, oxide.InstanceViewParams{
123123
Instance: oxide.NameOrId(instanceID),
124124
})
125125
if err != nil {

internal/provider/provider.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,28 @@ type Oxide struct {
3737

3838
// Initialize creates the Oxide and Kubernetes clients and spawns any additional
3939
// controllers, if necessary.
40-
func (c *Oxide) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{}) {
40+
func (o *Oxide) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{}) {
4141
kubernetesClient, err := clientBuilder.Client(Name)
4242
if err != nil {
4343
klog.Fatalf("failed to create kubernetes client: %v", err)
4444
return
4545
}
46-
c.k8sClient = kubernetesClient
46+
o.k8sClient = kubernetesClient
4747

4848
oxideClient, err := oxide.NewClient(nil)
4949
if err != nil {
5050
klog.Fatalf("failed to create oxide client: %v", err)
5151
return
5252
}
53-
c.client = oxideClient
53+
o.client = oxideClient
5454

55-
c.project = os.Getenv("OXIDE_PROJECT")
55+
o.project = os.Getenv("OXIDE_PROJECT")
5656

5757
klog.InfoS("initialized cloud provider", "type", "oxide")
5858
}
5959

6060
// ProviderName returns the name of this cloud provider.
61-
func (c *Oxide) ProviderName() string {
61+
func (o *Oxide) ProviderName() string {
6262
return Name
6363
}
6464

@@ -70,49 +70,49 @@ func (c *Oxide) ProviderName() string {
7070
// it's expected that a Kubernetes cluster on Oxide is deployed in its own VPC
7171
// and does not share resources with other Kubernetes clusters. This may become
7272
// supported in the future when Oxide has resource tags or labels.
73-
func (c *Oxide) HasClusterID() bool {
73+
func (o *Oxide) HasClusterID() bool {
7474
return false
7575
}
7676

7777
// Clusters is purposefully unimplemented. This is meant for a single Cloud
7878
// Controller Manager to manage multiple Kubernetes clusters but the modern
7979
// idiom is to run a single Cloud Controller Manager per Kubernetes cluster,
8080
// making this irrelevant.
81-
func (c *Oxide) Clusters() (cloudprovider.Clusters, bool) {
81+
func (o *Oxide) Clusters() (cloudprovider.Clusters, bool) {
8282
return nil, false
8383
}
8484

8585
// Instances is purposefully unimplemented. Use [Oxide.InstancesV2].
86-
func (c *Oxide) Instances() (cloudprovider.Instances, bool) {
86+
func (o *Oxide) Instances() (cloudprovider.Instances, bool) {
8787
return nil, false
8888
}
8989

9090
// InstancesV2 returns an implementation of [cloudprovider.InstancesV2]
9191
// that provides functionality to initialize Kubernetes nodes, provide their
9292
// metadata, and determine whether they exists to facilitate cleanup.
93-
func (c *Oxide) InstancesV2() (cloudprovider.InstancesV2, bool) {
93+
func (o *Oxide) InstancesV2() (cloudprovider.InstancesV2, bool) {
9494
return &InstancesV2{
95-
client: c.client,
96-
project: c.project,
97-
k8sClient: c.k8sClient,
95+
client: o.client,
96+
project: o.project,
97+
k8sClient: o.k8sClient,
9898
}, true
9999
}
100100

101101
// LoadBalancer is currently unimplemented. This may be implemented in the
102102
// future.
103-
func (c *Oxide) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
103+
func (o *Oxide) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
104104
return nil, false
105105
}
106106

107107
// Routes is purposefully unimplemented. It is expected that the Kubernetes
108108
// cluster uses a third-party CNI instead of this controller. This may be
109109
// implemented in the future.
110-
func (c *Oxide) Routes() (cloudprovider.Routes, bool) {
110+
func (o *Oxide) Routes() (cloudprovider.Routes, bool) {
111111
return nil, false
112112
}
113113

114114
// Zones is purposefully unimplemented. Zone and region information is retrieved
115115
// from [InstancesV2.InstanceMetadata] instead.
116-
func (c *Oxide) Zones() (cloudprovider.Zones, bool) {
116+
func (o *Oxide) Zones() (cloudprovider.Zones, bool) {
117117
return nil, false
118118
}

0 commit comments

Comments
 (0)