Skip to content

Commit 5aaa8a4

Browse files
authored
Merge branch 'main' into add_go_toolchain
2 parents 359a427 + 4e12116 commit 5aaa8a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2463
-1385
lines changed

.golangci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ issues:
220220
- path: controller/suite_test.go
221221
linters:
222222
- gci
223+
# Exclude goimports check for controller tests that import both mocktest and ginkgo/gomega as dot imports.
224+
# goimports wants mocktest as a dot import in a separate group, but gci wants them in the same group.
225+
- path: controller/.*_controller_test.go
226+
linters:
227+
- goimports
223228

224229
# These are performance optimisations rather than style issues per se.
225230
# They warn when function arguments or range values copy a lot of memory

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ docs:
141141

142142
.PHONY: test
143143
test: generate fmt vet envtest ## Run tests.
144-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(CACHE_BIN) -p path)" go test -race -timeout 60s `go list ./... | grep -v ./mock` -coverprofile cover.out.tmp
144+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(CACHE_BIN) -p path)" go test -race -timeout 60s `go list ./... | grep -v ./mock$$` -coverprofile cover.out.tmp
145145
grep -v "zz_generated.deepcopy.go" cover.out.tmp > cover.out
146146
rm cover.out.tmp
147147

@@ -239,7 +239,7 @@ release-manifests: $(KUSTOMIZE) $(RELEASE_DIR)
239239

240240
.PHONY: local-release
241241
local-release:
242-
RELEASE_DIR=infrastructure-linode/v0.0.0 $(MAKE) release
242+
RELEASE_DIR=infrastructure-local-linode/v0.0.0 $(MAKE) release
243243
$(MAKE) clean-release-git
244244

245245
## --------------------------------------

cloud/scope/client.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ type LinodeObjectStorageClient interface {
5959
DeleteObjectStorageKey(ctx context.Context, keyID int) error
6060
}
6161

62-
type LinodeObjectStorageClientBuilder func(apiKey string) (LinodeObjectStorageClient, error)
63-
64-
func CreateLinodeObjectStorageClient(apiKey string) (LinodeObjectStorageClient, error) {
65-
return CreateLinodeClient(apiKey)
66-
}
67-
68-
type k8sClient interface {
62+
type K8sClient interface {
6963
client.Client
7064
}

cloud/scope/cluster.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030

3131
// ClusterScopeParams defines the input parameters used to create a new Scope.
3232
type ClusterScopeParams struct {
33-
Client k8sClient
33+
Client K8sClient
3434
Cluster *clusterv1.Cluster
3535
LinodeCluster *infrav1alpha1.LinodeCluster
3636
}
@@ -72,7 +72,7 @@ func NewClusterScope(ctx context.Context, apiKey string, params ClusterScopePara
7272
}
7373

7474
return &ClusterScope{
75-
client: params.Client,
75+
Client: params.Client,
7676
Cluster: params.Cluster,
7777
LinodeClient: linodeClient,
7878
LinodeCluster: params.LinodeCluster,
@@ -82,7 +82,7 @@ func NewClusterScope(ctx context.Context, apiKey string, params ClusterScopePara
8282

8383
// ClusterScope defines the basic context for an actuator to operate upon.
8484
type ClusterScope struct {
85-
client k8sClient
85+
Client K8sClient
8686
PatchHelper *patch.Helper
8787
LinodeClient LinodeNodeBalancerClient
8888
Cluster *clusterv1.Cluster

cloud/scope/cluster_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func TestClusterScopeMethods(t *testing.T) {
102102
tests := []struct {
103103
name string
104104
fields fields
105-
expects func(mock *mock.Mockk8sClient)
105+
expects func(mock *mock.MockK8sClient)
106106
}{
107107
{
108108
name: "Success - finalizer should be added to the Linode Cluster object",
@@ -114,7 +114,7 @@ func TestClusterScopeMethods(t *testing.T) {
114114
},
115115
},
116116
},
117-
expects: func(mock *mock.Mockk8sClient) {
117+
expects: func(mock *mock.MockK8sClient) {
118118
mock.EXPECT().Scheme().DoAndReturn(func() *runtime.Scheme {
119119
s := runtime.NewScheme()
120120
infrav1alpha1.AddToScheme(s)
@@ -134,7 +134,7 @@ func TestClusterScopeMethods(t *testing.T) {
134134
},
135135
},
136136
},
137-
expects: func(mock *mock.Mockk8sClient) {
137+
expects: func(mock *mock.MockK8sClient) {
138138
mock.EXPECT().Scheme().DoAndReturn(func() *runtime.Scheme {
139139
s := runtime.NewScheme()
140140
infrav1alpha1.AddToScheme(s)
@@ -151,7 +151,7 @@ func TestClusterScopeMethods(t *testing.T) {
151151
ctrl := gomock.NewController(t)
152152
defer ctrl.Finish()
153153

154-
mockK8sClient := mock.NewMockk8sClient(ctrl)
154+
mockK8sClient := mock.NewMockK8sClient(ctrl)
155155

156156
testcase.expects(mockK8sClient)
157157

@@ -188,7 +188,7 @@ func TestNewClusterScope(t *testing.T) {
188188
name string
189189
args args
190190
expectedError error
191-
expects func(mock *mock.Mockk8sClient)
191+
expects func(mock *mock.MockK8sClient)
192192
}{
193193
{
194194
name: "Success - Pass in valid args and get a valid ClusterScope",
@@ -200,7 +200,7 @@ func TestNewClusterScope(t *testing.T) {
200200
},
201201
},
202202
expectedError: nil,
203-
expects: func(mock *mock.Mockk8sClient) {
203+
expects: func(mock *mock.MockK8sClient) {
204204
mock.EXPECT().Scheme().DoAndReturn(func() *runtime.Scheme {
205205
s := runtime.NewScheme()
206206
infrav1alpha1.AddToScheme(s)
@@ -226,7 +226,7 @@ func TestNewClusterScope(t *testing.T) {
226226
},
227227
},
228228
expectedError: nil,
229-
expects: func(mock *mock.Mockk8sClient) {
229+
expects: func(mock *mock.MockK8sClient) {
230230
mock.EXPECT().Scheme().DoAndReturn(func() *runtime.Scheme {
231231
s := runtime.NewScheme()
232232
infrav1alpha1.AddToScheme(s)
@@ -250,7 +250,7 @@ func TestNewClusterScope(t *testing.T) {
250250
params: ClusterScopeParams{},
251251
},
252252
expectedError: fmt.Errorf("cluster is required when creating a ClusterScope"),
253-
expects: func(mock *mock.Mockk8sClient) {},
253+
expects: func(mock *mock.MockK8sClient) {},
254254
},
255255
{
256256
name: "Error - patchHelper returns error. Checking error handle for when new patchHelper is invoked",
@@ -262,7 +262,7 @@ func TestNewClusterScope(t *testing.T) {
262262
},
263263
},
264264
expectedError: fmt.Errorf("failed to init patch helper:"),
265-
expects: func(mock *mock.Mockk8sClient) {
265+
expects: func(mock *mock.MockK8sClient) {
266266
mock.EXPECT().Scheme().Return(runtime.NewScheme())
267267
},
268268
},
@@ -284,7 +284,7 @@ func TestNewClusterScope(t *testing.T) {
284284
},
285285
},
286286
expectedError: fmt.Errorf("credentials from secret ref: get credentials secret test/example: failed to get secret"),
287-
expects: func(mock *mock.Mockk8sClient) {
287+
expects: func(mock *mock.MockK8sClient) {
288288
mock.EXPECT().Get(gomock.Any(), gomock.Any(), gomock.Any()).Return(fmt.Errorf("failed to get secret"))
289289
},
290290
},
@@ -298,7 +298,7 @@ func TestNewClusterScope(t *testing.T) {
298298
},
299299
},
300300
expectedError: fmt.Errorf("failed to create linode client: missing Linode API key"),
301-
expects: func(mock *mock.Mockk8sClient) {},
301+
expects: func(mock *mock.MockK8sClient) {},
302302
},
303303
}
304304

@@ -310,7 +310,7 @@ func TestNewClusterScope(t *testing.T) {
310310
ctrl := gomock.NewController(t)
311311
defer ctrl.Finish()
312312

313-
mockK8sClient := mock.NewMockk8sClient(ctrl)
313+
mockK8sClient := mock.NewMockK8sClient(ctrl)
314314

315315
testcase.expects(mockK8sClient)
316316

cloud/scope/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func CreateLinodeClient(apiKey string) (*linodego.Client, error) {
3333
return &linodeClient, nil
3434
}
3535

36-
func getCredentialDataFromRef(ctx context.Context, crClient k8sClient, credentialsRef corev1.SecretReference, defaultNamespace string) ([]byte, error) {
36+
func getCredentialDataFromRef(ctx context.Context, crClient K8sClient, credentialsRef corev1.SecretReference, defaultNamespace string) ([]byte, error) {
3737
secretRef := client.ObjectKey{
3838
Name: credentialsRef.Name,
3939
Namespace: credentialsRef.Namespace,

cloud/scope/common_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func TestGetCredentialDataFromRef(t *testing.T) {
164164
defer ctrl.Finish()
165165

166166
// Create an instance of the mock K8sClient
167-
mockClient := mock.NewMockk8sClient(ctrl)
167+
mockClient := mock.NewMockK8sClient(ctrl)
168168

169169
// Setup Expected behaviour
170170
mockClient.EXPECT().Get(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(testCase.args.funcBehavior)

cloud/scope/machine.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ import (
1515
)
1616

1717
type MachineScopeParams struct {
18-
Client k8sClient
18+
Client K8sClient
1919
Cluster *clusterv1.Cluster
2020
Machine *clusterv1.Machine
2121
LinodeCluster *infrav1alpha1.LinodeCluster
2222
LinodeMachine *infrav1alpha1.LinodeMachine
2323
}
2424

2525
type MachineScope struct {
26-
Client k8sClient
26+
Client K8sClient
2727
PatchHelper *patch.Helper
2828
Cluster *clusterv1.Cluster
2929
Machine *clusterv1.Machine
@@ -34,7 +34,7 @@ type MachineScope struct {
3434

3535
func validateMachineScopeParams(params MachineScopeParams) error {
3636
if params.Cluster == nil {
37-
return errors.New("custer is required when creating a MachineScope")
37+
return errors.New("cluster is required when creating a MachineScope")
3838
}
3939
if params.Machine == nil {
4040
return errors.New("machine is required when creating a MachineScope")
@@ -77,7 +77,7 @@ func NewMachineScope(ctx context.Context, apiKey string, params MachineScopePara
7777
if credentialRef != nil {
7878
data, err := getCredentialDataFromRef(ctx, params.Client, *credentialRef, defaultNamespace)
7979
if err != nil {
80-
return nil, fmt.Errorf("credentials from cluster secret ref: %w", err)
80+
return nil, fmt.Errorf("credentials from secret ref: %w", err)
8181
}
8282
apiKey = string(data)
8383
}

0 commit comments

Comments
 (0)