diff --git a/azure/services/privateendpoints/client.go b/azure/services/privateendpoints/client.go index 43496b21d54..22312ebc2a0 100644 --- a/azure/services/privateendpoints/client.go +++ b/azure/services/privateendpoints/client.go @@ -28,6 +28,9 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) +// PrivateEndpointsClient is an interface that the sdk to be injected for +// testing. +// In production we use the azure-sdk-for-go which utilizes these methods. type PrivateEndpointsClient interface { BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, privateEndpointName string, parameters armnetwork.PrivateEndpoint, options *armnetwork.PrivateEndpointsClientBeginCreateOrUpdateOptions) (*runtime.Poller[armnetwork.PrivateEndpointsClientCreateOrUpdateResponse], error) BeginDelete(ctx context.Context, resourceGroupName string, privateEndpointName string, options *armnetwork.PrivateEndpointsClientBeginDeleteOptions) (*runtime.Poller[armnetwork.PrivateEndpointsClientDeleteResponse], error) diff --git a/azure/services/privateendpoints/client_test.go b/azure/services/privateendpoints/client_test.go index 7cd6aafdd3c..2927eabdc12 100644 --- a/azure/services/privateendpoints/client_test.go +++ b/azure/services/privateendpoints/client_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package privateendpoints import ( @@ -72,5 +88,4 @@ func TestCreateOrUpdateAsync(t *testing.T) { } _, _, err := ac.CreateOrUpdateAsync(ctx, rsp, "resume", pe) g.Expect(err).To(HaveOccurred()) - } diff --git a/azure/services/resourcehealth/client.go b/azure/services/resourcehealth/client.go index e623cef56bc..f6b09106288 100644 --- a/azure/services/resourcehealth/client.go +++ b/azure/services/resourcehealth/client.go @@ -30,6 +30,9 @@ type client interface { GetByResource(context.Context, string) (armresourcehealth.AvailabilityStatus, error) } +// AvailabilityStatusesClient is an interface that the sdk to be injected for +// testing. +// In production we use the azure-sdk-for-go which utilizes these methods. type AvailabilityStatusesClient interface { GetByResource(ctx context.Context, resourceURI string, options *armresourcehealth.AvailabilityStatusesClientGetByResourceOptions) (armresourcehealth.AvailabilityStatusesClientGetByResourceResponse, error) } diff --git a/azure/services/resourcehealth/client_test.go b/azure/services/resourcehealth/client_test.go index 7ab27ff66c5..dc8ce2d8f93 100644 --- a/azure/services/resourcehealth/client_test.go +++ b/azure/services/resourcehealth/client_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package resourcehealth import ( @@ -7,7 +23,6 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcehealth/armresourcehealth" . "github.com/onsi/gomega" - "go.uber.org/mock/gomock" "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourcehealth/mock_resourcehealth" ) diff --git a/azure/services/subnets/client.go b/azure/services/subnets/client.go index a81a0414c51..912ee129d5f 100644 --- a/azure/services/subnets/client.go +++ b/azure/services/subnets/client.go @@ -28,6 +28,8 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) +// SubnetsClient is an interface that the sdk to be injected for testing. +// In production we use the azure-sdk-for-go which utilizes these methods. type SubnetsClient interface { Get(ctx context.Context, resourceGroupName string, virtualNetworkName string, subnetName string, options *armnetwork.SubnetsClientGetOptions) (armnetwork.SubnetsClientGetResponse, error) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkName string, subnetName string, subnetParameters armnetwork.Subnet, options *armnetwork.SubnetsClientBeginCreateOrUpdateOptions) (*runtime.Poller[armnetwork.SubnetsClientCreateOrUpdateResponse], error) diff --git a/azure/services/subnets/client_test.go b/azure/services/subnets/client_test.go index bfc3f4d0312..b3539fa693e 100644 --- a/azure/services/subnets/client_test.go +++ b/azure/services/subnets/client_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package subnets import ( @@ -77,7 +93,6 @@ func TestCreateOrUpdateAsync(t *testing.T) { } _, _, err := ac.CreateOrUpdateAsync(ctx, rsp, "resume", sub) g.Expect(err).To(HaveOccurred()) - } func TestDeleteAsync(t *testing.T) { @@ -100,5 +115,4 @@ func TestDeleteAsync(t *testing.T) { } _, err := ac.DeleteAsync(ctx, rsp, "resume") g.Expect(err).To(HaveOccurred()) - } diff --git a/azure/services/subnets/mock_subnets/doc.go b/azure/services/subnets/mock_subnets/doc.go index af74338eeb2..1343619af98 100644 --- a/azure/services/subnets/mock_subnets/doc.go +++ b/azure/services/subnets/mock_subnets/doc.go @@ -19,4 +19,5 @@ limitations under the License. //go:generate ../../../../hack/tools/bin/mockgen -destination subnets_mock.go -package mock_subnets -source ../subnets.go SubnetScope //go:generate ../../../../hack/tools/bin/mockgen -destination subnets_clients_mock.go -package mock_subnets -source ../client.go SubnetsClient //go:generate /usr/bin/env bash -c "cat ../../../../hack/boilerplate/boilerplate.generatego.txt subnets_mock.go > _subnets_mock.go && mv _subnets_mock.go subnets_mock.go" +//go:generate /usr/bin/env bash -c "cat ../../../../hack/boilerplate/boilerplate.generatego.txt subnets_clients_mock.go > _subnets_clients_mock.go && mv _subnets_clients_mock.go subnets_clients_mock.go" package mock_subnets diff --git a/azure/services/subnets/mock_subnets/subnets_clients_mock.go b/azure/services/subnets/mock_subnets/subnets_clients_mock.go index bb4124a755d..a37db9e097f 100644 --- a/azure/services/subnets/mock_subnets/subnets_clients_mock.go +++ b/azure/services/subnets/mock_subnets/subnets_clients_mock.go @@ -1,3 +1,19 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + // Code generated by MockGen. DO NOT EDIT. // Source: ../client.go // diff --git a/azure/services/tags/client.go b/azure/services/tags/client.go index 6222ae6eff0..93b98ebe5f9 100644 --- a/azure/services/tags/client.go +++ b/azure/services/tags/client.go @@ -31,6 +31,8 @@ type client interface { UpdateAtScope(context.Context, string, armresources.TagsPatchResource) (armresources.TagsResource, error) } +// TagsClient is an interface that the sdk to be injected for testing. +// In production we use the azure-sdk-for-go which utilizes these methods. type TagsClient interface { GetAtScope(ctx context.Context, scope string, options *armresources.TagsClientGetAtScopeOptions) (armresources.TagsClientGetAtScopeResponse, error) UpdateAtScope(ctx context.Context, scope string, parameters armresources.TagsPatchResource, options *armresources.TagsClientUpdateAtScopeOptions) (armresources.TagsClientUpdateAtScopeResponse, error) diff --git a/azure/services/tags/client_test.go b/azure/services/tags/client_test.go index a43b6b6c3e0..057ecda466f 100644 --- a/azure/services/tags/client_test.go +++ b/azure/services/tags/client_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package tags import ( @@ -77,6 +93,5 @@ func TestUpdateAtScope(t *testing.T) { g.Expect(err).To(HaveOccurred()) } }) - } } diff --git a/azure/services/virtualmachines/client.go b/azure/services/virtualmachines/client.go index f8f08252b34..04f7387147d 100644 --- a/azure/services/virtualmachines/client.go +++ b/azure/services/virtualmachines/client.go @@ -34,6 +34,9 @@ type AzureClient struct { virtualmachines VirtualMachinesClient } +// VirtualMachinesClient is an interface that the sdk to be injected for +// testing. +// In production we use the azure-sdk-for-go which utilizes these methods. type VirtualMachinesClient interface { BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, vmName string, parameters armcompute.VirtualMachine, options *armcompute.VirtualMachinesClientBeginCreateOrUpdateOptions) (*runtime.Poller[armcompute.VirtualMachinesClientCreateOrUpdateResponse], error) BeginDelete(ctx context.Context, resourceGroupName string, vmName string, options *armcompute.VirtualMachinesClientBeginDeleteOptions) (*runtime.Poller[armcompute.VirtualMachinesClientDeleteResponse], error) diff --git a/azure/services/virtualmachines/client_test.go b/azure/services/virtualmachines/client_test.go index d48b1c9d313..177aecf74e8 100644 --- a/azure/services/virtualmachines/client_test.go +++ b/azure/services/virtualmachines/client_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package virtualmachines import ( @@ -72,7 +88,6 @@ func TestCreateOrUpdateAsync(t *testing.T) { } _, _, err := ac.CreateOrUpdateAsync(ctx, rsp, "resume", vm) g.Expect(err).To(HaveOccurred()) - } func TestDeleteAsync(t *testing.T) { @@ -94,5 +109,4 @@ func TestDeleteAsync(t *testing.T) { } _, err := ac.DeleteAsync(ctx, rsp, "resume") g.Expect(err).To(HaveOccurred()) - }