From db8af503f7f452fcefcdc29fd05de31fe1a70065 Mon Sep 17 00:00:00 2001 From: Stephen Augustus Date: Sat, 13 Apr 2019 11:46:41 -0400 Subject: [PATCH] Add mock interfaces Signed-off-by: Stephen Augustus --- Gopkg.lock | 21 +- Gopkg.toml | 6 + Makefile | 5 - WORKSPACE | 7 +- build/asmshim/BUILD | 14 - build/asmshim/c.go | 21 - build/asmshim/textflag.h | 34 - build/go_mock.bzl | 91 -- hack/copy-bazel-mocks.sh | 30 + pkg/apis/azureprovider/v1alpha1/types.go | 4 + pkg/cloud/azure/BUILD.bazel | 5 +- .../azure/actuators/machine/actuator_test.go | 18 +- pkg/cloud/azure/defaults.go | 2 + pkg/cloud/azure/fake_interfaces.go | 25 +- pkg/cloud/azure/interfaces.go | 21 +- pkg/cloud/azure/mocks/BUILD.bazel | 41 + pkg/cloud/azure/mocks/getterservice.go | 96 +++ pkg/cloud/azure/mocks/service.go | 81 ++ pkg/cloud/azure/services/BUILD.bazel | 20 - .../services/availabilityzones/BUILD.bazel | 1 + .../availabilityzones/availabilityzones.go | 8 +- .../mock_availabilityzones/BUILD | 40 + .../services/certificates/certificates.go | 6 +- pkg/cloud/azure/services/groups/BUILD.bazel | 1 + pkg/cloud/azure/services/groups/groups.go | 8 +- .../azure/services/groups/mock_groups/BUILD | 21 + .../internalloadbalancers/BUILD.bazel | 1 + .../internalloadbalancers.go | 7 +- .../mock_internalloadbalancers/BUILD | 19 + pkg/cloud/azure/services/mock_interfaces.go | 267 ------ .../azure/services/mock_interfaces_helper.go | 358 -------- .../services/networkinterfaces/BUILD.bazel | 1 + .../mock_networkinterfaces/BUILD | 19 + .../networkinterfaces/networkinterfaces.go | 7 +- .../azure/services/publicips/BUILD.bazel | 1 + .../services/publicips/mock_publicips/BUILD | 19 + .../azure/services/publicips/publicips.go | 7 +- .../services/publicloadbalancers/BUILD.bazel | 1 + .../mock_publicloadbalancers/BUILD | 19 + .../publicloadbalancers.go | 7 +- .../azure/services/routetables/BUILD.bazel | 1 + .../routetables/mock_routetables/BUILD | 19 + .../azure/services/routetables/routetables.go | 7 +- .../azure/services/securitygroups/BUILD.bazel | 1 + .../securitygroups/mock_securitygroups/BUILD | 19 + .../services/securitygroups/securitygroups.go | 7 +- pkg/cloud/azure/services/subnets/BUILD.bazel | 1 + .../azure/services/subnets/mock_subnets/BUILD | 19 + pkg/cloud/azure/services/subnets/subnets.go | 7 +- .../virtualmachineextensions/BUILD.bazel | 1 + .../mock_virtualmachineextensions/BUILD | 19 + .../virtualmachineextensions.go | 7 +- .../mock_virtualmachines/BUILD | 20 + .../virtualmachines/virtualmachines.go | 6 +- .../services/virtualnetworks/BUILD.bazel | 1 + .../mock_virtualnetworks/BUILD | 19 + .../virtualnetworks/virtualnetworks.go | 7 +- .../2019-03-01/compute/computeapi/BUILD.bazel | 13 + .../compute/computeapi/interfaces.go | 286 +++++++ .../2018-12-01/network/networkapi/BUILD.bazel | 13 + .../network/networkapi/interfaces.go | 794 ++++++++++++++++++ .../resources/resourcesapi/BUILD.bazel | 13 + .../resources/resourcesapi/interfaces.go | 117 +++ vendor/github.com/golang/mock/AUTHORS | 12 + vendor/github.com/golang/mock/CONTRIBUTORS | 37 + vendor/github.com/golang/mock/LICENSE | 202 +++++ .../github.com/golang/mock/gomock/BUILD.bazel | 14 + vendor/github.com/golang/mock/gomock/call.go | 420 +++++++++ .../github.com/golang/mock/gomock/callset.go | 108 +++ .../golang/mock/gomock/controller.go | 235 ++++++ .../github.com/golang/mock/gomock/matchers.go | 122 +++ .../golang/mock/mockgen/model/BUILD.bazel | 9 + .../golang/mock/mockgen/model/model.go | 454 ++++++++++ 73 files changed, 3482 insertions(+), 888 deletions(-) delete mode 100644 build/asmshim/BUILD delete mode 100644 build/asmshim/c.go delete mode 100644 build/asmshim/textflag.h delete mode 100644 build/go_mock.bzl create mode 100755 hack/copy-bazel-mocks.sh create mode 100644 pkg/cloud/azure/mocks/BUILD.bazel create mode 100755 pkg/cloud/azure/mocks/getterservice.go create mode 100755 pkg/cloud/azure/mocks/service.go delete mode 100644 pkg/cloud/azure/services/BUILD.bazel create mode 100644 pkg/cloud/azure/services/availabilityzones/mock_availabilityzones/BUILD create mode 100644 pkg/cloud/azure/services/groups/mock_groups/BUILD create mode 100644 pkg/cloud/azure/services/internalloadbalancers/mock_internalloadbalancers/BUILD delete mode 100644 pkg/cloud/azure/services/mock_interfaces.go delete mode 100644 pkg/cloud/azure/services/mock_interfaces_helper.go create mode 100644 pkg/cloud/azure/services/networkinterfaces/mock_networkinterfaces/BUILD create mode 100644 pkg/cloud/azure/services/publicips/mock_publicips/BUILD create mode 100644 pkg/cloud/azure/services/publicloadbalancers/mock_publicloadbalancers/BUILD create mode 100644 pkg/cloud/azure/services/routetables/mock_routetables/BUILD create mode 100644 pkg/cloud/azure/services/securitygroups/mock_securitygroups/BUILD create mode 100644 pkg/cloud/azure/services/subnets/mock_subnets/BUILD create mode 100644 pkg/cloud/azure/services/virtualmachineextensions/mock_virtualmachineextensions/BUILD create mode 100644 pkg/cloud/azure/services/virtualmachines/mock_virtualmachines/BUILD create mode 100644 pkg/cloud/azure/services/virtualnetworks/mock_virtualnetworks/BUILD create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/computeapi/BUILD.bazel create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/computeapi/interfaces.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network/networkapi/BUILD.bazel create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network/networkapi/interfaces.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/resourcesapi/BUILD.bazel create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/resourcesapi/interfaces.go create mode 100644 vendor/github.com/golang/mock/AUTHORS create mode 100644 vendor/github.com/golang/mock/CONTRIBUTORS create mode 100644 vendor/github.com/golang/mock/LICENSE create mode 100644 vendor/github.com/golang/mock/gomock/BUILD.bazel create mode 100644 vendor/github.com/golang/mock/gomock/call.go create mode 100644 vendor/github.com/golang/mock/gomock/callset.go create mode 100644 vendor/github.com/golang/mock/gomock/controller.go create mode 100644 vendor/github.com/golang/mock/gomock/matchers.go create mode 100644 vendor/github.com/golang/mock/mockgen/model/BUILD.bazel create mode 100644 vendor/github.com/golang/mock/mockgen/model/model.go diff --git a/Gopkg.lock b/Gopkg.lock index 8b31ca9c63f..51c81f3f1eb 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -18,12 +18,15 @@ version = "v0.2.0" [[projects]] - digest = "1:5e96accf9973db68f174a33076000853f9295f5b7d53a56f8933f4bbd8d4d4d1" + digest = "1:84942ae55e514f0208479a7d57cb018ff9eb33e99c56820fac37f487b8a0f2d9" name = "github.com/Azure/azure-sdk-for-go" packages = [ "services/compute/mgmt/2019-03-01/compute", + "services/compute/mgmt/2019-03-01/compute/computeapi", "services/network/mgmt/2018-12-01/network", + "services/network/mgmt/2018-12-01/network/networkapi", "services/resources/mgmt/2018-05-01/resources", + "services/resources/mgmt/2018-05-01/resources/resourcesapi", "version", ] pruneopts = "UT" @@ -172,6 +175,17 @@ pruneopts = "UT" revision = "5b532d6fd5efaf7fa130d4e859a2fde0fc3a9e1b" +[[projects]] + digest = "1:a507e8646bf3775af6f7e7b2a62a5e67d1c6a8f00754f87e66b96181b7f3d747" + name = "github.com/golang/mock" + packages = [ + "gomock", + "mockgen/model", + ] + pruneopts = "UT" + revision = "51421b967af1f557f93a59e0057aaf15ca02e29c" + version = "v1.2.0" + [[projects]] digest = "1:e1b86a55f22a21007da87160a3e0897a35392af410d33ae82a4f165f1eec13cf" name = "github.com/golang/protobuf" @@ -1267,13 +1281,18 @@ analyzer-version = 1 input-imports = [ "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute", + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/computeapi", "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network", + "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network/networkapi", "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources", + "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/resourcesapi", "github.com/Azure/go-autorest/autorest", "github.com/Azure/go-autorest/autorest/azure/auth", "github.com/Azure/go-autorest/autorest/to", "github.com/emicklei/go-restful", "github.com/ghodss/yaml", + "github.com/golang/mock/gomock", + "github.com/golang/mock/mockgen/model", "github.com/onsi/ginkgo", "github.com/onsi/gomega", "github.com/pkg/errors", diff --git a/Gopkg.toml b/Gopkg.toml index d6c2008ea7a..bc606bff81e 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -25,6 +25,12 @@ # unused-packages = true required = [ + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/computeapi", + "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network/networkapi", + "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/resourcesapi", + "github.com/Azure/go-autorest/autorest", + "github.com/golang/mock/gomock", + "github.com/golang/mock/mockgen/model", "github.com/emicklei/go-restful", "github.com/onsi/ginkgo", # for test framework "github.com/onsi/gomega", # for test matchers diff --git a/Makefile b/Makefile index 5cf99756514..b38cd183a2d 100644 --- a/Makefile +++ b/Makefile @@ -160,16 +160,11 @@ dep-ensure: check-install ## Ensure dependencies are up to date gazelle: ## Run Bazel Gazelle bazel run //:gazelle $(BAZEL_ARGS) -# TODO: Uncomment mock generation once mocks exist .PHONY: generate generate: ## Generate mocks, CRDs and runs `go generate` through Bazel GOPATH=$(shell go env GOPATH) bazel run //:generate $(BAZEL_ARGS) $(MAKE) dep-ensure $(MAKE) generate-deepcopy -# bazel build $(BAZEL_ARGS) //pkg/cloud/azure/services/mocks:go_mock_interfaces \ -# //pkg/cloud/azure/services/ec2/mock_ec2iface:go_default_library \ -# //pkg/cloud/azure/services/elb/mock_elbiface:go_default_library -# cp -Rf bazel-genfiles/pkg/* pkg/ $(MAKE) generate-crds .PHONY: generate-deepcopy diff --git a/WORKSPACE b/WORKSPACE index 157e01e6420..95a69f90d88 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -13,7 +13,6 @@ # limitations under the License. load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") http_archive( name = "io_bazel_rules_go", @@ -96,6 +95,12 @@ go_repository( tag = "v1.2.0", ) +go_repository( + name = "bazel_gomock", + commit = "08cc809a2f68f6d810c2013987970a9a5c1181b4", + importpath = "github.com/jmhodges/bazel_gomock", +) + go_repository( name = "io_k8s_sigs_kind", commit = "161151a26faf0dbe962ac9f323cc0cdebac79ba8", diff --git a/build/asmshim/BUILD b/build/asmshim/BUILD deleted file mode 100644 index 59e47bd6eee..00000000000 --- a/build/asmshim/BUILD +++ /dev/null @@ -1,14 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "c.go", - "textflag.h", - ], - cgo = True, - importpath = "sigs.k8s.io/cluster-api-provider-azure/build/asmshim", - visibility = ["//visibility:public"], -) diff --git a/build/asmshim/c.go b/build/asmshim/c.go deleted file mode 100644 index 68867107b85..00000000000 --- a/build/asmshim/c.go +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright 2018 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 asmshim - -import ( - "C" -) diff --git a/build/asmshim/textflag.h b/build/asmshim/textflag.h deleted file mode 100644 index 929e9b36a90..00000000000 --- a/build/asmshim/textflag.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file defines flags attached to various functions -// and data objects. The compilers, assemblers, and linker must -// all agree on these values. -// -// Keep in sync with src/cmd/internal/obj/textflag.go. - -// Don't profile the marked routine. This flag is deprecated. -#define NOPROF 1 -// It is ok for the linker to get multiple of these symbols. It will -// pick one of the duplicates to use. -#define DUPOK 2 -// Don't insert stack check preamble. -#define NOSPLIT 4 -// Put this data in a read-only section. -#define RODATA 8 -// This data contains no pointers. -#define NOPTR 16 -// This is a wrapper function and should not count as disabling 'recover'. -#define WRAPPER 32 -// This function uses its incoming context register. -#define NEEDCTXT 64 -// Allocate a word of thread local storage and store the offset from the -// thread local base to the thread local storage in this variable. -#define TLSBSS 256 -// Do not insert instructions to allocate a stack frame for this function. -// Only valid on functions that declare a frame size of 0. -// TODO(mwhudson): only implemented for ppc64x at present. -#define NOFRAME 512 -// Function can call reflect.Type.Method or reflect.Type.MethodByName. -#define REFLECTMETHOD = 1024 diff --git a/build/go_mock.bzl b/build/go_mock.bzl deleted file mode 100644 index 4ce166326da..00000000000 --- a/build/go_mock.bzl +++ /dev/null @@ -1,91 +0,0 @@ -# Copyright 2018 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. - -load("@io_bazel_rules_go//go:def.bzl", "go_library") -load("@io_kubernetes_build//defs:go.bzl", "go_genrule") - -MOCKGEN = "@com_github_golang_mock//mockgen" -MOCKGEN_LIBS = [ - "@com_github_golang_mock//mockgen/model:go_default_library", - "//vendor/github.com/golang/mock/gomock:go_default_library", -] -ASM_SHIM = "//build/asmshim" -ASM_SHIM_LIB = "%s:go_default_library" % ASM_SHIM -TEXTFLAG_SHIM = "%s:textflag.h" % ASM_SHIM -SDK_INCLUDE_DIR = "$$GOROOT/pkg/include" -BOILERPLATE = "//hack:boilerplate/boilerplate.go.txt" -GO_FLAGS = "CGO_ENABLED=0" - -def _qualified_genfile(label): - return "$$GO_GENRULE_EXECROOT/$(location %s)" % label - -def go_mock(name, importpath, visibility, mocks, deps): - targets = [name + ".go"] - srcs = [m["interface"].lower() + ".go" for m in mocks] - - go_library( - name = name, - srcs = srcs, - importpath = importpath, - deps = deps + MOCKGEN_LIBS , - visibility = visibility, - ) - - for m in mocks: - package = m["package"] - interface = m["interface"] - prefix = m["prefix"] - - out_basename = m["interface"].lower() - out = "%s.go" % out_basename - - if m["vendored"]: - extra_dep = ["//vendor/%s/%s:go_default_library" % (prefix, package)] - else: - extra_dep = [ "//%s:go_default_library" % package ] - - full_deps = [ASM_SHIM_LIB] + MOCKGEN_LIBS + deps + extra_dep - - cmd = """mkdir -p {source_package} && \\ -mkdir -p {generated_package} && \\ -mkdir -p {sdk_include_dir} && \\ -cp {textflag_shim} {sdk_include_dir} && \\ -cd {source_package} && \\ -cat {boilerplate} | sed "s/YEAR/$$(date +%Y)/g" > {qualified_out} && \\ -echo "\n\n" >> {qualified_out} && \\ -{go_flags} {mockgen} -package={code_package} {qualified_package} {interface} \\ - >> {qualified_out} -""".format( - qualified_package = prefix + "/" + package, - code_package = importpath.split("/")[-1], - importpath = importpath, - textflag_shim = "$(location %s)" % TEXTFLAG_SHIM, - generated_package = "$$GO_GENRULE_EXECROOT/%s" % importpath, - source_package = "$$GOPATH/src/%s" % importpath, - qualified_out = _qualified_genfile(":" + out), - mockgen = _qualified_genfile(MOCKGEN), - sdk_include_dir = SDK_INCLUDE_DIR, - go_flags = GO_FLAGS, - interface = interface, - boilerplate = _qualified_genfile(BOILERPLATE), - ) - - go_genrule( - name = out_basename, - srcs = [BOILERPLATE, TEXTFLAG_SHIM], - outs = [ out ], - cmd = cmd, - go_deps = full_deps, - tools = [MOCKGEN], - ) diff --git a/hack/copy-bazel-mocks.sh b/hack/copy-bazel-mocks.sh new file mode 100755 index 00000000000..655a149081d --- /dev/null +++ b/hack/copy-bazel-mocks.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# 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. + +set -o errexit +set -o nounset +set -o pipefail + +REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +cd "${REPO_ROOT}" || exit 1 + +BOILERPLATE=$(sed "s/YEAR/$(date +%Y)/g" < hack/boilerplate/boilerplate.go.txt) + +while IFS= read -r -d '' file +do + out=$(echo "${file}" | sed "s#bazel-bin/##g") + echo -e "${BOILERPLATE}\n" > "${out}" + cat "${file}" >> "${out}" +done < <(find bazel-bin/pkg -name '*_mock.go' -type f -print0) diff --git a/pkg/apis/azureprovider/v1alpha1/types.go b/pkg/apis/azureprovider/v1alpha1/types.go index 5905f8c78ef..0a6ca7deb38 100644 --- a/pkg/apis/azureprovider/v1alpha1/types.go +++ b/pkg/apis/azureprovider/v1alpha1/types.go @@ -23,6 +23,10 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// ResourceSpec defines a generic spec that can used to define Azure resources. +// TODO: ResourceSpec should be removed once concrete specs have been defined for all Azure resources in use. +type ResourceSpec interface{} + // TODO: Write type tests // AzureResourceReference is a reference to a specific Azure resource by ID diff --git a/pkg/cloud/azure/BUILD.bazel b/pkg/cloud/azure/BUILD.bazel index b31528c9792..54280bdcfd4 100644 --- a/pkg/cloud/azure/BUILD.bazel +++ b/pkg/cloud/azure/BUILD.bazel @@ -10,5 +10,8 @@ go_library( ], importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure", visibility = ["//visibility:public"], - deps = ["//vendor/github.com/Azure/go-autorest/autorest:go_default_library"], + deps = [ + "//pkg/apis/azureprovider/v1alpha1:go_default_library", + "//vendor/github.com/Azure/go-autorest/autorest:go_default_library", + ], ) diff --git a/pkg/cloud/azure/actuators/machine/actuator_test.go b/pkg/cloud/azure/actuators/machine/actuator_test.go index 92014be2e94..4c10806d4fe 100644 --- a/pkg/cloud/azure/actuators/machine/actuator_test.go +++ b/pkg/cloud/azure/actuators/machine/actuator_test.go @@ -194,7 +194,7 @@ type FakeVMService struct { } // Get returns fake success. -func (s *FakeVMService) Get(ctx context.Context, spec azure.Spec) (interface{}, error) { +func (s *FakeVMService) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { s.GetCallCount++ return compute.VirtualMachine{ ID: to.StringPtr(s.ID), @@ -206,13 +206,13 @@ func (s *FakeVMService) Get(ctx context.Context, spec azure.Spec) (interface{}, } // Reconcile returns fake success. -func (s *FakeVMService) Reconcile(ctx context.Context, spec azure.Spec) error { +func (s *FakeVMService) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { s.CreateOrUpdateCallCount++ return nil } // Delete returns fake success. -func (s *FakeVMService) Delete(ctx context.Context, spec azure.Spec) error { +func (s *FakeVMService) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { s.DeleteCallCount++ return nil } @@ -381,12 +381,12 @@ type FakeVMCheckZonesService struct { } // Get returns fake success. -func (s *FakeVMCheckZonesService) Get(ctx context.Context, spec azure.Spec) (interface{}, error) { +func (s *FakeVMCheckZonesService) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { return nil, errors.New("vm not found") } // Reconcile returns fake success. -func (s *FakeVMCheckZonesService) Reconcile(ctx context.Context, spec azure.Spec) error { +func (s *FakeVMCheckZonesService) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { vmSpec, ok := spec.(*virtualmachines.Spec) if !ok { return errors.New("invalid vm specification") @@ -405,7 +405,7 @@ func (s *FakeVMCheckZonesService) Reconcile(ctx context.Context, spec azure.Spec } // Delete returns fake success. -func (s *FakeVMCheckZonesService) Delete(ctx context.Context, spec azure.Spec) error { +func (s *FakeVMCheckZonesService) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { return nil } @@ -415,17 +415,17 @@ type FakeAvailabilityZonesService struct { } // Get returns fake success. -func (s *FakeAvailabilityZonesService) Get(ctx context.Context, spec azure.Spec) (interface{}, error) { +func (s *FakeAvailabilityZonesService) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { return s.zonesResponse, nil } // Reconcile returns fake success. -func (s *FakeAvailabilityZonesService) Reconcile(ctx context.Context, spec azure.Spec) error { +func (s *FakeAvailabilityZonesService) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { return nil } // Delete returns fake success. -func (s *FakeAvailabilityZonesService) Delete(ctx context.Context, spec azure.Spec) error { +func (s *FakeAvailabilityZonesService) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { return nil } diff --git a/pkg/cloud/azure/defaults.go b/pkg/cloud/azure/defaults.go index 477308ec398..69e26d6971a 100644 --- a/pkg/cloud/azure/defaults.go +++ b/pkg/cloud/azure/defaults.go @@ -31,6 +31,8 @@ const ( DefaultInternalLBIPAddress = "10.0.0.100" // DefaultAzureDNSZone is the default provided azure dns zone DefaultAzureDNSZone = "cloudapp.azure.com" + // UserAgent used for communicating with azure + UserAgent = "cluster-api-azure-services" ) // GenerateVnetName generates a virtual network name, based on the cluster name. diff --git a/pkg/cloud/azure/fake_interfaces.go b/pkg/cloud/azure/fake_interfaces.go index 2b906f69bc0..113407a66bb 100644 --- a/pkg/cloud/azure/fake_interfaces.go +++ b/pkg/cloud/azure/fake_interfaces.go @@ -22,6 +22,7 @@ import ( "reflect" "github.com/Azure/go-autorest/autorest" + "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" ) // FakeSuccessService generic service which always returns success. @@ -42,17 +43,17 @@ type FakeCachedService struct { } // Get returns fake success. -func (s *FakeSuccessService) Get(ctx context.Context, spec Spec) (interface{}, error) { +func (s *FakeSuccessService) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { return nil, nil } // Reconcile returns fake success. -func (s *FakeSuccessService) Reconcile(ctx context.Context, spec Spec) error { +func (s *FakeSuccessService) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { return nil } // Delete returns fake success. -func (s *FakeSuccessService) Delete(ctx context.Context, spec Spec) error { +func (s *FakeSuccessService) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { return nil } @@ -61,42 +62,42 @@ type FakeStruct struct { } // Get returns fake failure. -func (s *FakeFailureService) Get(ctx context.Context, spec Spec) (interface{}, error) { +func (s *FakeFailureService) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { return FakeStruct{}, errors.New("Failed to Get service") } // Reconcile returns fake failure. -func (s *FakeFailureService) Reconcile(ctx context.Context, spec Spec) error { +func (s *FakeFailureService) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { return errors.New("Failed to Create") } // Delete returns fake failure. -func (s *FakeFailureService) Delete(ctx context.Context, spec Spec) error { +func (s *FakeFailureService) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { return errors.New("Failed to Delete") } // Get returns fake not found. -func (s *FakeNotFoundService) Get(ctx context.Context, spec Spec) (interface{}, error) { +func (s *FakeNotFoundService) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { return nil, autorest.DetailedError{StatusCode: 404} } // Reconcile returns fake not found. -func (s *FakeNotFoundService) Reconcile(ctx context.Context, spec Spec) error { +func (s *FakeNotFoundService) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { return autorest.DetailedError{StatusCode: 404} } // Delete returns fake not found. -func (s *FakeNotFoundService) Delete(ctx context.Context, spec Spec) error { +func (s *FakeNotFoundService) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { return autorest.DetailedError{StatusCode: 404} } // Get returns fake success. -func (s *FakeCachedService) Get(ctx context.Context, spec Spec) (interface{}, error) { +func (s *FakeCachedService) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { return nil, nil } // Reconcile returns fake success. -func (s *FakeCachedService) Reconcile(ctx context.Context, spec Spec) error { +func (s *FakeCachedService) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { if spec == nil { return nil } @@ -106,6 +107,6 @@ func (s *FakeCachedService) Reconcile(ctx context.Context, spec Spec) error { } // Delete returns fake success. -func (s *FakeCachedService) Delete(ctx context.Context, spec Spec) error { +func (s *FakeCachedService) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { return nil } diff --git a/pkg/cloud/azure/interfaces.go b/pkg/cloud/azure/interfaces.go index 25bde1d3f4a..a3702f5ee5e 100644 --- a/pkg/cloud/azure/interfaces.go +++ b/pkg/cloud/azure/interfaces.go @@ -16,29 +16,24 @@ limitations under the License. package azure -import "context" +import ( + "context" -const ( - // UserAgent used for communicating with azure - UserAgent = "cluster-api-azure-services" + "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" ) -// Spec defines a generic interface which all services should conform to -type Spec interface { -} - // Service is a generic interface used by components offering a type of service. // Example: virtualnetworks service would offer Reconcile/Delete methods. type Service interface { - Reconcile(ctx context.Context, spec Spec) error - Delete(ctx context.Context, spec Spec) error + Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error + Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error } // GetterService is a temporary interface used by components which still require Get methods. // Once all components move to storing provider information within the relevant // Cluster/Machine specs, this interface should be removed. type GetterService interface { - Get(ctx context.Context, spec Spec) (interface{}, error) - Reconcile(ctx context.Context, spec Spec) error - Delete(ctx context.Context, spec Spec) error + Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) + Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error + Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error } diff --git a/pkg/cloud/azure/mocks/BUILD.bazel b/pkg/cloud/azure/mocks/BUILD.bazel new file mode 100644 index 00000000000..264c6b5405c --- /dev/null +++ b/pkg/cloud/azure/mocks/BUILD.bazel @@ -0,0 +1,41 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "getterservice.go", + "service.go", + ], + importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/mocks", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/azureprovider/v1alpha1:go_default_library", + "//vendor/github.com/golang/mock/gomock:go_default_library", + ], +) + +"""load("//build:go_mock.bzl", "go_mock") + +go_mock( + name = "go_mock_interfaces", + importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/mocks", + visibility = ["//visibility:public"], + mocks = [ + { + "prefix": "sigs.k8s.io/cluster-api-provider-azure", + "package": "pkg/cloud/azure/services", + "interface": "Service", + "vendored": False, + }, + { + "prefix": "sigs.k8s.io/cluster-api-provider-azure", + "package": "pkg/cloud/azure/services", + "interface": "GetterService", + "vendored": False, + }, + ], + deps = [ + "//pkg/apis/azureprovider/v1alpha1:go_default_library", + ], +) +""" diff --git a/pkg/cloud/azure/mocks/getterservice.go b/pkg/cloud/azure/mocks/getterservice.go new file mode 100755 index 00000000000..db7c75bf1de --- /dev/null +++ b/pkg/cloud/azure/mocks/getterservice.go @@ -0,0 +1,96 @@ +/* +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. +*/ + + + +// Code generated by MockGen. DO NOT EDIT. +// Source: sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services (interfaces: GetterService) + +// Package mocks is a generated GoMock package. +package mocks + +import ( + context "context" + gomock "github.com/golang/mock/gomock" + reflect "reflect" + v1alpha1 "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" +) + +// MockGetterService is a mock of GetterService interface +type MockGetterService struct { + ctrl *gomock.Controller + recorder *MockGetterServiceMockRecorder +} + +// MockGetterServiceMockRecorder is the mock recorder for MockGetterService +type MockGetterServiceMockRecorder struct { + mock *MockGetterService +} + +// NewMockGetterService creates a new mock instance +func NewMockGetterService(ctrl *gomock.Controller) *MockGetterService { + mock := &MockGetterService{ctrl: ctrl} + mock.recorder = &MockGetterServiceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use +func (m *MockGetterService) EXPECT() *MockGetterServiceMockRecorder { + return m.recorder +} + +// Delete mocks base method +func (m *MockGetterService) Delete(arg0 context.Context, arg1 v1alpha1.ResourceSpec) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Delete", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete +func (mr *MockGetterServiceMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockGetterService)(nil).Delete), arg0, arg1) +} + +// Get mocks base method +func (m *MockGetterService) Get(arg0 context.Context, arg1 v1alpha1.ResourceSpec) (interface{}, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Get", arg0, arg1) + ret0, _ := ret[0].(interface{}) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Get indicates an expected call of Get +func (mr *MockGetterServiceMockRecorder) Get(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockGetterService)(nil).Get), arg0, arg1) +} + +// Reconcile mocks base method +func (m *MockGetterService) Reconcile(arg0 context.Context, arg1 v1alpha1.ResourceSpec) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Reconcile", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Reconcile indicates an expected call of Reconcile +func (mr *MockGetterServiceMockRecorder) Reconcile(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Reconcile", reflect.TypeOf((*MockGetterService)(nil).Reconcile), arg0, arg1) +} diff --git a/pkg/cloud/azure/mocks/service.go b/pkg/cloud/azure/mocks/service.go new file mode 100755 index 00000000000..c927b8f6c54 --- /dev/null +++ b/pkg/cloud/azure/mocks/service.go @@ -0,0 +1,81 @@ +/* +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. +*/ + + + +// Code generated by MockGen. DO NOT EDIT. +// Source: sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services (interfaces: Service) + +// Package mocks is a generated GoMock package. +package mocks + +import ( + context "context" + gomock "github.com/golang/mock/gomock" + reflect "reflect" + v1alpha1 "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" +) + +// MockService is a mock of Service interface +type MockService struct { + ctrl *gomock.Controller + recorder *MockServiceMockRecorder +} + +// MockServiceMockRecorder is the mock recorder for MockService +type MockServiceMockRecorder struct { + mock *MockService +} + +// NewMockService creates a new mock instance +func NewMockService(ctrl *gomock.Controller) *MockService { + mock := &MockService{ctrl: ctrl} + mock.recorder = &MockServiceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use +func (m *MockService) EXPECT() *MockServiceMockRecorder { + return m.recorder +} + +// Delete mocks base method +func (m *MockService) Delete(arg0 context.Context, arg1 v1alpha1.ResourceSpec) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Delete", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete +func (mr *MockServiceMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockService)(nil).Delete), arg0, arg1) +} + +// Reconcile mocks base method +func (m *MockService) Reconcile(arg0 context.Context, arg1 v1alpha1.ResourceSpec) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Reconcile", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Reconcile indicates an expected call of Reconcile +func (mr *MockServiceMockRecorder) Reconcile(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Reconcile", reflect.TypeOf((*MockService)(nil).Reconcile), arg0, arg1) +} diff --git a/pkg/cloud/azure/services/BUILD.bazel b/pkg/cloud/azure/services/BUILD.bazel deleted file mode 100644 index 73bb3472ca2..00000000000 --- a/pkg/cloud/azure/services/BUILD.bazel +++ /dev/null @@ -1,20 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "mock_interfaces.go", - "mock_interfaces_helper.go", - ], - importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services", - visibility = ["//visibility:public"], - deps = [ - "//pkg/apis/azureprovider/v1alpha1:go_default_library", - "//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute:go_default_library", - "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network:go_default_library", - "//vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources:go_default_library", - "//vendor/github.com/Azure/go-autorest/autorest:go_default_library", - "//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library", - "//vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1:go_default_library", - ], -) diff --git a/pkg/cloud/azure/services/availabilityzones/BUILD.bazel b/pkg/cloud/azure/services/availabilityzones/BUILD.bazel index 4cffb2b46b9..97eef7199b9 100644 --- a/pkg/cloud/azure/services/availabilityzones/BUILD.bazel +++ b/pkg/cloud/azure/services/availabilityzones/BUILD.bazel @@ -9,6 +9,7 @@ go_library( importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/availabilityzones", visibility = ["//visibility:public"], deps = [ + "//pkg/apis/azureprovider/v1alpha1:go_default_library", "//pkg/cloud/azure:go_default_library", "//pkg/cloud/azure/actuators:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute:go_default_library", diff --git a/pkg/cloud/azure/services/availabilityzones/availabilityzones.go b/pkg/cloud/azure/services/availabilityzones/availabilityzones.go index cb809d87a0d..2bfc9cc3ceb 100644 --- a/pkg/cloud/azure/services/availabilityzones/availabilityzones.go +++ b/pkg/cloud/azure/services/availabilityzones/availabilityzones.go @@ -21,7 +21,7 @@ import ( "strings" "github.com/pkg/errors" - "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure" + "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" ) // Spec input specification for Get/CreateOrUpdate/Delete calls @@ -30,7 +30,7 @@ type Spec struct { } // Get provides information about a availability zones. -func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) { +func (s *Service) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { var zones []string skusSpec, ok := spec.(*Spec) if !ok { @@ -55,13 +55,13 @@ func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) } // Reconcile no-op. -func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { +func (s *Service) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { // Not implemented since there is nothing to reconcile return nil } // Delete no-op. -func (s *Service) Delete(ctx context.Context, spec azure.Spec) error { +func (s *Service) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { // Not implemented since there is nothing to delete return nil } diff --git a/pkg/cloud/azure/services/availabilityzones/mock_availabilityzones/BUILD b/pkg/cloud/azure/services/availabilityzones/mock_availabilityzones/BUILD new file mode 100644 index 00000000000..e32d5b7ab46 --- /dev/null +++ b/pkg/cloud/azure/services/availabilityzones/mock_availabilityzones/BUILD @@ -0,0 +1,40 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +""" +go_mock( + name = "go_default_library", + importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/availabilityzones/mock_availabilityzones", + visibility = ["//visibility:public"], + mocks = [ + { + "prefix": "github.com/Azure/azure-sdk-for-go", + "package": "services/compute/mgmt/2019-03-01/compute/computeapi", + "interface": "ResourceSkusClientAPI", + "vendored": True, + }, + ], + deps = [ + "//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute:go_default_library", + ], +) +""" + +load("@bazel_gomock//:gomock.bzl", "gomock") + +gomock( + name = "mocks", + out = "availabilityzones_mock.go", + interfaces = [ + "ResourceSkusClientAPI", + ], + library = "//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/computeapi:go_default_library", + package = "mock_availabilityzones", + visibility = ["//visibility:public"], +) + +go_library( + name = "go_default_library", + srcs = ["availabilityzones_mock.go"], + importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/availabilityzones/mock_availabilityzones", + visibility = ["//visibility:public"], +) diff --git a/pkg/cloud/azure/services/certificates/certificates.go b/pkg/cloud/azure/services/certificates/certificates.go index 5f7e44d49d4..13c43c8d41f 100644 --- a/pkg/cloud/azure/services/certificates/certificates.go +++ b/pkg/cloud/azure/services/certificates/certificates.go @@ -45,17 +45,17 @@ import ( ) // Get should implement returning certs and kubeconfigs. -func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) { +func (s *Service) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { return nil, errors.New("Not implemented") } // Delete cleans up and generated certificates, could be useful for renewal. -func (s *Service) Delete(ctx context.Context, spec azure.Spec) error { +func (s *Service) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { return nil } // Reconcile Helper function so this can be unittested. -func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { +func (s *Service) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { klog.V(2).Infof("generating certificates") clusterName := s.scope.Cluster.Name tmpDirName := "/tmp/cluster-api/" + clusterName diff --git a/pkg/cloud/azure/services/groups/BUILD.bazel b/pkg/cloud/azure/services/groups/BUILD.bazel index f31b4955306..cfbe9b27747 100644 --- a/pkg/cloud/azure/services/groups/BUILD.bazel +++ b/pkg/cloud/azure/services/groups/BUILD.bazel @@ -9,6 +9,7 @@ go_library( importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/groups", visibility = ["//visibility:public"], deps = [ + "//pkg/apis/azureprovider/v1alpha1:go_default_library", "//pkg/cloud/azure:go_default_library", "//pkg/cloud/azure/actuators:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources:go_default_library", diff --git a/pkg/cloud/azure/services/groups/groups.go b/pkg/cloud/azure/services/groups/groups.go index 8ec98d79d40..9d5d5e1cac1 100644 --- a/pkg/cloud/azure/services/groups/groups.go +++ b/pkg/cloud/azure/services/groups/groups.go @@ -23,16 +23,16 @@ import ( "github.com/Azure/go-autorest/autorest/to" "github.com/pkg/errors" "k8s.io/klog" - "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure" + "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" ) // Get provides information about a resource group. -func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) { +func (s *Service) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { return s.Client.Get(ctx, s.Scope.ClusterConfig.ResourceGroup) } // // Reconcile gets/creates/updates a resource group. -func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { +func (s *Service) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { klog.V(2).Infof("creating resource group %s", s.Scope.ClusterConfig.ResourceGroup) _, err := s.Client.CreateOrUpdate(ctx, s.Scope.ClusterConfig.ResourceGroup, resources.Group{Location: to.StringPtr(s.Scope.ClusterConfig.Location)}) klog.V(2).Infof("successfully created resource group %s", s.Scope.ClusterConfig.ResourceGroup) @@ -40,7 +40,7 @@ func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { } // Delete deletes the resource group with the provided name. -func (s *Service) Delete(ctx context.Context, spec azure.Spec) error { +func (s *Service) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { klog.V(2).Infof("deleting resource group %s", s.Scope.ClusterConfig.ResourceGroup) future, err := s.Client.Delete(ctx, s.Scope.ClusterConfig.ResourceGroup) if err != nil { diff --git a/pkg/cloud/azure/services/groups/mock_groups/BUILD b/pkg/cloud/azure/services/groups/mock_groups/BUILD new file mode 100644 index 00000000000..7f120fc22c8 --- /dev/null +++ b/pkg/cloud/azure/services/groups/mock_groups/BUILD @@ -0,0 +1,21 @@ +""" +load("//build:go_mock.bzl", "go_mock") + +go_mock( + name = "go_default_library", + importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/groups/mock_groups", + visibility = ["//visibility:public"], + mocks = [ + { + "prefix": "github.com/Azure/azure-sdk-for-go", + "package": "services/resources/mgmt/2018-05-01/resources/resourcesapi", + "interface": "GroupsClientAPI", + "vendored": True, + }, + ], + deps = [ + "//vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources:go_default_library", + "//vendor/github.com/Azure/go-autorest/autorest:go_default_library", + ], +) +""" diff --git a/pkg/cloud/azure/services/internalloadbalancers/BUILD.bazel b/pkg/cloud/azure/services/internalloadbalancers/BUILD.bazel index ae1ef798263..185d6669130 100644 --- a/pkg/cloud/azure/services/internalloadbalancers/BUILD.bazel +++ b/pkg/cloud/azure/services/internalloadbalancers/BUILD.bazel @@ -9,6 +9,7 @@ go_library( importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/internalloadbalancers", visibility = ["//visibility:public"], deps = [ + "//pkg/apis/azureprovider/v1alpha1:go_default_library", "//pkg/cloud/azure:go_default_library", "//pkg/cloud/azure/actuators:go_default_library", "//pkg/cloud/azure/services/subnets:go_default_library", diff --git a/pkg/cloud/azure/services/internalloadbalancers/internalloadbalancers.go b/pkg/cloud/azure/services/internalloadbalancers/internalloadbalancers.go index 611c89a0eae..2e589ffe464 100644 --- a/pkg/cloud/azure/services/internalloadbalancers/internalloadbalancers.go +++ b/pkg/cloud/azure/services/internalloadbalancers/internalloadbalancers.go @@ -24,6 +24,7 @@ import ( "github.com/Azure/go-autorest/autorest/to" "github.com/pkg/errors" "k8s.io/klog" + "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure" "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/subnets" ) @@ -37,7 +38,7 @@ type Spec struct { } // Get provides information about an internal load balancer. -func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) { +func (s *Service) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { internalLBSpec, ok := spec.(*Spec) if !ok { return network.LoadBalancer{}, errors.New("invalid internal load balancer specification") @@ -53,7 +54,7 @@ func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) } // Reconcile gets/creates/updates an internal load balancer. -func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { +func (s *Service) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { internalLBSpec, ok := spec.(*Spec) if !ok { return errors.New("invalid internal load balancer specification") @@ -151,7 +152,7 @@ func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { } // Delete deletes the internal load balancer with the provided name. -func (s *Service) Delete(ctx context.Context, spec azure.Spec) error { +func (s *Service) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { internalLBSpec, ok := spec.(*Spec) if !ok { return errors.New("invalid internal load balancer specification") diff --git a/pkg/cloud/azure/services/internalloadbalancers/mock_internalloadbalancers/BUILD b/pkg/cloud/azure/services/internalloadbalancers/mock_internalloadbalancers/BUILD new file mode 100644 index 00000000000..7c10c2bfc45 --- /dev/null +++ b/pkg/cloud/azure/services/internalloadbalancers/mock_internalloadbalancers/BUILD @@ -0,0 +1,19 @@ +"""load("//build:go_mock.bzl", "go_mock") + +go_mock( + name = "go_default_library", + importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/internalloadbalancers/mock_internalloadbalancers", + visibility = ["//visibility:public"], + mocks = [ + { + "prefix": "github.com/Azure/azure-sdk-for-go", + "package": "services/network/mgmt/2018-12-01/network/networkapi", + "interface": "LoadBalancersClientAPI", + "vendored": True, + }, + ], + deps = [ + "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network:go_default_library", + ], +) +""" diff --git a/pkg/cloud/azure/services/mock_interfaces.go b/pkg/cloud/azure/services/mock_interfaces.go deleted file mode 100644 index 1f72bcb3e6b..00000000000 --- a/pkg/cloud/azure/services/mock_interfaces.go +++ /dev/null @@ -1,267 +0,0 @@ -/* -Copyright 2018 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 services - -import ( - "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute" - "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network" - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources" - "github.com/Azure/go-autorest/autorest" - providerv1 "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" - clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" -) - -// MockAzureComputeClient is a mock implementation of AzureComputeClient. -type MockAzureComputeClient struct { - MockRunCommand func(resourceGroup string, name string, cmd string) (compute.VirtualMachinesRunCommandFuture, error) - MockVMIfExists func(resourceGroup string, name string) (*compute.VirtualMachine, error) - MockDeleteVM func(resourceGroup string, name string) (compute.VirtualMachinesDeleteFuture, error) - MockWaitForVMRunCommandFuture func(future compute.VirtualMachinesRunCommandFuture) error - MockWaitForVMDeletionFuture func(future compute.VirtualMachinesDeleteFuture) error - MockDeleteManagedDisk func(resourceGroup string, name string) (compute.DisksDeleteFuture, error) - MockWaitForDisksDeleteFuture func(future compute.DisksDeleteFuture) error -} - -// MockAzureNetworkClient is a mock implementation of MockAzureNetworkClient. -type MockAzureNetworkClient struct { - MockDeleteNetworkInterface func(resourceGroup string, networkInterfaceName string) (network.InterfacesDeleteFuture, error) - MockWaitForNetworkInterfacesDeleteFuture func(future network.InterfacesDeleteFuture) error - - MockCreateOrUpdateNetworkSecurityGroup func(resourceGroupName string, networkSecurityGroupName string, location string) (*network.SecurityGroupsCreateOrUpdateFuture, error) - MockNetworkSGIfExists func(resourceGroupName string, networkSecurityGroupName string) (*network.SecurityGroup, error) - MockWaitForNetworkSGsCreateOrUpdateFuture func(future network.SecurityGroupsCreateOrUpdateFuture) error - - MockCreateOrUpdatePublicIPAddress func(resourceGroup string, IPName string) (network.PublicIPAddress, error) - MockDeletePublicIPAddress func(resourceGroup string, IPName string) (network.PublicIPAddressesDeleteFuture, error) - MockWaitForPublicIPAddressDeleteFuture func(future network.PublicIPAddressesDeleteFuture) error - - MockCreateOrUpdateVnet func(resourceGroupName string, virtualNetworkName string, location string) (*network.VirtualNetworksCreateOrUpdateFuture, error) - MockWaitForVnetCreateOrUpdateFuture func(future network.VirtualNetworksCreateOrUpdateFuture) error -} - -// MockAzureResourcesClient is a mock implementation of MockAzureResourcesClient. -type MockAzureResourcesClient struct { - MockCreateOrUpdateGroup func(resourceGroupName string, location string) (resources.Group, error) - MockDeleteGroup func(resourceGroupName string) (resources.GroupsDeleteFuture, error) - MockCheckGroupExistence func(rgName string) (autorest.Response, error) - MockWaitForGroupsDeleteFuture func(future resources.GroupsDeleteFuture) error - - MockCreateOrUpdateDeployment func(machine *clusterv1.Machine, clusterConfig *providerv1.AzureClusterProviderSpec, machineConfig *providerv1.AzureMachineProviderSpec) (*resources.DeploymentsCreateOrUpdateFuture, error) - MockGetDeploymentResult func(future resources.DeploymentsCreateOrUpdateFuture) (de resources.DeploymentExtended, err error) - MockValidateDeployment func(machine *clusterv1.Machine, clusterConfig *providerv1.AzureClusterProviderSpec, machineConfig *providerv1.AzureMachineProviderSpec) error - MockWaitForDeploymentsCreateOrUpdateFuture func(future resources.DeploymentsCreateOrUpdateFuture) error -} - -// RunCommand executes a command on the VM. -func (m *MockAzureComputeClient) RunCommand(resourceGroup string, name string, cmd string) (compute.VirtualMachinesRunCommandFuture, error) { - if m.MockRunCommand == nil { - return compute.VirtualMachinesRunCommandFuture{}, nil - } - return m.MockRunCommand(resourceGroup, name, cmd) -} - -// VMIfExists returns the reference to the VM object if it exists. -func (m *MockAzureComputeClient) VMIfExists(resourceGroup string, name string) (*compute.VirtualMachine, error) { - if m.MockVMIfExists == nil { - return nil, nil - } - return m.MockVMIfExists(resourceGroup, name) -} - -// DeleteVM deletes the virtual machine. -func (m *MockAzureComputeClient) DeleteVM(resourceGroup string, name string) (compute.VirtualMachinesDeleteFuture, error) { - if m.MockDeleteVM == nil { - return compute.VirtualMachinesDeleteFuture{}, nil - } - return m.MockDeleteVM(resourceGroup, name) -} - -// DeleteManagedDisk deletes a managed disk resource. -func (m *MockAzureComputeClient) DeleteManagedDisk(resourceGroup string, name string) (compute.DisksDeleteFuture, error) { - if m.MockDeleteManagedDisk == nil { - return compute.DisksDeleteFuture{}, nil - } - return m.MockDeleteManagedDisk(resourceGroup, name) -} - -// WaitForVMRunCommandFuture returns when the RunCommand operation completes. -func (m *MockAzureComputeClient) WaitForVMRunCommandFuture(future compute.VirtualMachinesRunCommandFuture) error { - if m.MockWaitForVMRunCommandFuture == nil { - return nil - } - return m.MockWaitForVMRunCommandFuture(future) -} - -// WaitForVMDeletionFuture returns when the DeleteVM operation completes. -func (m *MockAzureComputeClient) WaitForVMDeletionFuture(future compute.VirtualMachinesDeleteFuture) error { - if m.MockWaitForVMDeletionFuture == nil { - return nil - } - return m.MockWaitForVMDeletionFuture(future) -} - -// WaitForDisksDeleteFuture waits for the DeleteManagedDisk operation to complete. -func (m *MockAzureComputeClient) WaitForDisksDeleteFuture(future compute.DisksDeleteFuture) error { - if m.MockWaitForDisksDeleteFuture == nil { - return nil - } - return m.MockWaitForDisksDeleteFuture(future) -} - -// DeleteNetworkInterface deletes the NIC resource. -func (m *MockAzureNetworkClient) DeleteNetworkInterface(resourceGroup string, networkInterfaceName string) (network.InterfacesDeleteFuture, error) { - if m.MockDeleteNetworkInterface == nil { - return network.InterfacesDeleteFuture{}, nil - } - return m.MockDeleteNetworkInterface(resourceGroup, networkInterfaceName) -} - -// WaitForNetworkInterfacesDeleteFuture returns when the DeleteNetworkInterface operation completes. -func (m *MockAzureNetworkClient) WaitForNetworkInterfacesDeleteFuture(future network.InterfacesDeleteFuture) error { - if m.MockWaitForNetworkInterfacesDeleteFuture == nil { - return nil - } - return m.MockWaitForNetworkInterfacesDeleteFuture(future) -} - -// CreateOrUpdatePublicIPAddress retrieves the reference of the PublicIPAddress resource. -func (m *MockAzureNetworkClient) CreateOrUpdatePublicIPAddress(resourceGroup string, IPName string) (network.PublicIPAddress, error) { - if m.MockCreateOrUpdatePublicIPAddress == nil { - return network.PublicIPAddress{}, nil - } - return m.MockCreateOrUpdatePublicIPAddress(resourceGroup, IPName) -} - -// DeletePublicIPAddress deletes the PublicIPAddress resource. -func (m *MockAzureNetworkClient) DeletePublicIPAddress(resourceGroup string, IPName string) (network.PublicIPAddressesDeleteFuture, error) { - if m.MockDeletePublicIPAddress == nil { - return network.PublicIPAddressesDeleteFuture{}, nil - } - return m.MockDeletePublicIPAddress(resourceGroup, IPName) -} - -// WaitForPublicIPAddressDeleteFuture returns when the DeletePublicIPAddress completes. -func (m *MockAzureNetworkClient) WaitForPublicIPAddressDeleteFuture(future network.PublicIPAddressesDeleteFuture) error { - if m.MockWaitForPublicIPAddressDeleteFuture == nil { - return nil - } - return m.MockWaitForPublicIPAddressDeleteFuture(future) -} - -// CreateOrUpdateNetworkSecurityGroup creates or updates the NSG resource. -func (m *MockAzureNetworkClient) CreateOrUpdateNetworkSecurityGroup(resourceGroupName string, networkSecurityGroupName string, location string) (*network.SecurityGroupsCreateOrUpdateFuture, error) { - if m.MockCreateOrUpdateNetworkSecurityGroup == nil { - return nil, nil - } - return m.MockCreateOrUpdateNetworkSecurityGroup(resourceGroupName, networkSecurityGroupName, location) -} - -// NetworkSGIfExists returns the nsg resource reference if it exists. -func (m *MockAzureNetworkClient) NetworkSGIfExists(resourceGroupName string, networkSecurityGroupName string) (*network.SecurityGroup, error) { - if m.MockNetworkSGIfExists == nil { - return nil, nil - } - return m.MockNetworkSGIfExists(resourceGroupName, networkSecurityGroupName) -} - -// WaitForNetworkSGsCreateOrUpdateFuture returns when the CreateOrUpdateNetworkSecurityGroup operation completes. -func (m *MockAzureNetworkClient) WaitForNetworkSGsCreateOrUpdateFuture(future network.SecurityGroupsCreateOrUpdateFuture) error { - if m.MockWaitForNetworkSGsCreateOrUpdateFuture == nil { - return nil - } - return m.MockWaitForNetworkSGsCreateOrUpdateFuture(future) -} - -// CreateOrUpdateVnet creates or updates the vnet resource. -func (m *MockAzureNetworkClient) CreateOrUpdateVnet(resourceGroupName string, virtualNetworkName string, location string) (*network.VirtualNetworksCreateOrUpdateFuture, error) { - if m.MockCreateOrUpdateVnet == nil { - return nil, nil - } - return m.MockCreateOrUpdateVnet(resourceGroupName, virtualNetworkName, location) -} - -// WaitForVnetCreateOrUpdateFuture returns when the CreateOrUpdateVnet operation completes. -func (m *MockAzureNetworkClient) WaitForVnetCreateOrUpdateFuture(future network.VirtualNetworksCreateOrUpdateFuture) error { - if m.MockWaitForVnetCreateOrUpdateFuture == nil { - return nil - } - return m.MockWaitForVnetCreateOrUpdateFuture(future) -} - -// CreateOrUpdateGroup creates or updates an azure resource group. -func (m *MockAzureResourcesClient) CreateOrUpdateGroup(resourceGroupName string, location string) (resources.Group, error) { - if m.MockCreateOrUpdateGroup == nil { - return resources.Group{}, nil - } - return m.MockCreateOrUpdateGroup(resourceGroupName, location) -} - -// DeleteGroup deletes an azure resource group. -func (m *MockAzureResourcesClient) DeleteGroup(resourceGroupName string) (resources.GroupsDeleteFuture, error) { - if m.MockDeleteGroup == nil { - return resources.GroupsDeleteFuture{}, nil - } - return m.MockDeleteGroup(resourceGroupName) -} - -// CheckGroupExistence checks if a resource group with name 'rgName' exists. -func (m *MockAzureResourcesClient) CheckGroupExistence(rgName string) (autorest.Response, error) { - if m.MockCheckGroupExistence == nil { - return autorest.Response{}, nil - } - return m.MockCheckGroupExistence(rgName) -} - -// WaitForGroupsDeleteFuture returns when the DeleteGroup operation completes. -func (m *MockAzureResourcesClient) WaitForGroupsDeleteFuture(future resources.GroupsDeleteFuture) error { - if m.MockWaitForGroupsDeleteFuture == nil { - return nil - } - return m.MockWaitForGroupsDeleteFuture(future) -} - -// CreateOrUpdateDeployment creates or updates an ARM deployment. -func (m *MockAzureResourcesClient) CreateOrUpdateDeployment(machine *clusterv1.Machine, clusterConfig *providerv1.AzureClusterProviderSpec, machineConfig *providerv1.AzureMachineProviderSpec) (*resources.DeploymentsCreateOrUpdateFuture, error) { - if m.MockCreateOrUpdateDeployment == nil { - return nil, nil - } - return m.MockCreateOrUpdateDeployment(machine, clusterConfig, machineConfig) -} - -// ValidateDeployment validates an ARM deployment. -func (m *MockAzureResourcesClient) ValidateDeployment(machine *clusterv1.Machine, clusterConfig *providerv1.AzureClusterProviderSpec, machineConfig *providerv1.AzureMachineProviderSpec) error { - if m.MockValidateDeployment == nil { - return nil - } - return m.MockValidateDeployment(machine, clusterConfig, machineConfig) -} - -// GetDeploymentResult retrives an existing ARM deployment reference. -func (m *MockAzureResourcesClient) GetDeploymentResult(future resources.DeploymentsCreateOrUpdateFuture) (de resources.DeploymentExtended, err error) { - if m.MockGetDeploymentResult == nil { - return resources.DeploymentExtended{}, nil - } - return m.MockGetDeploymentResult(future) -} - -// WaitForDeploymentsCreateOrUpdateFuture returns when the CreateOrUpdateDeployment operation completes. -func (m *MockAzureResourcesClient) WaitForDeploymentsCreateOrUpdateFuture(future resources.DeploymentsCreateOrUpdateFuture) error { - if m.MockWaitForDeploymentsCreateOrUpdateFuture == nil { - return nil - } - return m.MockWaitForDeploymentsCreateOrUpdateFuture(future) -} diff --git a/pkg/cloud/azure/services/mock_interfaces_helper.go b/pkg/cloud/azure/services/mock_interfaces_helper.go deleted file mode 100644 index f579355a969..00000000000 --- a/pkg/cloud/azure/services/mock_interfaces_helper.go +++ /dev/null @@ -1,358 +0,0 @@ -/* -Copyright 2018 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 services - -import ( - "errors" - "fmt" - "net/http" - - "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute" - "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network" - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/to" - providerv1 "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" - clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" -) - -// MockVMExists mocks the VMIfExists success response. -func MockVMExists() MockAzureComputeClient { - return MockAzureComputeClient{ - MockVMIfExists: func(resourceGroup string, name string) (*compute.VirtualMachine, error) { - networkProfile := compute.NetworkProfile{NetworkInterfaces: &[]compute.NetworkInterfaceReference{{ID: to.StringPtr("001")}}} - OsDiskName := fmt.Sprintf("OS_Disk_%v", name) - storageProfile := compute.StorageProfile{OsDisk: &compute.OSDisk{Name: &OsDiskName}} - vmProperties := compute.VirtualMachineProperties{StorageProfile: &storageProfile, NetworkProfile: &networkProfile} - return &compute.VirtualMachine{Name: &name, VirtualMachineProperties: &vmProperties}, nil - }, - } -} - -// MockVMExistsNICInvalid mocks the VMIfExists Invalid NIC response. -func MockVMExistsNICInvalid() MockAzureComputeClient { - return MockAzureComputeClient{ - MockVMIfExists: func(resourceGroup string, name string) (*compute.VirtualMachine, error) { - networkProfile := compute.NetworkProfile{NetworkInterfaces: &[]compute.NetworkInterfaceReference{{ID: to.StringPtr("")}}} - OsDiskName := fmt.Sprintf("OS_Disk_%v", name) - storageProfile := compute.StorageProfile{OsDisk: &compute.OSDisk{Name: &OsDiskName}} - vmProperties := compute.VirtualMachineProperties{StorageProfile: &storageProfile, NetworkProfile: &networkProfile} - return &compute.VirtualMachine{Name: &name, VirtualMachineProperties: &vmProperties}, nil - }, - } -} - -// MockVMNotExists mocks the VMExists not found response. -func MockVMNotExists() MockAzureComputeClient { - return MockAzureComputeClient{ - MockVMIfExists: func(resourceGroup string, name string) (*compute.VirtualMachine, error) { - return nil, nil - }, - } -} - -// MockVMCheckFailure mocks the VMIfExists failure response -func MockVMCheckFailure() MockAzureComputeClient { - return MockAzureComputeClient{ - MockVMIfExists: func(resourceGroup string, name string) (*compute.VirtualMachine, error) { - return &compute.VirtualMachine{}, errors.New("error while checking if vm exists") - }, - } -} - -// MockVMDeleteFailure mocks the VMDelete failure response. -func MockVMDeleteFailure() MockAzureComputeClient { - return MockAzureComputeClient{ - MockDeleteVM: func(resourceGroup string, name string) (compute.VirtualMachinesDeleteFuture, error) { - return compute.VirtualMachinesDeleteFuture{}, errors.New("error while deleting vm") - }, - } -} - -// MockVMDeleteFutureFailure mocks the VMDeleteFutureFailure response. -func MockVMDeleteFutureFailure() MockAzureComputeClient { - return MockAzureComputeClient{ - MockWaitForVMDeletionFuture: func(future compute.VirtualMachinesDeleteFuture) error { - return errors.New("failed on waiting for VirtualMachinesDeleteFuture") - }, - } -} - -// MockDisksDeleteFailure mocks the Disks Delete failure response. -func MockDisksDeleteFailure() MockAzureComputeClient { - return MockAzureComputeClient{ - MockDeleteManagedDisk: func(resourceGroup string, name string) (compute.DisksDeleteFuture, error) { - return compute.DisksDeleteFuture{}, errors.New("error while deleting managed disk") - }, - } -} - -// MockDisksDeleteFutureFailure mocks the Disks Delete Future failure response. -func MockDisksDeleteFutureFailure() MockAzureComputeClient { - return MockAzureComputeClient{ - MockWaitForDisksDeleteFuture: func(future compute.DisksDeleteFuture) error { - return errors.New("failed on waiting for VirtualMachinesDeleteFuture") - }, - } -} - -// MockRunCommandFailure mocks the RunCommand failure response. -func MockRunCommandFailure() MockAzureComputeClient { - return MockAzureComputeClient{ - MockRunCommand: func(resourceGroup string, name string, cmd string) (compute.VirtualMachinesRunCommandFuture, error) { - return compute.VirtualMachinesRunCommandFuture{}, errors.New("error while running command on vm") - }, - } -} - -// MockRunCommandFutureFailure mocks the RunCommand's future failure response. -func MockRunCommandFutureFailure() MockAzureComputeClient { - return MockAzureComputeClient{ - MockWaitForVMRunCommandFuture: func(future compute.VirtualMachinesRunCommandFuture) error { - return errors.New("failed on waiting for VirtualMachinesRunCommandFuture") - }, - } -} - -// MockNsgCreateOrUpdateSuccess mocks the SecurityGroupsCreateOrUpdateFuture response. -func MockNsgCreateOrUpdateSuccess() MockAzureNetworkClient { - return MockAzureNetworkClient{ - MockCreateOrUpdateNetworkSecurityGroup: func(resourceGroupName string, networkSecurityGroupName string, location string) (*network.SecurityGroupsCreateOrUpdateFuture, error) { - return &network.SecurityGroupsCreateOrUpdateFuture{}, nil - }, - } -} - -// MockNsgCreateOrUpdateFailure SecurityGroupsCreateOrUpdateFuture failure response. -func MockNsgCreateOrUpdateFailure() MockAzureNetworkClient { - return MockAzureNetworkClient{ - MockCreateOrUpdateNetworkSecurityGroup: func(resourceGroupName string, networkSecurityGroupName string, location string) (*network.SecurityGroupsCreateOrUpdateFuture, error) { - return nil, errors.New("failed to create or update network security group") - }, - } -} - -// MockVnetCreateOrUpdateSuccess mocks the VnetCreateOrUpdateSuccess response. -func MockVnetCreateOrUpdateSuccess() MockAzureNetworkClient { - return MockAzureNetworkClient{ - MockCreateOrUpdateVnet: func(resourceGroupName string, virtualNetworkName string, location string) (*network.VirtualNetworksCreateOrUpdateFuture, error) { - return &network.VirtualNetworksCreateOrUpdateFuture{}, nil - }, - } -} - -// MockVnetCreateOrUpdateFailure mocks the VnetCreateOrUpdateSuccess failure response. -func MockVnetCreateOrUpdateFailure() MockAzureNetworkClient { - return MockAzureNetworkClient{ - MockCreateOrUpdateVnet: func(resourceGroupName string, virtualNetworkName string, location string) (*network.VirtualNetworksCreateOrUpdateFuture, error) { - return nil, errors.New("failed to create or update vnet") - }, - } -} - -// MockNsgCreateOrUpdateFutureFailure mocks the SecurityGroupsCreateOrUpdateSuccess future failure response. -func MockNsgCreateOrUpdateFutureFailure() MockAzureNetworkClient { - return MockAzureNetworkClient{ - MockWaitForNetworkSGsCreateOrUpdateFuture: func(future network.SecurityGroupsCreateOrUpdateFuture) error { - return errors.New("failed on waiting for SecurityGroupsCreateOrUpdateFuture") - }, - } -} - -// MockVnetCreateOrUpdateFutureFailure mocks the VnetCreateOrUpdate future failure response. -func MockVnetCreateOrUpdateFutureFailure() MockAzureNetworkClient { - return MockAzureNetworkClient{ - MockWaitForVnetCreateOrUpdateFuture: func(future network.VirtualNetworksCreateOrUpdateFuture) error { - return errors.New("failed on waiting for VirtualNetworksCreateOrUpdateFuture") - }, - } -} - -// MockNicDeleteFailure mocks the InterfacesDelete failure response. -func MockNicDeleteFailure() MockAzureNetworkClient { - return MockAzureNetworkClient{ - MockDeleteNetworkInterface: func(resourceGroup string, networkInterfaceName string) (network.InterfacesDeleteFuture, error) { - return network.InterfacesDeleteFuture{}, errors.New("failed to delete network interface") - }, - } -} - -// MockNicDeleteFutureFailure mocks the InterfacesDelete future failure response. -func MockNicDeleteFutureFailure() MockAzureNetworkClient { - return MockAzureNetworkClient{ - MockWaitForNetworkInterfacesDeleteFuture: func(future network.InterfacesDeleteFuture) error { - return errors.New("failed on waiting for InterfacesDeleteFuture") - }, - } -} - -// MockPublicIPDeleteFailure mocks the PublicIPDeleteFailure response. -func MockPublicIPDeleteFailure() MockAzureNetworkClient { - return MockAzureNetworkClient{ - MockDeletePublicIPAddress: func(resourceGroup string, IPName string) (network.PublicIPAddressesDeleteFuture, error) { - return network.PublicIPAddressesDeleteFuture{}, errors.New("failed to delete public ip address") - }, - } -} - -// MockPublicIPDeleteFutureFailure mocks the PublicIPDeleteFailure future response. -func MockPublicIPDeleteFutureFailure() MockAzureNetworkClient { - return MockAzureNetworkClient{ - MockWaitForPublicIPAddressDeleteFuture: func(future network.PublicIPAddressesDeleteFuture) error { - return errors.New("failed on waiting for PublicIPAddressesDeleteFuture") - }, - } -} - -// MockCreateOrUpdatePublicIPAddress mocks the CreateOrUpdatePublicIPAddress success response. -func MockCreateOrUpdatePublicIPAddress(ip string) MockAzureNetworkClient { - return MockAzureNetworkClient{ - MockCreateOrUpdatePublicIPAddress: func(resourceGroup string, IPName string) (network.PublicIPAddress, error) { - publicIPAddress := network.PublicIPAddress{PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{}} - publicIPAddress.IPAddress = to.StringPtr(ip) - return publicIPAddress, nil - }, - } -} - -// MockCreateOrUpdatePublicIPAddressFailure mocks the CreateOrUpdatePublicIPAddress failure response. -func MockCreateOrUpdatePublicIPAddressFailure() MockAzureNetworkClient { - return MockAzureNetworkClient{ - MockCreateOrUpdatePublicIPAddress: func(resourceGroup string, IPName string) (network.PublicIPAddress, error) { - return network.PublicIPAddress{}, errors.New("failed to get public ip address") - }, - } -} - -// ResourceManagement Mocks - -// MockRgExists mocks the CheckGroupExistence response. -func MockRgExists() MockAzureResourcesClient { - return MockAzureResourcesClient{ - MockCheckGroupExistence: func(rgName string) (autorest.Response, error) { - return autorest.Response{Response: &http.Response{StatusCode: 200}}, nil - }, - } -} - -// MockRgNotExists mocks the CheckGroupExistence not found response. -func MockRgNotExists() MockAzureResourcesClient { - return MockAzureResourcesClient{ - MockCheckGroupExistence: func(rgName string) (autorest.Response, error) { - return autorest.Response{Response: &http.Response{StatusCode: 404}}, nil - }, - } -} - -// MockRgCheckFailure mocks the CheckGroupExistence failure response. -func MockRgCheckFailure() MockAzureResourcesClient { - return MockAzureResourcesClient{ - MockCheckGroupExistence: func(rgName string) (autorest.Response, error) { - return autorest.Response{Response: &http.Response{StatusCode: 200}}, errors.New("failed to check resource group existence") - }, - } -} - -// MockRgCreateOrUpdateFailure mocks the CheckGroupExistence future failure response. -func MockRgCreateOrUpdateFailure() MockAzureResourcesClient { - return MockAzureResourcesClient{ - MockCreateOrUpdateGroup: func(resourceGroupName string, location string) (resources.Group, error) { - return resources.Group{}, errors.New("failed to create resource group") - }, - } -} - -// MockRgDeleteSuccess mocks the WaitForGroupsDeleteFuture response -func MockRgDeleteSuccess() MockAzureResourcesClient { - return MockAzureResourcesClient{ - MockDeleteGroup: func(resourceGroupName string) (resources.GroupsDeleteFuture, error) { - return resources.GroupsDeleteFuture{}, nil - }, - } -} - -// MockRgDeleteFailure mocks the groups delete response. -func MockRgDeleteFailure() MockAzureResourcesClient { - return MockAzureResourcesClient{ - MockDeleteGroup: func(resourceGroupName string) (resources.GroupsDeleteFuture, error) { - return resources.GroupsDeleteFuture{}, errors.New("failed to delete resource group") - }, - } -} - -// MockRgDeleteFutureFailure mocks the WaitForGroupsDeleteFuture failure response. -func MockRgDeleteFutureFailure() MockAzureResourcesClient { - return MockAzureResourcesClient{ - MockWaitForGroupsDeleteFuture: func(future resources.GroupsDeleteFuture) error { - return errors.New("error waiting for GroupsDeleteFuture") - }, - } -} - -// MockDeploymentCreateOrUpdateSuccess mocks the DeploymentCreateOrUpdate success response. -func MockDeploymentCreateOrUpdateSuccess() MockAzureResourcesClient { - return MockAzureResourcesClient{ - MockCreateOrUpdateDeployment: func(machine *clusterv1.Machine, clusterConfig *providerv1.AzureClusterProviderSpec, machineConfig *providerv1.AzureMachineProviderSpec) (*resources.DeploymentsCreateOrUpdateFuture, error) { - return &resources.DeploymentsCreateOrUpdateFuture{}, nil - }, - } -} - -// MockDeploymentCreateOrUpdateFailure mocks the DeploymentCreateOrUpdate failure response. -func MockDeploymentCreateOrUpdateFailure() MockAzureResourcesClient { - return MockAzureResourcesClient{ - MockCreateOrUpdateDeployment: func(machine *clusterv1.Machine, clusterConfig *providerv1.AzureClusterProviderSpec, machineConfig *providerv1.AzureMachineProviderSpec) (*resources.DeploymentsCreateOrUpdateFuture, error) { - return nil, errors.New("failed to create resource") - }, - } -} - -// MockDeploymentCreateOrUpdateFutureFailure mocks the DeploymentCreateOrUpdate future failure response. -func MockDeploymentCreateOrUpdateFutureFailure() MockAzureResourcesClient { - return MockAzureResourcesClient{ - MockWaitForDeploymentsCreateOrUpdateFuture: func(future resources.DeploymentsCreateOrUpdateFuture) error { - return errors.New("failed on waiting for DeploymentsCreateOrUpdateFuture") - }, - } -} - -// MockDeloymentGetResultSuccess mocks the DeploymentGetResult success response. -func MockDeloymentGetResultSuccess() MockAzureResourcesClient { - return MockAzureResourcesClient{ - MockGetDeploymentResult: func(future resources.DeploymentsCreateOrUpdateFuture) (resources.DeploymentExtended, error) { - return resources.DeploymentExtended{Name: to.StringPtr("deployment-test")}, nil - }, - } -} - -// MockDeloymentGetResultFailure mocks the DeploymentGetResult failure response. -func MockDeloymentGetResultFailure() MockAzureResourcesClient { - return MockAzureResourcesClient{ - MockGetDeploymentResult: func(future resources.DeploymentsCreateOrUpdateFuture) (resources.DeploymentExtended, error) { - return resources.DeploymentExtended{}, errors.New("error getting deployment result") - }, - } -} - -// MockDeploymentValidate mocks the DeploymentValidate error response. -func MockDeploymentValidate() MockAzureResourcesClient { - return MockAzureResourcesClient{ - MockValidateDeployment: func(machine *clusterv1.Machine, clusterConfig *providerv1.AzureClusterProviderSpec, machineConfig *providerv1.AzureMachineProviderSpec) error { - return errors.New("error validating deployment") - }, - } -} diff --git a/pkg/cloud/azure/services/networkinterfaces/BUILD.bazel b/pkg/cloud/azure/services/networkinterfaces/BUILD.bazel index 4e725ebaa0e..216c806e7b8 100644 --- a/pkg/cloud/azure/services/networkinterfaces/BUILD.bazel +++ b/pkg/cloud/azure/services/networkinterfaces/BUILD.bazel @@ -9,6 +9,7 @@ go_library( importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/networkinterfaces", visibility = ["//visibility:public"], deps = [ + "//pkg/apis/azureprovider/v1alpha1:go_default_library", "//pkg/cloud/azure:go_default_library", "//pkg/cloud/azure/actuators:go_default_library", "//pkg/cloud/azure/services/internalloadbalancers:go_default_library", diff --git a/pkg/cloud/azure/services/networkinterfaces/mock_networkinterfaces/BUILD b/pkg/cloud/azure/services/networkinterfaces/mock_networkinterfaces/BUILD new file mode 100644 index 00000000000..18fdbe64bf9 --- /dev/null +++ b/pkg/cloud/azure/services/networkinterfaces/mock_networkinterfaces/BUILD @@ -0,0 +1,19 @@ +"""load("//build:go_mock.bzl", "go_mock") + +go_mock( + name = "go_default_library", + importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/networkinterfaces/mock_networkinterfaces", + visibility = ["//visibility:public"], + mocks = [ + { + "prefix": "github.com/Azure/azure-sdk-for-go", + "package": "services/network/mgmt/2018-12-01/network/networkapi", + "interface": "InterfacesClientAPI", + "vendored": True, + }, + ], + deps = [ + "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network:go_default_library", + ], +) +""" diff --git a/pkg/cloud/azure/services/networkinterfaces/networkinterfaces.go b/pkg/cloud/azure/services/networkinterfaces/networkinterfaces.go index 369ae6841e2..9aa3e875d54 100644 --- a/pkg/cloud/azure/services/networkinterfaces/networkinterfaces.go +++ b/pkg/cloud/azure/services/networkinterfaces/networkinterfaces.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/go-autorest/autorest/to" "github.com/pkg/errors" "k8s.io/klog" + "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure" "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/internalloadbalancers" "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/publicloadbalancers" @@ -41,7 +42,7 @@ type Spec struct { } // Get provides information about a network interface. -func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) { +func (s *Service) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { nicSpec, ok := spec.(*Spec) if !ok { return network.Interface{}, errors.New("invalid network interface specification") @@ -56,7 +57,7 @@ func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) } // Reconcile gets/creates/updates a network interface. -func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { +func (s *Service) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { nicSpec, ok := spec.(*Spec) if !ok { return errors.New("invalid network interface specification") @@ -153,7 +154,7 @@ func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { } // Delete deletes the network interface with the provided name. -func (s *Service) Delete(ctx context.Context, spec azure.Spec) error { +func (s *Service) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { nicSpec, ok := spec.(*Spec) if !ok { return errors.New("invalid network interface Specification") diff --git a/pkg/cloud/azure/services/publicips/BUILD.bazel b/pkg/cloud/azure/services/publicips/BUILD.bazel index 595228a00c3..fe834d45664 100644 --- a/pkg/cloud/azure/services/publicips/BUILD.bazel +++ b/pkg/cloud/azure/services/publicips/BUILD.bazel @@ -9,6 +9,7 @@ go_library( importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/publicips", visibility = ["//visibility:public"], deps = [ + "//pkg/apis/azureprovider/v1alpha1:go_default_library", "//pkg/cloud/azure:go_default_library", "//pkg/cloud/azure/actuators:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network:go_default_library", diff --git a/pkg/cloud/azure/services/publicips/mock_publicips/BUILD b/pkg/cloud/azure/services/publicips/mock_publicips/BUILD new file mode 100644 index 00000000000..3737ba32a04 --- /dev/null +++ b/pkg/cloud/azure/services/publicips/mock_publicips/BUILD @@ -0,0 +1,19 @@ +"""load("//build:go_mock.bzl", "go_mock") + +go_mock( + name = "go_default_library", + importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/publicips/mock_publicips", + visibility = ["//visibility:public"], + mocks = [ + { + "prefix": "github.com/Azure/azure-sdk-for-go", + "package": "services/network/mgmt/2018-12-01/network/networkapi", + "interface": "PublicIPAddressesClientAPI", + "vendored": True, + }, + ], + deps = [ + "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network:go_default_library", + ], +) +""" diff --git a/pkg/cloud/azure/services/publicips/publicips.go b/pkg/cloud/azure/services/publicips/publicips.go index 2e970703a66..ddec260015f 100644 --- a/pkg/cloud/azure/services/publicips/publicips.go +++ b/pkg/cloud/azure/services/publicips/publicips.go @@ -24,6 +24,7 @@ import ( "github.com/Azure/go-autorest/autorest/to" "github.com/pkg/errors" "k8s.io/klog" + "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure" ) @@ -33,7 +34,7 @@ type Spec struct { } // Get provides information about a public ip. -func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) { +func (s *Service) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { publicIPSpec, ok := spec.(*Spec) if !ok { return network.PublicIPAddress{}, errors.New("Invalid PublicIP Specification") @@ -48,7 +49,7 @@ func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) } // Reconcile gets/creates/updates a public ip. -func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { +func (s *Service) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { publicIPSpec, ok := spec.(*Spec) if !ok { return errors.New("Invalid PublicIP Specification") @@ -94,7 +95,7 @@ func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { } // Delete deletes the public ip with the provided scope. -func (s *Service) Delete(ctx context.Context, spec azure.Spec) error { +func (s *Service) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { publicIPSpec, ok := spec.(*Spec) if !ok { return errors.New("Invalid PublicIP Specification") diff --git a/pkg/cloud/azure/services/publicloadbalancers/BUILD.bazel b/pkg/cloud/azure/services/publicloadbalancers/BUILD.bazel index 95dfd2d45be..d9d3a82dfa0 100644 --- a/pkg/cloud/azure/services/publicloadbalancers/BUILD.bazel +++ b/pkg/cloud/azure/services/publicloadbalancers/BUILD.bazel @@ -9,6 +9,7 @@ go_library( importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/publicloadbalancers", visibility = ["//visibility:public"], deps = [ + "//pkg/apis/azureprovider/v1alpha1:go_default_library", "//pkg/cloud/azure:go_default_library", "//pkg/cloud/azure/actuators:go_default_library", "//pkg/cloud/azure/services/publicips:go_default_library", diff --git a/pkg/cloud/azure/services/publicloadbalancers/mock_publicloadbalancers/BUILD b/pkg/cloud/azure/services/publicloadbalancers/mock_publicloadbalancers/BUILD new file mode 100644 index 00000000000..6e7b17e2a19 --- /dev/null +++ b/pkg/cloud/azure/services/publicloadbalancers/mock_publicloadbalancers/BUILD @@ -0,0 +1,19 @@ +"""load("//build:go_mock.bzl", "go_mock") + +go_mock( + name = "go_default_library", + importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/publicloadbalancers/mock_publicloadbalancers", + visibility = ["//visibility:public"], + mocks = [ + { + "prefix": "github.com/Azure/azure-sdk-for-go", + "package": "services/network/mgmt/2018-12-01/network/networkapi", + "interface": "LoadBalancersClientAPI", + "vendored": True, + }, + ], + deps = [ + "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network:go_default_library", + ], +) +""" diff --git a/pkg/cloud/azure/services/publicloadbalancers/publicloadbalancers.go b/pkg/cloud/azure/services/publicloadbalancers/publicloadbalancers.go index 4076748b011..0a9da24b63a 100644 --- a/pkg/cloud/azure/services/publicloadbalancers/publicloadbalancers.go +++ b/pkg/cloud/azure/services/publicloadbalancers/publicloadbalancers.go @@ -24,6 +24,7 @@ import ( "github.com/Azure/go-autorest/autorest/to" "github.com/pkg/errors" "k8s.io/klog" + "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure" "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/publicips" ) @@ -35,7 +36,7 @@ type Spec struct { } // Get provides information about a public load balancer. -func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) { +func (s *Service) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { publicLBSpec, ok := spec.(*Spec) if !ok { return network.LoadBalancer{}, errors.New("invalid public loadbalancer specification") @@ -50,7 +51,7 @@ func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) } // Reconcile gets/creates/updates a public load balancer. -func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { +func (s *Service) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { publicLBSpec, ok := spec.(*Spec) if !ok { return errors.New("invalid public loadbalancer specification") @@ -188,7 +189,7 @@ func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { } // Delete deletes the public load balancer with the provided name. -func (s *Service) Delete(ctx context.Context, spec azure.Spec) error { +func (s *Service) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { publicLBSpec, ok := spec.(*Spec) if !ok { return errors.New("invalid public loadbalancer specification") diff --git a/pkg/cloud/azure/services/routetables/BUILD.bazel b/pkg/cloud/azure/services/routetables/BUILD.bazel index 4edfe3d3f13..3eca401581e 100644 --- a/pkg/cloud/azure/services/routetables/BUILD.bazel +++ b/pkg/cloud/azure/services/routetables/BUILD.bazel @@ -9,6 +9,7 @@ go_library( importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/routetables", visibility = ["//visibility:public"], deps = [ + "//pkg/apis/azureprovider/v1alpha1:go_default_library", "//pkg/cloud/azure:go_default_library", "//pkg/cloud/azure/actuators:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network:go_default_library", diff --git a/pkg/cloud/azure/services/routetables/mock_routetables/BUILD b/pkg/cloud/azure/services/routetables/mock_routetables/BUILD new file mode 100644 index 00000000000..3e4c760d688 --- /dev/null +++ b/pkg/cloud/azure/services/routetables/mock_routetables/BUILD @@ -0,0 +1,19 @@ +"""load("//build:go_mock.bzl", "go_mock") + +go_mock( + name = "go_default_library", + importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/routetables/mock_routetables", + visibility = ["//visibility:public"], + mocks = [ + { + "prefix": "github.com/Azure/azure-sdk-for-go", + "package": "services/network/mgmt/2018-12-01/network/networkapi", + "interface": "RouteTablesClientAPI", + "vendored": True, + }, + ], + deps = [ + "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network:go_default_library", + ], +) +""" diff --git a/pkg/cloud/azure/services/routetables/routetables.go b/pkg/cloud/azure/services/routetables/routetables.go index f62a3935c15..9e055758b45 100644 --- a/pkg/cloud/azure/services/routetables/routetables.go +++ b/pkg/cloud/azure/services/routetables/routetables.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/go-autorest/autorest/to" "github.com/pkg/errors" "k8s.io/klog" + "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure" ) @@ -32,7 +33,7 @@ type Spec struct { } // Get provides information about a route table. -func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) { +func (s *Service) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { routeTableSpec, ok := spec.(*Spec) if !ok { return network.RouteTable{}, errors.New("Invalid Route Table Specification") @@ -47,7 +48,7 @@ func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) } // Reconcile gets/creates/updates a route table. -func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { +func (s *Service) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { routeTableSpec, ok := spec.(*Spec) if !ok { return errors.New("Invalid Route Table Specification") @@ -80,7 +81,7 @@ func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { } // Delete deletes the route table with the provided name. -func (s *Service) Delete(ctx context.Context, spec azure.Spec) error { +func (s *Service) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { routeTableSpec, ok := spec.(*Spec) if !ok { return errors.New("Invalid Route Table Specification") diff --git a/pkg/cloud/azure/services/securitygroups/BUILD.bazel b/pkg/cloud/azure/services/securitygroups/BUILD.bazel index c0fe216a8e2..443d5883929 100644 --- a/pkg/cloud/azure/services/securitygroups/BUILD.bazel +++ b/pkg/cloud/azure/services/securitygroups/BUILD.bazel @@ -9,6 +9,7 @@ go_library( importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/securitygroups", visibility = ["//visibility:public"], deps = [ + "//pkg/apis/azureprovider/v1alpha1:go_default_library", "//pkg/cloud/azure:go_default_library", "//pkg/cloud/azure/actuators:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network:go_default_library", diff --git a/pkg/cloud/azure/services/securitygroups/mock_securitygroups/BUILD b/pkg/cloud/azure/services/securitygroups/mock_securitygroups/BUILD new file mode 100644 index 00000000000..87cc846f6f3 --- /dev/null +++ b/pkg/cloud/azure/services/securitygroups/mock_securitygroups/BUILD @@ -0,0 +1,19 @@ +"""load("//build:go_mock.bzl", "go_mock") + +go_mock( + name = "go_default_library", + importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/securitygroups/mock_securitygroups", + visibility = ["//visibility:public"], + mocks = [ + { + "prefix": "github.com/Azure/azure-sdk-for-go", + "package": "services/network/mgmt/2018-12-01/network/networkapi", + "interface": "SecurityGroupsClientAPI", + "vendored": True, + }, + ], + deps = [ + "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network:go_default_library", + ], +) +""" diff --git a/pkg/cloud/azure/services/securitygroups/securitygroups.go b/pkg/cloud/azure/services/securitygroups/securitygroups.go index 1a918e59de3..ebb1a403de5 100644 --- a/pkg/cloud/azure/services/securitygroups/securitygroups.go +++ b/pkg/cloud/azure/services/securitygroups/securitygroups.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/go-autorest/autorest/to" "github.com/pkg/errors" "k8s.io/klog" + "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure" ) @@ -33,7 +34,7 @@ type Spec struct { } // Get provides information about a network security group. -func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) { +func (s *Service) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { nsgSpec, ok := spec.(*Spec) if !ok { return network.SecurityGroup{}, errors.New("invalid security groups specification") @@ -48,7 +49,7 @@ func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) } // Reconcile gets/creates/updates a network security group. -func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { +func (s *Service) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { nsgSpec, ok := spec.(*Spec) if !ok { return errors.New("invalid security groups specification") @@ -118,7 +119,7 @@ func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { } // Delete deletes the network security group with the provided name. -func (s *Service) Delete(ctx context.Context, spec azure.Spec) error { +func (s *Service) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { nsgSpec, ok := spec.(*Spec) if !ok { return errors.New("invalid security groups specification") diff --git a/pkg/cloud/azure/services/subnets/BUILD.bazel b/pkg/cloud/azure/services/subnets/BUILD.bazel index 9a6188bfca0..a43a6b1d962 100644 --- a/pkg/cloud/azure/services/subnets/BUILD.bazel +++ b/pkg/cloud/azure/services/subnets/BUILD.bazel @@ -9,6 +9,7 @@ go_library( importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/subnets", visibility = ["//visibility:public"], deps = [ + "//pkg/apis/azureprovider/v1alpha1:go_default_library", "//pkg/cloud/azure:go_default_library", "//pkg/cloud/azure/actuators:go_default_library", "//pkg/cloud/azure/services/routetables:go_default_library", diff --git a/pkg/cloud/azure/services/subnets/mock_subnets/BUILD b/pkg/cloud/azure/services/subnets/mock_subnets/BUILD new file mode 100644 index 00000000000..a8e56e580a2 --- /dev/null +++ b/pkg/cloud/azure/services/subnets/mock_subnets/BUILD @@ -0,0 +1,19 @@ +"""load("//build:go_mock.bzl", "go_mock") + +go_mock( + name = "go_default_library", + importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/subnets/mock_subnets", + visibility = ["//visibility:public"], + mocks = [ + { + "prefix": "github.com/Azure/azure-sdk-for-go", + "package": "services/network/mgmt/2018-12-01/network/networkapi", + "interface": "SubnetsClientAPI", + "vendored": True, + }, + ], + deps = [ + "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network:go_default_library", + ], +) +""" diff --git a/pkg/cloud/azure/services/subnets/subnets.go b/pkg/cloud/azure/services/subnets/subnets.go index d2c3649bbb4..74649fb312e 100644 --- a/pkg/cloud/azure/services/subnets/subnets.go +++ b/pkg/cloud/azure/services/subnets/subnets.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/go-autorest/autorest/to" "github.com/pkg/errors" "k8s.io/klog" + "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure" "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/routetables" "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/securitygroups" @@ -38,7 +39,7 @@ type Spec struct { } // Get provides information about a subnet. -func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) { +func (s *Service) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { subnetSpec, ok := spec.(*Spec) if !ok { return network.Subnet{}, errors.New("Invalid Subnet Specification") @@ -53,7 +54,7 @@ func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) } // Reconcile gets/creates/updates a subnet. -func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { +func (s *Service) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { subnetSpec, ok := spec.(*Spec) if !ok { return errors.New("Invalid Subnet Specification") @@ -116,7 +117,7 @@ func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { } // Delete deletes the subnet with the provided name. -func (s *Service) Delete(ctx context.Context, spec azure.Spec) error { +func (s *Service) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { subnetSpec, ok := spec.(*Spec) if !ok { return errors.New("Invalid Subnet Specification") diff --git a/pkg/cloud/azure/services/virtualmachineextensions/BUILD.bazel b/pkg/cloud/azure/services/virtualmachineextensions/BUILD.bazel index 10036267ec4..61c1e77be29 100644 --- a/pkg/cloud/azure/services/virtualmachineextensions/BUILD.bazel +++ b/pkg/cloud/azure/services/virtualmachineextensions/BUILD.bazel @@ -9,6 +9,7 @@ go_library( importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/virtualmachineextensions", visibility = ["//visibility:public"], deps = [ + "//pkg/apis/azureprovider/v1alpha1:go_default_library", "//pkg/cloud/azure:go_default_library", "//pkg/cloud/azure/actuators:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute:go_default_library", diff --git a/pkg/cloud/azure/services/virtualmachineextensions/mock_virtualmachineextensions/BUILD b/pkg/cloud/azure/services/virtualmachineextensions/mock_virtualmachineextensions/BUILD new file mode 100644 index 00000000000..48bef1fd429 --- /dev/null +++ b/pkg/cloud/azure/services/virtualmachineextensions/mock_virtualmachineextensions/BUILD @@ -0,0 +1,19 @@ +"""load("//build:go_mock.bzl", "go_mock") + +go_mock( + name = "go_default_library", + importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/virtualmachineextensions/mock_virtualmachineextensions", + visibility = ["//visibility:public"], + mocks = [ + { + "prefix": "github.com/Azure/azure-sdk-for-go", + "package": "services/compute/mgmt/2019-03-01/compute/computeapi", + "interface": "VirtualMachineExtensionsClientAPI", + "vendored": True, + }, + ], + deps = [ + "//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute:go_default_library", + ], +) +""" diff --git a/pkg/cloud/azure/services/virtualmachineextensions/virtualmachineextensions.go b/pkg/cloud/azure/services/virtualmachineextensions/virtualmachineextensions.go index 7bf65233894..eab97e8629b 100644 --- a/pkg/cloud/azure/services/virtualmachineextensions/virtualmachineextensions.go +++ b/pkg/cloud/azure/services/virtualmachineextensions/virtualmachineextensions.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/go-autorest/autorest/to" "github.com/pkg/errors" "k8s.io/klog" + "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure" ) @@ -34,7 +35,7 @@ type Spec struct { } // Get provides information about a virtual machine extension. -func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) { +func (s *Service) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { vmExtSpec, ok := spec.(*Spec) if !ok { return compute.VirtualMachineExtension{}, errors.New("invalid vm specification") @@ -49,7 +50,7 @@ func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) } // Reconcile gets/creates/updates a virtual machine extension. -func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { +func (s *Service) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { vmExtSpec, ok := spec.(*Spec) if !ok { return errors.New("invalid vm specification") @@ -98,7 +99,7 @@ func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { } // Delete deletes the virtual machine extension with the provided name. -func (s *Service) Delete(ctx context.Context, spec azure.Spec) error { +func (s *Service) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { vmExtSpec, ok := spec.(*Spec) if !ok { return errors.New("Invalid VNET Specification") diff --git a/pkg/cloud/azure/services/virtualmachines/mock_virtualmachines/BUILD b/pkg/cloud/azure/services/virtualmachines/mock_virtualmachines/BUILD new file mode 100644 index 00000000000..f22b87c9eb8 --- /dev/null +++ b/pkg/cloud/azure/services/virtualmachines/mock_virtualmachines/BUILD @@ -0,0 +1,20 @@ +"""load("//build:go_mock.bzl", "go_mock") + +go_mock( + name = "go_default_library", + importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/virtualmachines/mock_virtualmachines", + visibility = ["//visibility:public"], + mocks = [ + { + "prefix": "github.com/Azure/azure-sdk-for-go", + "package": "services/compute/mgmt/2019-03-01/compute/computeapi", + "interface": "VirtualMachinesClientAPI", + "vendored": True, + }, + ], + deps = [ + "//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute:go_default_library", + "//vendor/github.com/Azure/go-autorest/autorest:go_default_library", + ], +) +""" diff --git a/pkg/cloud/azure/services/virtualmachines/virtualmachines.go b/pkg/cloud/azure/services/virtualmachines/virtualmachines.go index 83cc19ca1a9..2c1d07bcfe0 100644 --- a/pkg/cloud/azure/services/virtualmachines/virtualmachines.go +++ b/pkg/cloud/azure/services/virtualmachines/virtualmachines.go @@ -46,7 +46,7 @@ type Spec struct { } // Get provides information about a virtual machine. -func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) { +func (s *Service) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { vmSpec, ok := spec.(*Spec) if !ok { return compute.VirtualMachine{}, errors.New("invalid vm specification") @@ -61,7 +61,7 @@ func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) } // Reconcile gets/creates/updates a virtual machine. -func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { +func (s *Service) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { vmSpec, ok := spec.(*Spec) if !ok { return errors.New("invalid vm specification") @@ -179,7 +179,7 @@ func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { } // Delete deletes the virtual machine with the provided name. -func (s *Service) Delete(ctx context.Context, spec azure.Spec) error { +func (s *Service) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { vmSpec, ok := spec.(*Spec) if !ok { return errors.New("invalid vm Specification") diff --git a/pkg/cloud/azure/services/virtualnetworks/BUILD.bazel b/pkg/cloud/azure/services/virtualnetworks/BUILD.bazel index 1dfbd2428fa..1f134c40d01 100644 --- a/pkg/cloud/azure/services/virtualnetworks/BUILD.bazel +++ b/pkg/cloud/azure/services/virtualnetworks/BUILD.bazel @@ -9,6 +9,7 @@ go_library( importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/virtualnetworks", visibility = ["//visibility:public"], deps = [ + "//pkg/apis/azureprovider/v1alpha1:go_default_library", "//pkg/cloud/azure:go_default_library", "//pkg/cloud/azure/actuators:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network:go_default_library", diff --git a/pkg/cloud/azure/services/virtualnetworks/mock_virtualnetworks/BUILD b/pkg/cloud/azure/services/virtualnetworks/mock_virtualnetworks/BUILD new file mode 100644 index 00000000000..53e71e30586 --- /dev/null +++ b/pkg/cloud/azure/services/virtualnetworks/mock_virtualnetworks/BUILD @@ -0,0 +1,19 @@ +"""load("//build:go_mock.bzl", "go_mock") + +go_mock( + name = "go_default_library", + importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/services/virtualnetworks/mock_virtualnetworks", + visibility = ["//visibility:public"], + mocks = [ + { + "prefix": "github.com/Azure/azure-sdk-for-go", + "package": "services/network/mgmt/2018-12-01/network/networkapi", + "interface": "VirtualNetworksClientAPI", + "vendored": True, + }, + ], + deps = [ + "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network:go_default_library", + ], +) +""" diff --git a/pkg/cloud/azure/services/virtualnetworks/virtualnetworks.go b/pkg/cloud/azure/services/virtualnetworks/virtualnetworks.go index 974aa8c95e6..0397268ddbe 100644 --- a/pkg/cloud/azure/services/virtualnetworks/virtualnetworks.go +++ b/pkg/cloud/azure/services/virtualnetworks/virtualnetworks.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/go-autorest/autorest/to" "github.com/pkg/errors" "k8s.io/klog" + "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1" "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure" ) @@ -33,7 +34,7 @@ type Spec struct { } // Get provides information about a virtual network. -func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) { +func (s *Service) Get(ctx context.Context, spec v1alpha1.ResourceSpec) (interface{}, error) { vnetSpec, ok := spec.(*Spec) if !ok { return network.VirtualNetwork{}, errors.New("Invalid VNET Specification") @@ -48,7 +49,7 @@ func (s *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error) } // Reconcile gets/creates/updates a virtual network. -func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { +func (s *Service) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) error { // Following should be created upstream and provided as an input to NewService // A vnet has following dependencies // * Vnet Cidr @@ -95,7 +96,7 @@ func (s *Service) Reconcile(ctx context.Context, spec azure.Spec) error { } // Delete deletes the virtual network with the provided name. -func (s *Service) Delete(ctx context.Context, spec azure.Spec) error { +func (s *Service) Delete(ctx context.Context, spec v1alpha1.ResourceSpec) error { vnetSpec, ok := spec.(*Spec) if !ok { return errors.New("Invalid VNET Specification") diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/computeapi/BUILD.bazel b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/computeapi/BUILD.bazel new file mode 100644 index 00000000000..ea4bbaf9763 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/computeapi/BUILD.bazel @@ -0,0 +1,13 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["interfaces.go"], + importmap = "sigs.k8s.io/cluster-api-provider-azure/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/computeapi", + importpath = "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/computeapi", + visibility = ["//visibility:public"], + deps = [ + "//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute:go_default_library", + "//vendor/github.com/Azure/go-autorest/autorest:go_default_library", + ], +) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/computeapi/interfaces.go b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/computeapi/interfaces.go new file mode 100644 index 00000000000..ce7aa2b5a12 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/computeapi/interfaces.go @@ -0,0 +1,286 @@ +package computeapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// 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 Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute" + "github.com/Azure/go-autorest/autorest" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result compute.OperationListResult, err error) +} + +var _ OperationsClientAPI = (*compute.OperationsClient)(nil) + +// AvailabilitySetsClientAPI contains the set of methods on the AvailabilitySetsClient type. +type AvailabilitySetsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, availabilitySetName string, parameters compute.AvailabilitySet) (result compute.AvailabilitySet, err error) + Delete(ctx context.Context, resourceGroupName string, availabilitySetName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, availabilitySetName string) (result compute.AvailabilitySet, err error) + List(ctx context.Context, resourceGroupName string) (result compute.AvailabilitySetListResultPage, err error) + ListAvailableSizes(ctx context.Context, resourceGroupName string, availabilitySetName string) (result compute.VirtualMachineSizeListResult, err error) + ListBySubscription(ctx context.Context) (result compute.AvailabilitySetListResultPage, err error) + Update(ctx context.Context, resourceGroupName string, availabilitySetName string, parameters compute.AvailabilitySetUpdate) (result compute.AvailabilitySet, err error) +} + +var _ AvailabilitySetsClientAPI = (*compute.AvailabilitySetsClient)(nil) + +// VirtualMachineExtensionImagesClientAPI contains the set of methods on the VirtualMachineExtensionImagesClient type. +type VirtualMachineExtensionImagesClientAPI interface { + Get(ctx context.Context, location string, publisherName string, typeParameter string, version string) (result compute.VirtualMachineExtensionImage, err error) + ListTypes(ctx context.Context, location string, publisherName string) (result compute.ListVirtualMachineExtensionImage, err error) + ListVersions(ctx context.Context, location string, publisherName string, typeParameter string, filter string, top *int32, orderby string) (result compute.ListVirtualMachineExtensionImage, err error) +} + +var _ VirtualMachineExtensionImagesClientAPI = (*compute.VirtualMachineExtensionImagesClient)(nil) + +// VirtualMachineExtensionsClientAPI contains the set of methods on the VirtualMachineExtensionsClient type. +type VirtualMachineExtensionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, VMName string, VMExtensionName string, extensionParameters compute.VirtualMachineExtension) (result compute.VirtualMachineExtensionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, VMName string, VMExtensionName string) (result compute.VirtualMachineExtensionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, VMName string, VMExtensionName string, expand string) (result compute.VirtualMachineExtension, err error) + List(ctx context.Context, resourceGroupName string, VMName string, expand string) (result compute.VirtualMachineExtensionsListResult, err error) + Update(ctx context.Context, resourceGroupName string, VMName string, VMExtensionName string, extensionParameters compute.VirtualMachineExtensionUpdate) (result compute.VirtualMachineExtensionsUpdateFuture, err error) +} + +var _ VirtualMachineExtensionsClientAPI = (*compute.VirtualMachineExtensionsClient)(nil) + +// VirtualMachineImagesClientAPI contains the set of methods on the VirtualMachineImagesClient type. +type VirtualMachineImagesClientAPI interface { + Get(ctx context.Context, location string, publisherName string, offer string, skus string, version string) (result compute.VirtualMachineImage, err error) + List(ctx context.Context, location string, publisherName string, offer string, skus string, filter string, top *int32, orderby string) (result compute.ListVirtualMachineImageResource, err error) + ListOffers(ctx context.Context, location string, publisherName string) (result compute.ListVirtualMachineImageResource, err error) + ListPublishers(ctx context.Context, location string) (result compute.ListVirtualMachineImageResource, err error) + ListSkus(ctx context.Context, location string, publisherName string, offer string) (result compute.ListVirtualMachineImageResource, err error) +} + +var _ VirtualMachineImagesClientAPI = (*compute.VirtualMachineImagesClient)(nil) + +// UsageClientAPI contains the set of methods on the UsageClient type. +type UsageClientAPI interface { + List(ctx context.Context, location string) (result compute.ListUsagesResultPage, err error) +} + +var _ UsageClientAPI = (*compute.UsageClient)(nil) + +// VirtualMachinesClientAPI contains the set of methods on the VirtualMachinesClient type. +type VirtualMachinesClientAPI interface { + Capture(ctx context.Context, resourceGroupName string, VMName string, parameters compute.VirtualMachineCaptureParameters) (result compute.VirtualMachinesCaptureFuture, err error) + ConvertToManagedDisks(ctx context.Context, resourceGroupName string, VMName string) (result compute.VirtualMachinesConvertToManagedDisksFuture, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, VMName string, parameters compute.VirtualMachine) (result compute.VirtualMachinesCreateOrUpdateFuture, err error) + Deallocate(ctx context.Context, resourceGroupName string, VMName string) (result compute.VirtualMachinesDeallocateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, VMName string) (result compute.VirtualMachinesDeleteFuture, err error) + Generalize(ctx context.Context, resourceGroupName string, VMName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, VMName string, expand compute.InstanceViewTypes) (result compute.VirtualMachine, err error) + InstanceView(ctx context.Context, resourceGroupName string, VMName string) (result compute.VirtualMachineInstanceView, err error) + List(ctx context.Context, resourceGroupName string) (result compute.VirtualMachineListResultPage, err error) + ListAll(ctx context.Context) (result compute.VirtualMachineListResultPage, err error) + ListAvailableSizes(ctx context.Context, resourceGroupName string, VMName string) (result compute.VirtualMachineSizeListResult, err error) + ListByLocation(ctx context.Context, location string) (result compute.VirtualMachineListResultPage, err error) + PerformMaintenance(ctx context.Context, resourceGroupName string, VMName string) (result compute.VirtualMachinesPerformMaintenanceFuture, err error) + PowerOff(ctx context.Context, resourceGroupName string, VMName string, skipShutdown *bool) (result compute.VirtualMachinesPowerOffFuture, err error) + Redeploy(ctx context.Context, resourceGroupName string, VMName string) (result compute.VirtualMachinesRedeployFuture, err error) + Reimage(ctx context.Context, resourceGroupName string, VMName string, parameters *compute.VirtualMachineReimageParameters) (result compute.VirtualMachinesReimageFuture, err error) + Restart(ctx context.Context, resourceGroupName string, VMName string) (result compute.VirtualMachinesRestartFuture, err error) + RunCommand(ctx context.Context, resourceGroupName string, VMName string, parameters compute.RunCommandInput) (result compute.VirtualMachinesRunCommandFuture, err error) + Start(ctx context.Context, resourceGroupName string, VMName string) (result compute.VirtualMachinesStartFuture, err error) + Update(ctx context.Context, resourceGroupName string, VMName string, parameters compute.VirtualMachineUpdate) (result compute.VirtualMachinesUpdateFuture, err error) +} + +var _ VirtualMachinesClientAPI = (*compute.VirtualMachinesClient)(nil) + +// VirtualMachineSizesClientAPI contains the set of methods on the VirtualMachineSizesClient type. +type VirtualMachineSizesClientAPI interface { + List(ctx context.Context, location string) (result compute.VirtualMachineSizeListResult, err error) +} + +var _ VirtualMachineSizesClientAPI = (*compute.VirtualMachineSizesClient)(nil) + +// ImagesClientAPI contains the set of methods on the ImagesClient type. +type ImagesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, imageName string, parameters compute.Image) (result compute.ImagesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, imageName string) (result compute.ImagesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, imageName string, expand string) (result compute.Image, err error) + List(ctx context.Context) (result compute.ImageListResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result compute.ImageListResultPage, err error) + Update(ctx context.Context, resourceGroupName string, imageName string, parameters compute.ImageUpdate) (result compute.ImagesUpdateFuture, err error) +} + +var _ ImagesClientAPI = (*compute.ImagesClient)(nil) + +// VirtualMachineScaleSetsClientAPI contains the set of methods on the VirtualMachineScaleSetsClient type. +type VirtualMachineScaleSetsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, VMScaleSetName string, parameters compute.VirtualMachineScaleSet) (result compute.VirtualMachineScaleSetsCreateOrUpdateFuture, err error) + Deallocate(ctx context.Context, resourceGroupName string, VMScaleSetName string, VMInstanceIDs *compute.VirtualMachineScaleSetVMInstanceIDs) (result compute.VirtualMachineScaleSetsDeallocateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result compute.VirtualMachineScaleSetsDeleteFuture, err error) + DeleteInstances(ctx context.Context, resourceGroupName string, VMScaleSetName string, VMInstanceIDs compute.VirtualMachineScaleSetVMInstanceRequiredIDs) (result compute.VirtualMachineScaleSetsDeleteInstancesFuture, err error) + ForceRecoveryServiceFabricPlatformUpdateDomainWalk(ctx context.Context, resourceGroupName string, VMScaleSetName string, platformUpdateDomain int32) (result compute.RecoveryWalkResponse, err error) + Get(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result compute.VirtualMachineScaleSet, err error) + GetInstanceView(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result compute.VirtualMachineScaleSetInstanceView, err error) + GetOSUpgradeHistory(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result compute.VirtualMachineScaleSetListOSUpgradeHistoryPage, err error) + List(ctx context.Context, resourceGroupName string) (result compute.VirtualMachineScaleSetListResultPage, err error) + ListAll(ctx context.Context) (result compute.VirtualMachineScaleSetListWithLinkResultPage, err error) + ListSkus(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result compute.VirtualMachineScaleSetListSkusResultPage, err error) + PerformMaintenance(ctx context.Context, resourceGroupName string, VMScaleSetName string, VMInstanceIDs *compute.VirtualMachineScaleSetVMInstanceIDs) (result compute.VirtualMachineScaleSetsPerformMaintenanceFuture, err error) + PowerOff(ctx context.Context, resourceGroupName string, VMScaleSetName string, VMInstanceIDs *compute.VirtualMachineScaleSetVMInstanceIDs, skipShutdown *bool) (result compute.VirtualMachineScaleSetsPowerOffFuture, err error) + Redeploy(ctx context.Context, resourceGroupName string, VMScaleSetName string, VMInstanceIDs *compute.VirtualMachineScaleSetVMInstanceIDs) (result compute.VirtualMachineScaleSetsRedeployFuture, err error) + Reimage(ctx context.Context, resourceGroupName string, VMScaleSetName string, VMScaleSetReimageInput *compute.VirtualMachineScaleSetReimageParameters) (result compute.VirtualMachineScaleSetsReimageFuture, err error) + ReimageAll(ctx context.Context, resourceGroupName string, VMScaleSetName string, VMInstanceIDs *compute.VirtualMachineScaleSetVMInstanceIDs) (result compute.VirtualMachineScaleSetsReimageAllFuture, err error) + Restart(ctx context.Context, resourceGroupName string, VMScaleSetName string, VMInstanceIDs *compute.VirtualMachineScaleSetVMInstanceIDs) (result compute.VirtualMachineScaleSetsRestartFuture, err error) + Start(ctx context.Context, resourceGroupName string, VMScaleSetName string, VMInstanceIDs *compute.VirtualMachineScaleSetVMInstanceIDs) (result compute.VirtualMachineScaleSetsStartFuture, err error) + Update(ctx context.Context, resourceGroupName string, VMScaleSetName string, parameters compute.VirtualMachineScaleSetUpdate) (result compute.VirtualMachineScaleSetsUpdateFuture, err error) + UpdateInstances(ctx context.Context, resourceGroupName string, VMScaleSetName string, VMInstanceIDs compute.VirtualMachineScaleSetVMInstanceRequiredIDs) (result compute.VirtualMachineScaleSetsUpdateInstancesFuture, err error) +} + +var _ VirtualMachineScaleSetsClientAPI = (*compute.VirtualMachineScaleSetsClient)(nil) + +// VirtualMachineScaleSetExtensionsClientAPI contains the set of methods on the VirtualMachineScaleSetExtensionsClient type. +type VirtualMachineScaleSetExtensionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, VMScaleSetName string, vmssExtensionName string, extensionParameters compute.VirtualMachineScaleSetExtension) (result compute.VirtualMachineScaleSetExtensionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, VMScaleSetName string, vmssExtensionName string) (result compute.VirtualMachineScaleSetExtensionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, VMScaleSetName string, vmssExtensionName string, expand string) (result compute.VirtualMachineScaleSetExtension, err error) + List(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result compute.VirtualMachineScaleSetExtensionListResultPage, err error) +} + +var _ VirtualMachineScaleSetExtensionsClientAPI = (*compute.VirtualMachineScaleSetExtensionsClient)(nil) + +// VirtualMachineScaleSetRollingUpgradesClientAPI contains the set of methods on the VirtualMachineScaleSetRollingUpgradesClient type. +type VirtualMachineScaleSetRollingUpgradesClientAPI interface { + Cancel(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result compute.VirtualMachineScaleSetRollingUpgradesCancelFuture, err error) + GetLatest(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result compute.RollingUpgradeStatusInfo, err error) + StartExtensionUpgrade(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result compute.VirtualMachineScaleSetRollingUpgradesStartExtensionUpgradeFuture, err error) + StartOSUpgrade(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result compute.VirtualMachineScaleSetRollingUpgradesStartOSUpgradeFuture, err error) +} + +var _ VirtualMachineScaleSetRollingUpgradesClientAPI = (*compute.VirtualMachineScaleSetRollingUpgradesClient)(nil) + +// VirtualMachineScaleSetVMsClientAPI contains the set of methods on the VirtualMachineScaleSetVMsClient type. +type VirtualMachineScaleSetVMsClientAPI interface { + Deallocate(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result compute.VirtualMachineScaleSetVMsDeallocateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result compute.VirtualMachineScaleSetVMsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result compute.VirtualMachineScaleSetVM, err error) + GetInstanceView(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result compute.VirtualMachineScaleSetVMInstanceView, err error) + List(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, filter string, selectParameter string, expand string) (result compute.VirtualMachineScaleSetVMListResultPage, err error) + PerformMaintenance(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result compute.VirtualMachineScaleSetVMsPerformMaintenanceFuture, err error) + PowerOff(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, skipShutdown *bool) (result compute.VirtualMachineScaleSetVMsPowerOffFuture, err error) + Redeploy(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result compute.VirtualMachineScaleSetVMsRedeployFuture, err error) + Reimage(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, VMScaleSetVMReimageInput *compute.VirtualMachineScaleSetVMReimageParameters) (result compute.VirtualMachineScaleSetVMsReimageFuture, err error) + ReimageAll(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result compute.VirtualMachineScaleSetVMsReimageAllFuture, err error) + Restart(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result compute.VirtualMachineScaleSetVMsRestartFuture, err error) + RunCommand(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, parameters compute.RunCommandInput) (result compute.VirtualMachineScaleSetVMsRunCommandFuture, err error) + Start(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result compute.VirtualMachineScaleSetVMsStartFuture, err error) + Update(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string, parameters compute.VirtualMachineScaleSetVM) (result compute.VirtualMachineScaleSetVMsUpdateFuture, err error) +} + +var _ VirtualMachineScaleSetVMsClientAPI = (*compute.VirtualMachineScaleSetVMsClient)(nil) + +// LogAnalyticsClientAPI contains the set of methods on the LogAnalyticsClient type. +type LogAnalyticsClientAPI interface { + ExportRequestRateByInterval(ctx context.Context, parameters compute.RequestRateByIntervalInput, location string) (result compute.LogAnalyticsExportRequestRateByIntervalFuture, err error) + ExportThrottledRequests(ctx context.Context, parameters compute.ThrottledRequestsInput, location string) (result compute.LogAnalyticsExportThrottledRequestsFuture, err error) +} + +var _ LogAnalyticsClientAPI = (*compute.LogAnalyticsClient)(nil) + +// VirtualMachineRunCommandsClientAPI contains the set of methods on the VirtualMachineRunCommandsClient type. +type VirtualMachineRunCommandsClientAPI interface { + Get(ctx context.Context, location string, commandID string) (result compute.RunCommandDocument, err error) + List(ctx context.Context, location string) (result compute.RunCommandListResultPage, err error) +} + +var _ VirtualMachineRunCommandsClientAPI = (*compute.VirtualMachineRunCommandsClient)(nil) + +// ResourceSkusClientAPI contains the set of methods on the ResourceSkusClient type. +type ResourceSkusClientAPI interface { + List(ctx context.Context) (result compute.ResourceSkusResultPage, err error) +} + +var _ ResourceSkusClientAPI = (*compute.ResourceSkusClient)(nil) + +// DisksClientAPI contains the set of methods on the DisksClient type. +type DisksClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, diskName string, disk compute.Disk) (result compute.DisksCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, diskName string) (result compute.DisksDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, diskName string) (result compute.Disk, err error) + GrantAccess(ctx context.Context, resourceGroupName string, diskName string, grantAccessData compute.GrantAccessData) (result compute.DisksGrantAccessFuture, err error) + List(ctx context.Context) (result compute.DiskListPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result compute.DiskListPage, err error) + RevokeAccess(ctx context.Context, resourceGroupName string, diskName string) (result compute.DisksRevokeAccessFuture, err error) + Update(ctx context.Context, resourceGroupName string, diskName string, disk compute.DiskUpdate) (result compute.DisksUpdateFuture, err error) +} + +var _ DisksClientAPI = (*compute.DisksClient)(nil) + +// SnapshotsClientAPI contains the set of methods on the SnapshotsClient type. +type SnapshotsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, snapshotName string, snapshot compute.Snapshot) (result compute.SnapshotsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, snapshotName string) (result compute.SnapshotsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, snapshotName string) (result compute.Snapshot, err error) + GrantAccess(ctx context.Context, resourceGroupName string, snapshotName string, grantAccessData compute.GrantAccessData) (result compute.SnapshotsGrantAccessFuture, err error) + List(ctx context.Context) (result compute.SnapshotListPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result compute.SnapshotListPage, err error) + RevokeAccess(ctx context.Context, resourceGroupName string, snapshotName string) (result compute.SnapshotsRevokeAccessFuture, err error) + Update(ctx context.Context, resourceGroupName string, snapshotName string, snapshot compute.SnapshotUpdate) (result compute.SnapshotsUpdateFuture, err error) +} + +var _ SnapshotsClientAPI = (*compute.SnapshotsClient)(nil) + +// GalleriesClientAPI contains the set of methods on the GalleriesClient type. +type GalleriesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, galleryName string, gallery compute.Gallery) (result compute.GalleriesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, galleryName string) (result compute.GalleriesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, galleryName string) (result compute.Gallery, err error) + List(ctx context.Context) (result compute.GalleryListPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result compute.GalleryListPage, err error) +} + +var _ GalleriesClientAPI = (*compute.GalleriesClient)(nil) + +// GalleryImagesClientAPI contains the set of methods on the GalleryImagesClient type. +type GalleryImagesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImage compute.GalleryImage) (result compute.GalleryImagesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string) (result compute.GalleryImagesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string) (result compute.GalleryImage, err error) + ListByGallery(ctx context.Context, resourceGroupName string, galleryName string) (result compute.GalleryImageListPage, err error) +} + +var _ GalleryImagesClientAPI = (*compute.GalleryImagesClient)(nil) + +// GalleryImageVersionsClientAPI contains the set of methods on the GalleryImageVersionsClient type. +type GalleryImageVersionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImageVersionName string, galleryImageVersion compute.GalleryImageVersion) (result compute.GalleryImageVersionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImageVersionName string) (result compute.GalleryImageVersionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImageVersionName string, expand compute.ReplicationStatusTypes) (result compute.GalleryImageVersion, err error) + ListByGalleryImage(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string) (result compute.GalleryImageVersionListPage, err error) +} + +var _ GalleryImageVersionsClientAPI = (*compute.GalleryImageVersionsClient)(nil) + +// ContainerServicesClientAPI contains the set of methods on the ContainerServicesClient type. +type ContainerServicesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, containerServiceName string, parameters compute.ContainerService) (result compute.ContainerServicesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, containerServiceName string) (result compute.ContainerServicesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, containerServiceName string) (result compute.ContainerService, err error) + List(ctx context.Context) (result compute.ContainerServiceListResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result compute.ContainerServiceListResultPage, err error) +} + +var _ ContainerServicesClientAPI = (*compute.ContainerServicesClient)(nil) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network/networkapi/BUILD.bazel b/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network/networkapi/BUILD.bazel new file mode 100644 index 00000000000..3f75c370cd3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network/networkapi/BUILD.bazel @@ -0,0 +1,13 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["interfaces.go"], + importmap = "sigs.k8s.io/cluster-api-provider-azure/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network/networkapi", + importpath = "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network/networkapi", + visibility = ["//visibility:public"], + deps = [ + "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network:go_default_library", + "//vendor/github.com/Azure/go-autorest/autorest:go_default_library", + ], +) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network/networkapi/interfaces.go b/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network/networkapi/interfaces.go new file mode 100644 index 00000000000..9f37df5450d --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network/networkapi/interfaces.go @@ -0,0 +1,794 @@ +package networkapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// 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 Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network" + "github.com/Azure/go-autorest/autorest" +) + +// BaseClientAPI contains the set of methods on the BaseClient type. +type BaseClientAPI interface { + CheckDNSNameAvailability(ctx context.Context, location string, domainNameLabel string) (result network.DNSNameAvailabilityResult, err error) + SupportedSecurityProviders(ctx context.Context, resourceGroupName string, virtualWANName string) (result network.VirtualWanSecurityProviders, err error) +} + +var _ BaseClientAPI = (*network.BaseClient)(nil) + +// ApplicationGatewaysClientAPI contains the set of methods on the ApplicationGatewaysClient type. +type ApplicationGatewaysClientAPI interface { + BackendHealth(ctx context.Context, resourceGroupName string, applicationGatewayName string, expand string) (result network.ApplicationGatewaysBackendHealthFuture, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, applicationGatewayName string, parameters network.ApplicationGateway) (result network.ApplicationGatewaysCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result network.ApplicationGatewaysDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result network.ApplicationGateway, err error) + GetSslPredefinedPolicy(ctx context.Context, predefinedPolicyName string) (result network.ApplicationGatewaySslPredefinedPolicy, err error) + List(ctx context.Context, resourceGroupName string) (result network.ApplicationGatewayListResultPage, err error) + ListAll(ctx context.Context) (result network.ApplicationGatewayListResultPage, err error) + ListAvailableRequestHeaders(ctx context.Context) (result network.ListString, err error) + ListAvailableResponseHeaders(ctx context.Context) (result network.ListString, err error) + ListAvailableServerVariables(ctx context.Context) (result network.ListString, err error) + ListAvailableSslOptions(ctx context.Context) (result network.ApplicationGatewayAvailableSslOptions, err error) + ListAvailableSslPredefinedPolicies(ctx context.Context) (result network.ApplicationGatewayAvailableSslPredefinedPoliciesPage, err error) + ListAvailableWafRuleSets(ctx context.Context) (result network.ApplicationGatewayAvailableWafRuleSetsResult, err error) + Start(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result network.ApplicationGatewaysStartFuture, err error) + Stop(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result network.ApplicationGatewaysStopFuture, err error) + UpdateTags(ctx context.Context, resourceGroupName string, applicationGatewayName string, parameters network.TagsObject) (result network.ApplicationGatewaysUpdateTagsFuture, err error) +} + +var _ ApplicationGatewaysClientAPI = (*network.ApplicationGatewaysClient)(nil) + +// ApplicationSecurityGroupsClientAPI contains the set of methods on the ApplicationSecurityGroupsClient type. +type ApplicationSecurityGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, applicationSecurityGroupName string, parameters network.ApplicationSecurityGroup) (result network.ApplicationSecurityGroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, applicationSecurityGroupName string) (result network.ApplicationSecurityGroupsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, applicationSecurityGroupName string) (result network.ApplicationSecurityGroup, err error) + List(ctx context.Context, resourceGroupName string) (result network.ApplicationSecurityGroupListResultPage, err error) + ListAll(ctx context.Context) (result network.ApplicationSecurityGroupListResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, applicationSecurityGroupName string, parameters network.TagsObject) (result network.ApplicationSecurityGroupsUpdateTagsFuture, err error) +} + +var _ ApplicationSecurityGroupsClientAPI = (*network.ApplicationSecurityGroupsClient)(nil) + +// AvailableDelegationsClientAPI contains the set of methods on the AvailableDelegationsClient type. +type AvailableDelegationsClientAPI interface { + List(ctx context.Context, location string) (result network.AvailableDelegationsResultPage, err error) +} + +var _ AvailableDelegationsClientAPI = (*network.AvailableDelegationsClient)(nil) + +// AvailableResourceGroupDelegationsClientAPI contains the set of methods on the AvailableResourceGroupDelegationsClient type. +type AvailableResourceGroupDelegationsClientAPI interface { + List(ctx context.Context, location string, resourceGroupName string) (result network.AvailableDelegationsResultPage, err error) +} + +var _ AvailableResourceGroupDelegationsClientAPI = (*network.AvailableResourceGroupDelegationsClient)(nil) + +// AzureFirewallsClientAPI contains the set of methods on the AzureFirewallsClient type. +type AzureFirewallsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, azureFirewallName string, parameters network.AzureFirewall) (result network.AzureFirewallsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, azureFirewallName string) (result network.AzureFirewallsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, azureFirewallName string) (result network.AzureFirewall, err error) + List(ctx context.Context, resourceGroupName string) (result network.AzureFirewallListResultPage, err error) + ListAll(ctx context.Context) (result network.AzureFirewallListResultPage, err error) +} + +var _ AzureFirewallsClientAPI = (*network.AzureFirewallsClient)(nil) + +// AzureFirewallFqdnTagsClientAPI contains the set of methods on the AzureFirewallFqdnTagsClient type. +type AzureFirewallFqdnTagsClientAPI interface { + ListAll(ctx context.Context) (result network.AzureFirewallFqdnTagListResultPage, err error) +} + +var _ AzureFirewallFqdnTagsClientAPI = (*network.AzureFirewallFqdnTagsClient)(nil) + +// DdosCustomPoliciesClientAPI contains the set of methods on the DdosCustomPoliciesClient type. +type DdosCustomPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, ddosCustomPolicyName string, parameters network.DdosCustomPolicy) (result network.DdosCustomPoliciesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, ddosCustomPolicyName string) (result network.DdosCustomPoliciesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, ddosCustomPolicyName string) (result network.DdosCustomPolicy, err error) + UpdateTags(ctx context.Context, resourceGroupName string, ddosCustomPolicyName string, parameters network.TagsObject) (result network.DdosCustomPoliciesUpdateTagsFuture, err error) +} + +var _ DdosCustomPoliciesClientAPI = (*network.DdosCustomPoliciesClient)(nil) + +// DdosProtectionPlansClientAPI contains the set of methods on the DdosProtectionPlansClient type. +type DdosProtectionPlansClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, parameters network.DdosProtectionPlan) (result network.DdosProtectionPlansCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string) (result network.DdosProtectionPlansDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string) (result network.DdosProtectionPlan, err error) + List(ctx context.Context) (result network.DdosProtectionPlanListResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result network.DdosProtectionPlanListResultPage, err error) +} + +var _ DdosProtectionPlansClientAPI = (*network.DdosProtectionPlansClient)(nil) + +// AvailableEndpointServicesClientAPI contains the set of methods on the AvailableEndpointServicesClient type. +type AvailableEndpointServicesClientAPI interface { + List(ctx context.Context, location string) (result network.EndpointServicesListResultPage, err error) +} + +var _ AvailableEndpointServicesClientAPI = (*network.AvailableEndpointServicesClient)(nil) + +// ExpressRouteCircuitAuthorizationsClientAPI contains the set of methods on the ExpressRouteCircuitAuthorizationsClient type. +type ExpressRouteCircuitAuthorizationsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, circuitName string, authorizationName string, authorizationParameters network.ExpressRouteCircuitAuthorization) (result network.ExpressRouteCircuitAuthorizationsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, circuitName string, authorizationName string) (result network.ExpressRouteCircuitAuthorizationsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, circuitName string, authorizationName string) (result network.ExpressRouteCircuitAuthorization, err error) + List(ctx context.Context, resourceGroupName string, circuitName string) (result network.AuthorizationListResultPage, err error) +} + +var _ ExpressRouteCircuitAuthorizationsClientAPI = (*network.ExpressRouteCircuitAuthorizationsClient)(nil) + +// ExpressRouteCircuitPeeringsClientAPI contains the set of methods on the ExpressRouteCircuitPeeringsClient type. +type ExpressRouteCircuitPeeringsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, peeringParameters network.ExpressRouteCircuitPeering) (result network.ExpressRouteCircuitPeeringsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, circuitName string, peeringName string) (result network.ExpressRouteCircuitPeeringsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, circuitName string, peeringName string) (result network.ExpressRouteCircuitPeering, err error) + List(ctx context.Context, resourceGroupName string, circuitName string) (result network.ExpressRouteCircuitPeeringListResultPage, err error) +} + +var _ ExpressRouteCircuitPeeringsClientAPI = (*network.ExpressRouteCircuitPeeringsClient)(nil) + +// ExpressRouteCircuitConnectionsClientAPI contains the set of methods on the ExpressRouteCircuitConnectionsClient type. +type ExpressRouteCircuitConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, connectionName string, expressRouteCircuitConnectionParameters network.ExpressRouteCircuitConnection) (result network.ExpressRouteCircuitConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, connectionName string) (result network.ExpressRouteCircuitConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, connectionName string) (result network.ExpressRouteCircuitConnection, err error) + List(ctx context.Context, resourceGroupName string, circuitName string, peeringName string) (result network.ExpressRouteCircuitConnectionListResultPage, err error) +} + +var _ ExpressRouteCircuitConnectionsClientAPI = (*network.ExpressRouteCircuitConnectionsClient)(nil) + +// PeerExpressRouteCircuitConnectionsClientAPI contains the set of methods on the PeerExpressRouteCircuitConnectionsClient type. +type PeerExpressRouteCircuitConnectionsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, connectionName string) (result network.PeerExpressRouteCircuitConnection, err error) + List(ctx context.Context, resourceGroupName string, circuitName string, peeringName string) (result network.PeerExpressRouteCircuitConnectionListResultPage, err error) +} + +var _ PeerExpressRouteCircuitConnectionsClientAPI = (*network.PeerExpressRouteCircuitConnectionsClient)(nil) + +// ExpressRouteCircuitsClientAPI contains the set of methods on the ExpressRouteCircuitsClient type. +type ExpressRouteCircuitsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, circuitName string, parameters network.ExpressRouteCircuit) (result network.ExpressRouteCircuitsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, circuitName string) (result network.ExpressRouteCircuitsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, circuitName string) (result network.ExpressRouteCircuit, err error) + GetPeeringStats(ctx context.Context, resourceGroupName string, circuitName string, peeringName string) (result network.ExpressRouteCircuitStats, err error) + GetStats(ctx context.Context, resourceGroupName string, circuitName string) (result network.ExpressRouteCircuitStats, err error) + List(ctx context.Context, resourceGroupName string) (result network.ExpressRouteCircuitListResultPage, err error) + ListAll(ctx context.Context) (result network.ExpressRouteCircuitListResultPage, err error) + ListArpTable(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, devicePath string) (result network.ExpressRouteCircuitsListArpTableFuture, err error) + ListRoutesTable(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, devicePath string) (result network.ExpressRouteCircuitsListRoutesTableFuture, err error) + ListRoutesTableSummary(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, devicePath string) (result network.ExpressRouteCircuitsListRoutesTableSummaryFuture, err error) + UpdateTags(ctx context.Context, resourceGroupName string, circuitName string, parameters network.TagsObject) (result network.ExpressRouteCircuitsUpdateTagsFuture, err error) +} + +var _ ExpressRouteCircuitsClientAPI = (*network.ExpressRouteCircuitsClient)(nil) + +// ExpressRouteServiceProvidersClientAPI contains the set of methods on the ExpressRouteServiceProvidersClient type. +type ExpressRouteServiceProvidersClientAPI interface { + List(ctx context.Context) (result network.ExpressRouteServiceProviderListResultPage, err error) +} + +var _ ExpressRouteServiceProvidersClientAPI = (*network.ExpressRouteServiceProvidersClient)(nil) + +// ExpressRouteCrossConnectionsClientAPI contains the set of methods on the ExpressRouteCrossConnectionsClient type. +type ExpressRouteCrossConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, crossConnectionName string, parameters network.ExpressRouteCrossConnection) (result network.ExpressRouteCrossConnectionsCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, crossConnectionName string) (result network.ExpressRouteCrossConnection, err error) + List(ctx context.Context) (result network.ExpressRouteCrossConnectionListResultPage, err error) + ListArpTable(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string, devicePath string) (result network.ExpressRouteCrossConnectionsListArpTableFuture, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result network.ExpressRouteCrossConnectionListResultPage, err error) + ListRoutesTable(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string, devicePath string) (result network.ExpressRouteCrossConnectionsListRoutesTableFuture, err error) + ListRoutesTableSummary(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string, devicePath string) (result network.ExpressRouteCrossConnectionsListRoutesTableSummaryFuture, err error) + UpdateTags(ctx context.Context, resourceGroupName string, crossConnectionName string, crossConnectionParameters network.TagsObject) (result network.ExpressRouteCrossConnectionsUpdateTagsFuture, err error) +} + +var _ ExpressRouteCrossConnectionsClientAPI = (*network.ExpressRouteCrossConnectionsClient)(nil) + +// ExpressRouteCrossConnectionPeeringsClientAPI contains the set of methods on the ExpressRouteCrossConnectionPeeringsClient type. +type ExpressRouteCrossConnectionPeeringsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string, peeringParameters network.ExpressRouteCrossConnectionPeering) (result network.ExpressRouteCrossConnectionPeeringsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string) (result network.ExpressRouteCrossConnectionPeeringsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string) (result network.ExpressRouteCrossConnectionPeering, err error) + List(ctx context.Context, resourceGroupName string, crossConnectionName string) (result network.ExpressRouteCrossConnectionPeeringListPage, err error) +} + +var _ ExpressRouteCrossConnectionPeeringsClientAPI = (*network.ExpressRouteCrossConnectionPeeringsClient)(nil) + +// ExpressRouteGatewaysClientAPI contains the set of methods on the ExpressRouteGatewaysClient type. +type ExpressRouteGatewaysClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, putExpressRouteGatewayParameters network.ExpressRouteGateway) (result network.ExpressRouteGatewaysCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, expressRouteGatewayName string) (result network.ExpressRouteGatewaysDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, expressRouteGatewayName string) (result network.ExpressRouteGateway, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result network.ExpressRouteGatewayList, err error) + ListBySubscription(ctx context.Context) (result network.ExpressRouteGatewayList, err error) +} + +var _ ExpressRouteGatewaysClientAPI = (*network.ExpressRouteGatewaysClient)(nil) + +// ExpressRouteConnectionsClientAPI contains the set of methods on the ExpressRouteConnectionsClient type. +type ExpressRouteConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, connectionName string, putExpressRouteConnectionParameters network.ExpressRouteConnection) (result network.ExpressRouteConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, connectionName string) (result network.ExpressRouteConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, expressRouteGatewayName string, connectionName string) (result network.ExpressRouteConnection, err error) + List(ctx context.Context, resourceGroupName string, expressRouteGatewayName string) (result network.ExpressRouteConnectionList, err error) +} + +var _ ExpressRouteConnectionsClientAPI = (*network.ExpressRouteConnectionsClient)(nil) + +// ExpressRoutePortsLocationsClientAPI contains the set of methods on the ExpressRoutePortsLocationsClient type. +type ExpressRoutePortsLocationsClientAPI interface { + Get(ctx context.Context, locationName string) (result network.ExpressRoutePortsLocation, err error) + List(ctx context.Context) (result network.ExpressRoutePortsLocationListResultPage, err error) +} + +var _ ExpressRoutePortsLocationsClientAPI = (*network.ExpressRoutePortsLocationsClient)(nil) + +// ExpressRoutePortsClientAPI contains the set of methods on the ExpressRoutePortsClient type. +type ExpressRoutePortsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, expressRoutePortName string, parameters network.ExpressRoutePort) (result network.ExpressRoutePortsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, expressRoutePortName string) (result network.ExpressRoutePortsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, expressRoutePortName string) (result network.ExpressRoutePort, err error) + List(ctx context.Context) (result network.ExpressRoutePortListResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result network.ExpressRoutePortListResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, expressRoutePortName string, parameters network.TagsObject) (result network.ExpressRoutePortsUpdateTagsFuture, err error) +} + +var _ ExpressRoutePortsClientAPI = (*network.ExpressRoutePortsClient)(nil) + +// ExpressRouteLinksClientAPI contains the set of methods on the ExpressRouteLinksClient type. +type ExpressRouteLinksClientAPI interface { + Get(ctx context.Context, resourceGroupName string, expressRoutePortName string, linkName string) (result network.ExpressRouteLink, err error) + List(ctx context.Context, resourceGroupName string, expressRoutePortName string) (result network.ExpressRouteLinkListResultPage, err error) +} + +var _ ExpressRouteLinksClientAPI = (*network.ExpressRouteLinksClient)(nil) + +// InterfaceEndpointsClientAPI contains the set of methods on the InterfaceEndpointsClient type. +type InterfaceEndpointsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, interfaceEndpointName string, parameters network.InterfaceEndpoint) (result network.InterfaceEndpointsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, interfaceEndpointName string) (result network.InterfaceEndpointsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, interfaceEndpointName string, expand string) (result network.InterfaceEndpoint, err error) + List(ctx context.Context, resourceGroupName string) (result network.InterfaceEndpointListResultPage, err error) + ListBySubscription(ctx context.Context) (result network.InterfaceEndpointListResultPage, err error) +} + +var _ InterfaceEndpointsClientAPI = (*network.InterfaceEndpointsClient)(nil) + +// LoadBalancersClientAPI contains the set of methods on the LoadBalancersClient type. +type LoadBalancersClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, loadBalancerName string, parameters network.LoadBalancer) (result network.LoadBalancersCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, loadBalancerName string) (result network.LoadBalancersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, loadBalancerName string, expand string) (result network.LoadBalancer, err error) + List(ctx context.Context, resourceGroupName string) (result network.LoadBalancerListResultPage, err error) + ListAll(ctx context.Context) (result network.LoadBalancerListResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, loadBalancerName string, parameters network.TagsObject) (result network.LoadBalancersUpdateTagsFuture, err error) +} + +var _ LoadBalancersClientAPI = (*network.LoadBalancersClient)(nil) + +// LoadBalancerBackendAddressPoolsClientAPI contains the set of methods on the LoadBalancerBackendAddressPoolsClient type. +type LoadBalancerBackendAddressPoolsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, loadBalancerName string, backendAddressPoolName string) (result network.BackendAddressPool, err error) + List(ctx context.Context, resourceGroupName string, loadBalancerName string) (result network.LoadBalancerBackendAddressPoolListResultPage, err error) +} + +var _ LoadBalancerBackendAddressPoolsClientAPI = (*network.LoadBalancerBackendAddressPoolsClient)(nil) + +// LoadBalancerFrontendIPConfigurationsClientAPI contains the set of methods on the LoadBalancerFrontendIPConfigurationsClient type. +type LoadBalancerFrontendIPConfigurationsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, loadBalancerName string, frontendIPConfigurationName string) (result network.FrontendIPConfiguration, err error) + List(ctx context.Context, resourceGroupName string, loadBalancerName string) (result network.LoadBalancerFrontendIPConfigurationListResultPage, err error) +} + +var _ LoadBalancerFrontendIPConfigurationsClientAPI = (*network.LoadBalancerFrontendIPConfigurationsClient)(nil) + +// InboundNatRulesClientAPI contains the set of methods on the InboundNatRulesClient type. +type InboundNatRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, loadBalancerName string, inboundNatRuleName string, inboundNatRuleParameters network.InboundNatRule) (result network.InboundNatRulesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, loadBalancerName string, inboundNatRuleName string) (result network.InboundNatRulesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, loadBalancerName string, inboundNatRuleName string, expand string) (result network.InboundNatRule, err error) + List(ctx context.Context, resourceGroupName string, loadBalancerName string) (result network.InboundNatRuleListResultPage, err error) +} + +var _ InboundNatRulesClientAPI = (*network.InboundNatRulesClient)(nil) + +// LoadBalancerLoadBalancingRulesClientAPI contains the set of methods on the LoadBalancerLoadBalancingRulesClient type. +type LoadBalancerLoadBalancingRulesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, loadBalancerName string, loadBalancingRuleName string) (result network.LoadBalancingRule, err error) + List(ctx context.Context, resourceGroupName string, loadBalancerName string) (result network.LoadBalancerLoadBalancingRuleListResultPage, err error) +} + +var _ LoadBalancerLoadBalancingRulesClientAPI = (*network.LoadBalancerLoadBalancingRulesClient)(nil) + +// LoadBalancerOutboundRulesClientAPI contains the set of methods on the LoadBalancerOutboundRulesClient type. +type LoadBalancerOutboundRulesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, loadBalancerName string, outboundRuleName string) (result network.OutboundRule, err error) + List(ctx context.Context, resourceGroupName string, loadBalancerName string) (result network.LoadBalancerOutboundRuleListResultPage, err error) +} + +var _ LoadBalancerOutboundRulesClientAPI = (*network.LoadBalancerOutboundRulesClient)(nil) + +// LoadBalancerNetworkInterfacesClientAPI contains the set of methods on the LoadBalancerNetworkInterfacesClient type. +type LoadBalancerNetworkInterfacesClientAPI interface { + List(ctx context.Context, resourceGroupName string, loadBalancerName string) (result network.InterfaceListResultPage, err error) +} + +var _ LoadBalancerNetworkInterfacesClientAPI = (*network.LoadBalancerNetworkInterfacesClient)(nil) + +// LoadBalancerProbesClientAPI contains the set of methods on the LoadBalancerProbesClient type. +type LoadBalancerProbesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, loadBalancerName string, probeName string) (result network.Probe, err error) + List(ctx context.Context, resourceGroupName string, loadBalancerName string) (result network.LoadBalancerProbeListResultPage, err error) +} + +var _ LoadBalancerProbesClientAPI = (*network.LoadBalancerProbesClient)(nil) + +// InterfacesClientAPI contains the set of methods on the InterfacesClient type. +type InterfacesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, networkInterfaceName string, parameters network.Interface) (result network.InterfacesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, networkInterfaceName string) (result network.InterfacesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, networkInterfaceName string, expand string) (result network.Interface, err error) + GetEffectiveRouteTable(ctx context.Context, resourceGroupName string, networkInterfaceName string) (result network.InterfacesGetEffectiveRouteTableFuture, err error) + GetVirtualMachineScaleSetIPConfiguration(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, IPConfigurationName string, expand string) (result network.InterfaceIPConfiguration, err error) + GetVirtualMachineScaleSetNetworkInterface(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, expand string) (result network.Interface, err error) + List(ctx context.Context, resourceGroupName string) (result network.InterfaceListResultPage, err error) + ListAll(ctx context.Context) (result network.InterfaceListResultPage, err error) + ListEffectiveNetworkSecurityGroups(ctx context.Context, resourceGroupName string, networkInterfaceName string) (result network.InterfacesListEffectiveNetworkSecurityGroupsFuture, err error) + ListVirtualMachineScaleSetIPConfigurations(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, expand string) (result network.InterfaceIPConfigurationListResultPage, err error) + ListVirtualMachineScaleSetNetworkInterfaces(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string) (result network.InterfaceListResultPage, err error) + ListVirtualMachineScaleSetVMNetworkInterfaces(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string) (result network.InterfaceListResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, networkInterfaceName string, parameters network.TagsObject) (result network.InterfacesUpdateTagsFuture, err error) +} + +var _ InterfacesClientAPI = (*network.InterfacesClient)(nil) + +// InterfaceIPConfigurationsClientAPI contains the set of methods on the InterfaceIPConfigurationsClient type. +type InterfaceIPConfigurationsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, networkInterfaceName string, IPConfigurationName string) (result network.InterfaceIPConfiguration, err error) + List(ctx context.Context, resourceGroupName string, networkInterfaceName string) (result network.InterfaceIPConfigurationListResultPage, err error) +} + +var _ InterfaceIPConfigurationsClientAPI = (*network.InterfaceIPConfigurationsClient)(nil) + +// InterfaceLoadBalancersClientAPI contains the set of methods on the InterfaceLoadBalancersClient type. +type InterfaceLoadBalancersClientAPI interface { + List(ctx context.Context, resourceGroupName string, networkInterfaceName string) (result network.InterfaceLoadBalancerListResultPage, err error) +} + +var _ InterfaceLoadBalancersClientAPI = (*network.InterfaceLoadBalancersClient)(nil) + +// InterfaceTapConfigurationsClientAPI contains the set of methods on the InterfaceTapConfigurationsClient type. +type InterfaceTapConfigurationsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, networkInterfaceName string, tapConfigurationName string, tapConfigurationParameters network.InterfaceTapConfiguration) (result network.InterfaceTapConfigurationsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, networkInterfaceName string, tapConfigurationName string) (result network.InterfaceTapConfigurationsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, networkInterfaceName string, tapConfigurationName string) (result network.InterfaceTapConfiguration, err error) + List(ctx context.Context, resourceGroupName string, networkInterfaceName string) (result network.InterfaceTapConfigurationListResultPage, err error) +} + +var _ InterfaceTapConfigurationsClientAPI = (*network.InterfaceTapConfigurationsClient)(nil) + +// ProfilesClientAPI contains the set of methods on the ProfilesClient type. +type ProfilesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, networkProfileName string, parameters network.Profile) (result network.Profile, err error) + Delete(ctx context.Context, resourceGroupName string, networkProfileName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, networkProfileName string, expand string) (result network.Profile, err error) + List(ctx context.Context, resourceGroupName string) (result network.ProfileListResultPage, err error) + ListAll(ctx context.Context) (result network.ProfileListResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, networkProfileName string, parameters network.TagsObject) (result network.Profile, err error) +} + +var _ ProfilesClientAPI = (*network.ProfilesClient)(nil) + +// SecurityGroupsClientAPI contains the set of methods on the SecurityGroupsClient type. +type SecurityGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, networkSecurityGroupName string, parameters network.SecurityGroup) (result network.SecurityGroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, networkSecurityGroupName string) (result network.SecurityGroupsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, networkSecurityGroupName string, expand string) (result network.SecurityGroup, err error) + List(ctx context.Context, resourceGroupName string) (result network.SecurityGroupListResultPage, err error) + ListAll(ctx context.Context) (result network.SecurityGroupListResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, networkSecurityGroupName string, parameters network.TagsObject) (result network.SecurityGroupsUpdateTagsFuture, err error) +} + +var _ SecurityGroupsClientAPI = (*network.SecurityGroupsClient)(nil) + +// SecurityRulesClientAPI contains the set of methods on the SecurityRulesClient type. +type SecurityRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, networkSecurityGroupName string, securityRuleName string, securityRuleParameters network.SecurityRule) (result network.SecurityRulesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, networkSecurityGroupName string, securityRuleName string) (result network.SecurityRulesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, networkSecurityGroupName string, securityRuleName string) (result network.SecurityRule, err error) + List(ctx context.Context, resourceGroupName string, networkSecurityGroupName string) (result network.SecurityRuleListResultPage, err error) +} + +var _ SecurityRulesClientAPI = (*network.SecurityRulesClient)(nil) + +// DefaultSecurityRulesClientAPI contains the set of methods on the DefaultSecurityRulesClient type. +type DefaultSecurityRulesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, networkSecurityGroupName string, defaultSecurityRuleName string) (result network.SecurityRule, err error) + List(ctx context.Context, resourceGroupName string, networkSecurityGroupName string) (result network.SecurityRuleListResultPage, err error) +} + +var _ DefaultSecurityRulesClientAPI = (*network.DefaultSecurityRulesClient)(nil) + +// WatchersClientAPI contains the set of methods on the WatchersClient type. +type WatchersClientAPI interface { + CheckConnectivity(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters network.ConnectivityParameters) (result network.WatchersCheckConnectivityFuture, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters network.Watcher) (result network.Watcher, err error) + Delete(ctx context.Context, resourceGroupName string, networkWatcherName string) (result network.WatchersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, networkWatcherName string) (result network.Watcher, err error) + GetAzureReachabilityReport(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters network.AzureReachabilityReportParameters) (result network.WatchersGetAzureReachabilityReportFuture, err error) + GetFlowLogStatus(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters network.FlowLogStatusParameters) (result network.WatchersGetFlowLogStatusFuture, err error) + GetNetworkConfigurationDiagnostic(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters network.ConfigurationDiagnosticParameters) (result network.WatchersGetNetworkConfigurationDiagnosticFuture, err error) + GetNextHop(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters network.NextHopParameters) (result network.WatchersGetNextHopFuture, err error) + GetTopology(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters network.TopologyParameters) (result network.Topology, err error) + GetTroubleshooting(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters network.TroubleshootingParameters) (result network.WatchersGetTroubleshootingFuture, err error) + GetTroubleshootingResult(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters network.QueryTroubleshootingParameters) (result network.WatchersGetTroubleshootingResultFuture, err error) + GetVMSecurityRules(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters network.SecurityGroupViewParameters) (result network.WatchersGetVMSecurityRulesFuture, err error) + List(ctx context.Context, resourceGroupName string) (result network.WatcherListResult, err error) + ListAll(ctx context.Context) (result network.WatcherListResult, err error) + ListAvailableProviders(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters network.AvailableProvidersListParameters) (result network.WatchersListAvailableProvidersFuture, err error) + SetFlowLogConfiguration(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters network.FlowLogInformation) (result network.WatchersSetFlowLogConfigurationFuture, err error) + UpdateTags(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters network.TagsObject) (result network.Watcher, err error) + VerifyIPFlow(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters network.VerificationIPFlowParameters) (result network.WatchersVerifyIPFlowFuture, err error) +} + +var _ WatchersClientAPI = (*network.WatchersClient)(nil) + +// PacketCapturesClientAPI contains the set of methods on the PacketCapturesClient type. +type PacketCapturesClientAPI interface { + Create(ctx context.Context, resourceGroupName string, networkWatcherName string, packetCaptureName string, parameters network.PacketCapture) (result network.PacketCapturesCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, networkWatcherName string, packetCaptureName string) (result network.PacketCapturesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, networkWatcherName string, packetCaptureName string) (result network.PacketCaptureResult, err error) + GetStatus(ctx context.Context, resourceGroupName string, networkWatcherName string, packetCaptureName string) (result network.PacketCapturesGetStatusFuture, err error) + List(ctx context.Context, resourceGroupName string, networkWatcherName string) (result network.PacketCaptureListResult, err error) + Stop(ctx context.Context, resourceGroupName string, networkWatcherName string, packetCaptureName string) (result network.PacketCapturesStopFuture, err error) +} + +var _ PacketCapturesClientAPI = (*network.PacketCapturesClient)(nil) + +// ConnectionMonitorsClientAPI contains the set of methods on the ConnectionMonitorsClient type. +type ConnectionMonitorsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string, parameters network.ConnectionMonitor) (result network.ConnectionMonitorsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string) (result network.ConnectionMonitorsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string) (result network.ConnectionMonitorResult, err error) + List(ctx context.Context, resourceGroupName string, networkWatcherName string) (result network.ConnectionMonitorListResult, err error) + Query(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string) (result network.ConnectionMonitorsQueryFuture, err error) + Start(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string) (result network.ConnectionMonitorsStartFuture, err error) + Stop(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string) (result network.ConnectionMonitorsStopFuture, err error) +} + +var _ ConnectionMonitorsClientAPI = (*network.ConnectionMonitorsClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result network.OperationListResultPage, err error) +} + +var _ OperationsClientAPI = (*network.OperationsClient)(nil) + +// PublicIPAddressesClientAPI contains the set of methods on the PublicIPAddressesClient type. +type PublicIPAddressesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, publicIPAddressName string, parameters network.PublicIPAddress) (result network.PublicIPAddressesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, publicIPAddressName string) (result network.PublicIPAddressesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, publicIPAddressName string, expand string) (result network.PublicIPAddress, err error) + GetVirtualMachineScaleSetPublicIPAddress(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, IPConfigurationName string, publicIPAddressName string, expand string) (result network.PublicIPAddress, err error) + List(ctx context.Context, resourceGroupName string) (result network.PublicIPAddressListResultPage, err error) + ListAll(ctx context.Context) (result network.PublicIPAddressListResultPage, err error) + ListVirtualMachineScaleSetPublicIPAddresses(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string) (result network.PublicIPAddressListResultPage, err error) + ListVirtualMachineScaleSetVMPublicIPAddresses(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, IPConfigurationName string) (result network.PublicIPAddressListResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, publicIPAddressName string, parameters network.TagsObject) (result network.PublicIPAddressesUpdateTagsFuture, err error) +} + +var _ PublicIPAddressesClientAPI = (*network.PublicIPAddressesClient)(nil) + +// PublicIPPrefixesClientAPI contains the set of methods on the PublicIPPrefixesClient type. +type PublicIPPrefixesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, publicIPPrefixName string, parameters network.PublicIPPrefix) (result network.PublicIPPrefixesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, publicIPPrefixName string) (result network.PublicIPPrefixesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, publicIPPrefixName string, expand string) (result network.PublicIPPrefix, err error) + List(ctx context.Context, resourceGroupName string) (result network.PublicIPPrefixListResultPage, err error) + ListAll(ctx context.Context) (result network.PublicIPPrefixListResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, publicIPPrefixName string, parameters network.TagsObject) (result network.PublicIPPrefixesUpdateTagsFuture, err error) +} + +var _ PublicIPPrefixesClientAPI = (*network.PublicIPPrefixesClient)(nil) + +// RouteFiltersClientAPI contains the set of methods on the RouteFiltersClient type. +type RouteFiltersClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, routeFilterName string, routeFilterParameters network.RouteFilter) (result network.RouteFiltersCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, routeFilterName string) (result network.RouteFiltersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, routeFilterName string, expand string) (result network.RouteFilter, err error) + List(ctx context.Context) (result network.RouteFilterListResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result network.RouteFilterListResultPage, err error) + Update(ctx context.Context, resourceGroupName string, routeFilterName string, routeFilterParameters network.PatchRouteFilter) (result network.RouteFiltersUpdateFuture, err error) +} + +var _ RouteFiltersClientAPI = (*network.RouteFiltersClient)(nil) + +// RouteFilterRulesClientAPI contains the set of methods on the RouteFilterRulesClient type. +type RouteFilterRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, routeFilterName string, ruleName string, routeFilterRuleParameters network.RouteFilterRule) (result network.RouteFilterRulesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, routeFilterName string, ruleName string) (result network.RouteFilterRulesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, routeFilterName string, ruleName string) (result network.RouteFilterRule, err error) + ListByRouteFilter(ctx context.Context, resourceGroupName string, routeFilterName string) (result network.RouteFilterRuleListResultPage, err error) + Update(ctx context.Context, resourceGroupName string, routeFilterName string, ruleName string, routeFilterRuleParameters network.PatchRouteFilterRule) (result network.RouteFilterRulesUpdateFuture, err error) +} + +var _ RouteFilterRulesClientAPI = (*network.RouteFilterRulesClient)(nil) + +// RouteTablesClientAPI contains the set of methods on the RouteTablesClient type. +type RouteTablesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, routeTableName string, parameters network.RouteTable) (result network.RouteTablesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, routeTableName string) (result network.RouteTablesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, routeTableName string, expand string) (result network.RouteTable, err error) + List(ctx context.Context, resourceGroupName string) (result network.RouteTableListResultPage, err error) + ListAll(ctx context.Context) (result network.RouteTableListResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, routeTableName string, parameters network.TagsObject) (result network.RouteTablesUpdateTagsFuture, err error) +} + +var _ RouteTablesClientAPI = (*network.RouteTablesClient)(nil) + +// RoutesClientAPI contains the set of methods on the RoutesClient type. +type RoutesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, routeTableName string, routeName string, routeParameters network.Route) (result network.RoutesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, routeTableName string, routeName string) (result network.RoutesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, routeTableName string, routeName string) (result network.Route, err error) + List(ctx context.Context, resourceGroupName string, routeTableName string) (result network.RouteListResultPage, err error) +} + +var _ RoutesClientAPI = (*network.RoutesClient)(nil) + +// BgpServiceCommunitiesClientAPI contains the set of methods on the BgpServiceCommunitiesClient type. +type BgpServiceCommunitiesClientAPI interface { + List(ctx context.Context) (result network.BgpServiceCommunityListResultPage, err error) +} + +var _ BgpServiceCommunitiesClientAPI = (*network.BgpServiceCommunitiesClient)(nil) + +// ServiceEndpointPoliciesClientAPI contains the set of methods on the ServiceEndpointPoliciesClient type. +type ServiceEndpointPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceEndpointPolicyName string, parameters network.ServiceEndpointPolicy) (result network.ServiceEndpointPoliciesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serviceEndpointPolicyName string) (result network.ServiceEndpointPoliciesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serviceEndpointPolicyName string, expand string) (result network.ServiceEndpointPolicy, err error) + List(ctx context.Context) (result network.ServiceEndpointPolicyListResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result network.ServiceEndpointPolicyListResultPage, err error) + Update(ctx context.Context, resourceGroupName string, serviceEndpointPolicyName string, parameters network.TagsObject) (result network.ServiceEndpointPoliciesUpdateFuture, err error) +} + +var _ ServiceEndpointPoliciesClientAPI = (*network.ServiceEndpointPoliciesClient)(nil) + +// ServiceEndpointPolicyDefinitionsClientAPI contains the set of methods on the ServiceEndpointPolicyDefinitionsClient type. +type ServiceEndpointPolicyDefinitionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceEndpointPolicyName string, serviceEndpointPolicyDefinitionName string, serviceEndpointPolicyDefinitions network.ServiceEndpointPolicyDefinition) (result network.ServiceEndpointPolicyDefinitionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serviceEndpointPolicyName string, serviceEndpointPolicyDefinitionName string) (result network.ServiceEndpointPolicyDefinitionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serviceEndpointPolicyName string, serviceEndpointPolicyDefinitionName string) (result network.ServiceEndpointPolicyDefinition, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string, serviceEndpointPolicyName string) (result network.ServiceEndpointPolicyDefinitionListResultPage, err error) +} + +var _ ServiceEndpointPolicyDefinitionsClientAPI = (*network.ServiceEndpointPolicyDefinitionsClient)(nil) + +// UsagesClientAPI contains the set of methods on the UsagesClient type. +type UsagesClientAPI interface { + List(ctx context.Context, location string) (result network.UsagesListResultPage, err error) +} + +var _ UsagesClientAPI = (*network.UsagesClient)(nil) + +// VirtualNetworksClientAPI contains the set of methods on the VirtualNetworksClient type. +type VirtualNetworksClientAPI interface { + CheckIPAddressAvailability(ctx context.Context, resourceGroupName string, virtualNetworkName string, IPAddress string) (result network.IPAddressAvailabilityResult, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkName string, parameters network.VirtualNetwork) (result network.VirtualNetworksCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, virtualNetworkName string) (result network.VirtualNetworksDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, virtualNetworkName string, expand string) (result network.VirtualNetwork, err error) + List(ctx context.Context, resourceGroupName string) (result network.VirtualNetworkListResultPage, err error) + ListAll(ctx context.Context) (result network.VirtualNetworkListResultPage, err error) + ListUsage(ctx context.Context, resourceGroupName string, virtualNetworkName string) (result network.VirtualNetworkListUsageResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, virtualNetworkName string, parameters network.TagsObject) (result network.VirtualNetworksUpdateTagsFuture, err error) +} + +var _ VirtualNetworksClientAPI = (*network.VirtualNetworksClient)(nil) + +// SubnetsClientAPI contains the set of methods on the SubnetsClient type. +type SubnetsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkName string, subnetName string, subnetParameters network.Subnet) (result network.SubnetsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, virtualNetworkName string, subnetName string) (result network.SubnetsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, virtualNetworkName string, subnetName string, expand string) (result network.Subnet, err error) + List(ctx context.Context, resourceGroupName string, virtualNetworkName string) (result network.SubnetListResultPage, err error) + PrepareNetworkPolicies(ctx context.Context, resourceGroupName string, virtualNetworkName string, subnetName string, prepareNetworkPoliciesRequestParameters network.PrepareNetworkPoliciesRequest) (result network.SubnetsPrepareNetworkPoliciesFuture, err error) +} + +var _ SubnetsClientAPI = (*network.SubnetsClient)(nil) + +// VirtualNetworkPeeringsClientAPI contains the set of methods on the VirtualNetworkPeeringsClient type. +type VirtualNetworkPeeringsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkName string, virtualNetworkPeeringName string, virtualNetworkPeeringParameters network.VirtualNetworkPeering) (result network.VirtualNetworkPeeringsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, virtualNetworkName string, virtualNetworkPeeringName string) (result network.VirtualNetworkPeeringsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, virtualNetworkName string, virtualNetworkPeeringName string) (result network.VirtualNetworkPeering, err error) + List(ctx context.Context, resourceGroupName string, virtualNetworkName string) (result network.VirtualNetworkPeeringListResultPage, err error) +} + +var _ VirtualNetworkPeeringsClientAPI = (*network.VirtualNetworkPeeringsClient)(nil) + +// VirtualNetworkGatewaysClientAPI contains the set of methods on the VirtualNetworkGatewaysClient type. +type VirtualNetworkGatewaysClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters network.VirtualNetworkGateway) (result network.VirtualNetworkGatewaysCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result network.VirtualNetworkGatewaysDeleteFuture, err error) + Generatevpnclientpackage(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters network.VpnClientParameters) (result network.VirtualNetworkGatewaysGeneratevpnclientpackageFuture, err error) + GenerateVpnProfile(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters network.VpnClientParameters) (result network.VirtualNetworkGatewaysGenerateVpnProfileFuture, err error) + Get(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result network.VirtualNetworkGateway, err error) + GetAdvertisedRoutes(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (result network.VirtualNetworkGatewaysGetAdvertisedRoutesFuture, err error) + GetBgpPeerStatus(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (result network.VirtualNetworkGatewaysGetBgpPeerStatusFuture, err error) + GetLearnedRoutes(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result network.VirtualNetworkGatewaysGetLearnedRoutesFuture, err error) + GetVpnclientIpsecParameters(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result network.VirtualNetworkGatewaysGetVpnclientIpsecParametersFuture, err error) + GetVpnProfilePackageURL(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result network.VirtualNetworkGatewaysGetVpnProfilePackageURLFuture, err error) + List(ctx context.Context, resourceGroupName string) (result network.VirtualNetworkGatewayListResultPage, err error) + ListConnections(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result network.VirtualNetworkGatewayListConnectionsResultPage, err error) + Reset(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string) (result network.VirtualNetworkGatewaysResetFuture, err error) + ResetVpnClientSharedKey(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result network.VirtualNetworkGatewaysResetVpnClientSharedKeyFuture, err error) + SetVpnclientIpsecParameters(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, vpnclientIpsecParams network.VpnClientIPsecParameters) (result network.VirtualNetworkGatewaysSetVpnclientIpsecParametersFuture, err error) + SupportedVpnDevices(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result network.String, err error) + UpdateTags(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters network.TagsObject) (result network.VirtualNetworkGatewaysUpdateTagsFuture, err error) + VpnDeviceConfigurationScript(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters network.VpnDeviceScriptParameters) (result network.String, err error) +} + +var _ VirtualNetworkGatewaysClientAPI = (*network.VirtualNetworkGatewaysClient)(nil) + +// VirtualNetworkGatewayConnectionsClientAPI contains the set of methods on the VirtualNetworkGatewayConnectionsClient type. +type VirtualNetworkGatewayConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters network.VirtualNetworkGatewayConnection) (result network.VirtualNetworkGatewayConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string) (result network.VirtualNetworkGatewayConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string) (result network.VirtualNetworkGatewayConnection, err error) + GetSharedKey(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string) (result network.ConnectionSharedKey, err error) + List(ctx context.Context, resourceGroupName string) (result network.VirtualNetworkGatewayConnectionListResultPage, err error) + ResetSharedKey(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters network.ConnectionResetSharedKey) (result network.VirtualNetworkGatewayConnectionsResetSharedKeyFuture, err error) + SetSharedKey(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters network.ConnectionSharedKey) (result network.VirtualNetworkGatewayConnectionsSetSharedKeyFuture, err error) + UpdateTags(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters network.TagsObject) (result network.VirtualNetworkGatewayConnectionsUpdateTagsFuture, err error) +} + +var _ VirtualNetworkGatewayConnectionsClientAPI = (*network.VirtualNetworkGatewayConnectionsClient)(nil) + +// LocalNetworkGatewaysClientAPI contains the set of methods on the LocalNetworkGatewaysClient type. +type LocalNetworkGatewaysClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, localNetworkGatewayName string, parameters network.LocalNetworkGateway) (result network.LocalNetworkGatewaysCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, localNetworkGatewayName string) (result network.LocalNetworkGatewaysDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, localNetworkGatewayName string) (result network.LocalNetworkGateway, err error) + List(ctx context.Context, resourceGroupName string) (result network.LocalNetworkGatewayListResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, localNetworkGatewayName string, parameters network.TagsObject) (result network.LocalNetworkGatewaysUpdateTagsFuture, err error) +} + +var _ LocalNetworkGatewaysClientAPI = (*network.LocalNetworkGatewaysClient)(nil) + +// VirtualNetworkTapsClientAPI contains the set of methods on the VirtualNetworkTapsClient type. +type VirtualNetworkTapsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, tapName string, parameters network.VirtualNetworkTap) (result network.VirtualNetworkTapsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, tapName string) (result network.VirtualNetworkTapsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, tapName string) (result network.VirtualNetworkTap, err error) + ListAll(ctx context.Context) (result network.VirtualNetworkTapListResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result network.VirtualNetworkTapListResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, tapName string, tapParameters network.TagsObject) (result network.VirtualNetworkTapsUpdateTagsFuture, err error) +} + +var _ VirtualNetworkTapsClientAPI = (*network.VirtualNetworkTapsClient)(nil) + +// VirtualWansClientAPI contains the set of methods on the VirtualWansClient type. +type VirtualWansClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, virtualWANName string, wANParameters network.VirtualWAN) (result network.VirtualWansCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, virtualWANName string) (result network.VirtualWansDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, virtualWANName string) (result network.VirtualWAN, err error) + List(ctx context.Context) (result network.ListVirtualWANsResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result network.ListVirtualWANsResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, virtualWANName string, wANParameters network.TagsObject) (result network.VirtualWansUpdateTagsFuture, err error) +} + +var _ VirtualWansClientAPI = (*network.VirtualWansClient)(nil) + +// VpnSitesClientAPI contains the set of methods on the VpnSitesClient type. +type VpnSitesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, vpnSiteName string, vpnSiteParameters network.VpnSite) (result network.VpnSitesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, vpnSiteName string) (result network.VpnSitesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, vpnSiteName string) (result network.VpnSite, err error) + List(ctx context.Context) (result network.ListVpnSitesResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result network.ListVpnSitesResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, vpnSiteName string, vpnSiteParameters network.TagsObject) (result network.VpnSitesUpdateTagsFuture, err error) +} + +var _ VpnSitesClientAPI = (*network.VpnSitesClient)(nil) + +// VpnSitesConfigurationClientAPI contains the set of methods on the VpnSitesConfigurationClient type. +type VpnSitesConfigurationClientAPI interface { + Download(ctx context.Context, resourceGroupName string, virtualWANName string, request network.GetVpnSitesConfigurationRequest) (result network.VpnSitesConfigurationDownloadFuture, err error) +} + +var _ VpnSitesConfigurationClientAPI = (*network.VpnSitesConfigurationClient)(nil) + +// VirtualHubsClientAPI contains the set of methods on the VirtualHubsClient type. +type VirtualHubsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, virtualHubName string, virtualHubParameters network.VirtualHub) (result network.VirtualHubsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, virtualHubName string) (result network.VirtualHubsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, virtualHubName string) (result network.VirtualHub, err error) + List(ctx context.Context) (result network.ListVirtualHubsResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result network.ListVirtualHubsResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, virtualHubName string, virtualHubParameters network.TagsObject) (result network.VirtualHubsUpdateTagsFuture, err error) +} + +var _ VirtualHubsClientAPI = (*network.VirtualHubsClient)(nil) + +// HubVirtualNetworkConnectionsClientAPI contains the set of methods on the HubVirtualNetworkConnectionsClient type. +type HubVirtualNetworkConnectionsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, virtualHubName string, connectionName string) (result network.HubVirtualNetworkConnection, err error) + List(ctx context.Context, resourceGroupName string, virtualHubName string) (result network.ListHubVirtualNetworkConnectionsResultPage, err error) +} + +var _ HubVirtualNetworkConnectionsClientAPI = (*network.HubVirtualNetworkConnectionsClient)(nil) + +// VpnGatewaysClientAPI contains the set of methods on the VpnGatewaysClient type. +type VpnGatewaysClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, gatewayName string, vpnGatewayParameters network.VpnGateway) (result network.VpnGatewaysCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, gatewayName string) (result network.VpnGatewaysDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, gatewayName string) (result network.VpnGateway, err error) + List(ctx context.Context) (result network.ListVpnGatewaysResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result network.ListVpnGatewaysResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, gatewayName string, vpnGatewayParameters network.TagsObject) (result network.VpnGatewaysUpdateTagsFuture, err error) +} + +var _ VpnGatewaysClientAPI = (*network.VpnGatewaysClient)(nil) + +// VpnConnectionsClientAPI contains the set of methods on the VpnConnectionsClient type. +type VpnConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, vpnConnectionParameters network.VpnConnection) (result network.VpnConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string) (result network.VpnConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string) (result network.VpnConnection, err error) + ListByVpnGateway(ctx context.Context, resourceGroupName string, gatewayName string) (result network.ListVpnConnectionsResultPage, err error) +} + +var _ VpnConnectionsClientAPI = (*network.VpnConnectionsClient)(nil) + +// P2sVpnServerConfigurationsClientAPI contains the set of methods on the P2sVpnServerConfigurationsClient type. +type P2sVpnServerConfigurationsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, virtualWanName string, p2SVpnServerConfigurationName string, p2SVpnServerConfigurationParameters network.P2SVpnServerConfiguration) (result network.P2sVpnServerConfigurationsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, virtualWanName string, p2SVpnServerConfigurationName string) (result network.P2sVpnServerConfigurationsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, virtualWanName string, p2SVpnServerConfigurationName string) (result network.P2SVpnServerConfiguration, err error) + ListByVirtualWan(ctx context.Context, resourceGroupName string, virtualWanName string) (result network.ListP2SVpnServerConfigurationsResultPage, err error) +} + +var _ P2sVpnServerConfigurationsClientAPI = (*network.P2sVpnServerConfigurationsClient)(nil) + +// P2sVpnGatewaysClientAPI contains the set of methods on the P2sVpnGatewaysClient type. +type P2sVpnGatewaysClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, gatewayName string, p2SVpnGatewayParameters network.P2SVpnGateway) (result network.P2sVpnGatewaysCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, gatewayName string) (result network.P2sVpnGatewaysDeleteFuture, err error) + GenerateVpnProfile(ctx context.Context, resourceGroupName string, gatewayName string, parameters network.P2SVpnProfileParameters) (result network.P2sVpnGatewaysGenerateVpnProfileFuture, err error) + Get(ctx context.Context, resourceGroupName string, gatewayName string) (result network.P2SVpnGateway, err error) + List(ctx context.Context) (result network.ListP2SVpnGatewaysResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result network.ListP2SVpnGatewaysResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, gatewayName string, p2SVpnGatewayParameters network.TagsObject) (result network.P2sVpnGatewaysUpdateTagsFuture, err error) +} + +var _ P2sVpnGatewaysClientAPI = (*network.P2sVpnGatewaysClient)(nil) + +// WebApplicationFirewallPoliciesClientAPI contains the set of methods on the WebApplicationFirewallPoliciesClient type. +type WebApplicationFirewallPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, policyName string, parameters network.WebApplicationFirewallPolicy) (result network.WebApplicationFirewallPolicy, err error) + Delete(ctx context.Context, resourceGroupName string, policyName string) (result network.WebApplicationFirewallPoliciesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, policyName string) (result network.WebApplicationFirewallPolicy, err error) + List(ctx context.Context, resourceGroupName string) (result network.WebApplicationFirewallPolicyListResultPage, err error) + ListAll(ctx context.Context) (result network.WebApplicationFirewallPolicyListResultPage, err error) +} + +var _ WebApplicationFirewallPoliciesClientAPI = (*network.WebApplicationFirewallPoliciesClient)(nil) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/resourcesapi/BUILD.bazel b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/resourcesapi/BUILD.bazel new file mode 100644 index 00000000000..dd028e92f43 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/resourcesapi/BUILD.bazel @@ -0,0 +1,13 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["interfaces.go"], + importmap = "sigs.k8s.io/cluster-api-provider-azure/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/resourcesapi", + importpath = "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/resourcesapi", + visibility = ["//visibility:public"], + deps = [ + "//vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources:go_default_library", + "//vendor/github.com/Azure/go-autorest/autorest:go_default_library", + ], +) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/resourcesapi/interfaces.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/resourcesapi/interfaces.go new file mode 100644 index 00000000000..1b5dd50dd57 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/resourcesapi/interfaces.go @@ -0,0 +1,117 @@ +package resourcesapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// 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 Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources" + "github.com/Azure/go-autorest/autorest" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result resources.OperationListResultPage, err error) +} + +var _ OperationsClientAPI = (*resources.OperationsClient)(nil) + +// DeploymentsClientAPI contains the set of methods on the DeploymentsClient type. +type DeploymentsClientAPI interface { + Cancel(ctx context.Context, resourceGroupName string, deploymentName string) (result autorest.Response, err error) + CancelAtSubscriptionScope(ctx context.Context, deploymentName string) (result autorest.Response, err error) + CheckExistence(ctx context.Context, resourceGroupName string, deploymentName string) (result autorest.Response, err error) + CheckExistenceAtSubscriptionScope(ctx context.Context, deploymentName string) (result autorest.Response, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, parameters resources.Deployment) (result resources.DeploymentsCreateOrUpdateFuture, err error) + CreateOrUpdateAtSubscriptionScope(ctx context.Context, deploymentName string, parameters resources.Deployment) (result resources.DeploymentsCreateOrUpdateAtSubscriptionScopeFuture, err error) + Delete(ctx context.Context, resourceGroupName string, deploymentName string) (result resources.DeploymentsDeleteFuture, err error) + DeleteAtSubscriptionScope(ctx context.Context, deploymentName string) (result resources.DeploymentsDeleteAtSubscriptionScopeFuture, err error) + ExportTemplate(ctx context.Context, resourceGroupName string, deploymentName string) (result resources.DeploymentExportResult, err error) + ExportTemplateAtSubscriptionScope(ctx context.Context, deploymentName string) (result resources.DeploymentExportResult, err error) + Get(ctx context.Context, resourceGroupName string, deploymentName string) (result resources.DeploymentExtended, err error) + GetAtSubscriptionScope(ctx context.Context, deploymentName string) (result resources.DeploymentExtended, err error) + ListAtSubscriptionScope(ctx context.Context, filter string, top *int32) (result resources.DeploymentListResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, top *int32) (result resources.DeploymentListResultPage, err error) + Validate(ctx context.Context, resourceGroupName string, deploymentName string, parameters resources.Deployment) (result resources.DeploymentValidateResult, err error) + ValidateAtSubscriptionScope(ctx context.Context, deploymentName string, parameters resources.Deployment) (result resources.DeploymentValidateResult, err error) +} + +var _ DeploymentsClientAPI = (*resources.DeploymentsClient)(nil) + +// ProvidersClientAPI contains the set of methods on the ProvidersClient type. +type ProvidersClientAPI interface { + Get(ctx context.Context, resourceProviderNamespace string, expand string) (result resources.Provider, err error) + List(ctx context.Context, top *int32, expand string) (result resources.ProviderListResultPage, err error) + Register(ctx context.Context, resourceProviderNamespace string) (result resources.Provider, err error) + Unregister(ctx context.Context, resourceProviderNamespace string) (result resources.Provider, err error) +} + +var _ ProvidersClientAPI = (*resources.ProvidersClient)(nil) + +// ClientAPI contains the set of methods on the Client type. +type ClientAPI interface { + CheckExistence(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result autorest.Response, err error) + CheckExistenceByID(ctx context.Context, resourceID string) (result autorest.Response, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, parameters resources.GenericResource) (result resources.CreateOrUpdateFuture, err error) + CreateOrUpdateByID(ctx context.Context, resourceID string, parameters resources.GenericResource) (result resources.CreateOrUpdateByIDFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result resources.DeleteFuture, err error) + DeleteByID(ctx context.Context, resourceID string) (result resources.DeleteByIDFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result resources.GenericResource, err error) + GetByID(ctx context.Context, resourceID string) (result resources.GenericResource, err error) + List(ctx context.Context, filter string, expand string, top *int32) (result resources.ListResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, expand string, top *int32) (result resources.ListResultPage, err error) + MoveResources(ctx context.Context, sourceResourceGroupName string, parameters resources.MoveInfo) (result resources.MoveResourcesFuture, err error) + Update(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, parameters resources.GenericResource) (result resources.UpdateFuture, err error) + UpdateByID(ctx context.Context, resourceID string, parameters resources.GenericResource) (result resources.UpdateByIDFuture, err error) + ValidateMoveResources(ctx context.Context, sourceResourceGroupName string, parameters resources.MoveInfo) (result resources.ValidateMoveResourcesFuture, err error) +} + +var _ ClientAPI = (*resources.Client)(nil) + +// GroupsClientAPI contains the set of methods on the GroupsClient type. +type GroupsClientAPI interface { + CheckExistence(ctx context.Context, resourceGroupName string) (result autorest.Response, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, parameters resources.Group) (result resources.Group, err error) + Delete(ctx context.Context, resourceGroupName string) (result resources.GroupsDeleteFuture, err error) + ExportTemplate(ctx context.Context, resourceGroupName string, parameters resources.ExportTemplateRequest) (result resources.GroupExportResult, err error) + Get(ctx context.Context, resourceGroupName string) (result resources.Group, err error) + List(ctx context.Context, filter string, top *int32) (result resources.GroupListResultPage, err error) + Update(ctx context.Context, resourceGroupName string, parameters resources.GroupPatchable) (result resources.Group, err error) +} + +var _ GroupsClientAPI = (*resources.GroupsClient)(nil) + +// TagsClientAPI contains the set of methods on the TagsClient type. +type TagsClientAPI interface { + CreateOrUpdate(ctx context.Context, tagName string) (result resources.TagDetails, err error) + CreateOrUpdateValue(ctx context.Context, tagName string, tagValue string) (result resources.TagValue, err error) + Delete(ctx context.Context, tagName string) (result autorest.Response, err error) + DeleteValue(ctx context.Context, tagName string, tagValue string) (result autorest.Response, err error) + List(ctx context.Context) (result resources.TagsListResultPage, err error) +} + +var _ TagsClientAPI = (*resources.TagsClient)(nil) + +// DeploymentOperationsClientAPI contains the set of methods on the DeploymentOperationsClient type. +type DeploymentOperationsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, deploymentName string, operationID string) (result resources.DeploymentOperation, err error) + GetAtSubscriptionScope(ctx context.Context, deploymentName string, operationID string) (result resources.DeploymentOperation, err error) + List(ctx context.Context, resourceGroupName string, deploymentName string, top *int32) (result resources.DeploymentOperationsListResultPage, err error) + ListAtSubscriptionScope(ctx context.Context, deploymentName string, top *int32) (result resources.DeploymentOperationsListResultPage, err error) +} + +var _ DeploymentOperationsClientAPI = (*resources.DeploymentOperationsClient)(nil) diff --git a/vendor/github.com/golang/mock/AUTHORS b/vendor/github.com/golang/mock/AUTHORS new file mode 100644 index 00000000000..660b8ccc8ae --- /dev/null +++ b/vendor/github.com/golang/mock/AUTHORS @@ -0,0 +1,12 @@ +# This is the official list of GoMock authors for copyright purposes. +# This file is distinct from the CONTRIBUTORS files. +# See the latter for an explanation. + +# Names should be added to this file as +# Name or Organization +# The email address is not required for organizations. + +# Please keep the list sorted. + +Alex Reece +Google Inc. diff --git a/vendor/github.com/golang/mock/CONTRIBUTORS b/vendor/github.com/golang/mock/CONTRIBUTORS new file mode 100644 index 00000000000..def849cab1b --- /dev/null +++ b/vendor/github.com/golang/mock/CONTRIBUTORS @@ -0,0 +1,37 @@ +# This is the official list of people who can contribute (and typically +# have contributed) code to the gomock repository. +# The AUTHORS file lists the copyright holders; this file +# lists people. For example, Google employees are listed here +# but not in AUTHORS, because Google holds the copyright. +# +# The submission process automatically checks to make sure +# that people submitting code are listed in this file (by email address). +# +# Names should be added to this file only after verifying that +# the individual or the individual's organization has agreed to +# the appropriate Contributor License Agreement, found here: +# +# http://code.google.com/legal/individual-cla-v1.0.html +# http://code.google.com/legal/corporate-cla-v1.0.html +# +# The agreement for individuals can be filled out on the web. +# +# When adding J Random Contributor's name to this file, +# either J's name or J's organization's name should be +# added to the AUTHORS file, depending on whether the +# individual or corporate CLA was used. + +# Names should be added to this file like so: +# Name +# +# An entry with two email addresses specifies that the +# first address should be used in the submit logs and +# that the second address should be recognized as the +# same person when interacting with Rietveld. + +# Please keep the list sorted. + +Aaron Jacobs +Alex Reece +David Symonds +Ryan Barrett diff --git a/vendor/github.com/golang/mock/LICENSE b/vendor/github.com/golang/mock/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/vendor/github.com/golang/mock/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vendor/github.com/golang/mock/gomock/BUILD.bazel b/vendor/github.com/golang/mock/gomock/BUILD.bazel new file mode 100644 index 00000000000..68556ad6104 --- /dev/null +++ b/vendor/github.com/golang/mock/gomock/BUILD.bazel @@ -0,0 +1,14 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "call.go", + "callset.go", + "controller.go", + "matchers.go", + ], + importmap = "sigs.k8s.io/cluster-api-provider-azure/vendor/github.com/golang/mock/gomock", + importpath = "github.com/golang/mock/gomock", + visibility = ["//visibility:public"], +) diff --git a/vendor/github.com/golang/mock/gomock/call.go b/vendor/github.com/golang/mock/gomock/call.go new file mode 100644 index 00000000000..3d54d9f5d01 --- /dev/null +++ b/vendor/github.com/golang/mock/gomock/call.go @@ -0,0 +1,420 @@ +// Copyright 2010 Google Inc. +// +// 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 gomock + +import ( + "fmt" + "reflect" + "strconv" + "strings" +) + +// Call represents an expected call to a mock. +type Call struct { + t TestHelper // for triggering test failures on invalid call setup + + receiver interface{} // the receiver of the method call + method string // the name of the method + methodType reflect.Type // the type of the method + args []Matcher // the args + origin string // file and line number of call setup + + preReqs []*Call // prerequisite calls + + // Expectations + minCalls, maxCalls int + + numCalls int // actual number made + + // actions are called when this Call is called. Each action gets the args and + // can set the return values by returning a non-nil slice. Actions run in the + // order they are created. + actions []func([]interface{}) []interface{} +} + +// newCall creates a *Call. It requires the method type in order to support +// unexported methods. +func newCall(t TestHelper, receiver interface{}, method string, methodType reflect.Type, args ...interface{}) *Call { + t.Helper() + + // TODO: check arity, types. + margs := make([]Matcher, len(args)) + for i, arg := range args { + if m, ok := arg.(Matcher); ok { + margs[i] = m + } else if arg == nil { + // Handle nil specially so that passing a nil interface value + // will match the typed nils of concrete args. + margs[i] = Nil() + } else { + margs[i] = Eq(arg) + } + } + + origin := callerInfo(3) + actions := []func([]interface{}) []interface{}{func([]interface{}) []interface{} { + // Synthesize the zero value for each of the return args' types. + rets := make([]interface{}, methodType.NumOut()) + for i := 0; i < methodType.NumOut(); i++ { + rets[i] = reflect.Zero(methodType.Out(i)).Interface() + } + return rets + }} + return &Call{t: t, receiver: receiver, method: method, methodType: methodType, + args: margs, origin: origin, minCalls: 1, maxCalls: 1, actions: actions} +} + +// AnyTimes allows the expectation to be called 0 or more times +func (c *Call) AnyTimes() *Call { + c.minCalls, c.maxCalls = 0, 1e8 // close enough to infinity + return c +} + +// MinTimes requires the call to occur at least n times. If AnyTimes or MaxTimes have not been called, MinTimes also +// sets the maximum number of calls to infinity. +func (c *Call) MinTimes(n int) *Call { + c.minCalls = n + if c.maxCalls == 1 { + c.maxCalls = 1e8 + } + return c +} + +// MaxTimes limits the number of calls to n times. If AnyTimes or MinTimes have not been called, MaxTimes also +// sets the minimum number of calls to 0. +func (c *Call) MaxTimes(n int) *Call { + c.maxCalls = n + if c.minCalls == 1 { + c.minCalls = 0 + } + return c +} + +// DoAndReturn declares the action to run when the call is matched. +// The return values from this function are returned by the mocked function. +// It takes an interface{} argument to support n-arity functions. +func (c *Call) DoAndReturn(f interface{}) *Call { + // TODO: Check arity and types here, rather than dying badly elsewhere. + v := reflect.ValueOf(f) + + c.addAction(func(args []interface{}) []interface{} { + vargs := make([]reflect.Value, len(args)) + ft := v.Type() + for i := 0; i < len(args); i++ { + if args[i] != nil { + vargs[i] = reflect.ValueOf(args[i]) + } else { + // Use the zero value for the arg. + vargs[i] = reflect.Zero(ft.In(i)) + } + } + vrets := v.Call(vargs) + rets := make([]interface{}, len(vrets)) + for i, ret := range vrets { + rets[i] = ret.Interface() + } + return rets + }) + return c +} + +// Do declares the action to run when the call is matched. The function's +// return values are ignored to retain backward compatibility. To use the +// return values call DoAndReturn. +// It takes an interface{} argument to support n-arity functions. +func (c *Call) Do(f interface{}) *Call { + // TODO: Check arity and types here, rather than dying badly elsewhere. + v := reflect.ValueOf(f) + + c.addAction(func(args []interface{}) []interface{} { + vargs := make([]reflect.Value, len(args)) + ft := v.Type() + for i := 0; i < len(args); i++ { + if args[i] != nil { + vargs[i] = reflect.ValueOf(args[i]) + } else { + // Use the zero value for the arg. + vargs[i] = reflect.Zero(ft.In(i)) + } + } + v.Call(vargs) + return nil + }) + return c +} + +// Return declares the values to be returned by the mocked function call. +func (c *Call) Return(rets ...interface{}) *Call { + c.t.Helper() + + mt := c.methodType + if len(rets) != mt.NumOut() { + c.t.Fatalf("wrong number of arguments to Return for %T.%v: got %d, want %d [%s]", + c.receiver, c.method, len(rets), mt.NumOut(), c.origin) + } + for i, ret := range rets { + if got, want := reflect.TypeOf(ret), mt.Out(i); got == want { + // Identical types; nothing to do. + } else if got == nil { + // Nil needs special handling. + switch want.Kind() { + case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: + // ok + default: + c.t.Fatalf("argument %d to Return for %T.%v is nil, but %v is not nillable [%s]", + i, c.receiver, c.method, want, c.origin) + } + } else if got.AssignableTo(want) { + // Assignable type relation. Make the assignment now so that the generated code + // can return the values with a type assertion. + v := reflect.New(want).Elem() + v.Set(reflect.ValueOf(ret)) + rets[i] = v.Interface() + } else { + c.t.Fatalf("wrong type of argument %d to Return for %T.%v: %v is not assignable to %v [%s]", + i, c.receiver, c.method, got, want, c.origin) + } + } + + c.addAction(func([]interface{}) []interface{} { + return rets + }) + + return c +} + +// Times declares the exact number of times a function call is expected to be executed. +func (c *Call) Times(n int) *Call { + c.minCalls, c.maxCalls = n, n + return c +} + +// SetArg declares an action that will set the nth argument's value, +// indirected through a pointer. Or, in the case of a slice, SetArg +// will copy value's elements into the nth argument. +func (c *Call) SetArg(n int, value interface{}) *Call { + c.t.Helper() + + mt := c.methodType + // TODO: This will break on variadic methods. + // We will need to check those at invocation time. + if n < 0 || n >= mt.NumIn() { + c.t.Fatalf("SetArg(%d, ...) called for a method with %d args [%s]", + n, mt.NumIn(), c.origin) + } + // Permit setting argument through an interface. + // In the interface case, we don't (nay, can't) check the type here. + at := mt.In(n) + switch at.Kind() { + case reflect.Ptr: + dt := at.Elem() + if vt := reflect.TypeOf(value); !vt.AssignableTo(dt) { + c.t.Fatalf("SetArg(%d, ...) argument is a %v, not assignable to %v [%s]", + n, vt, dt, c.origin) + } + case reflect.Interface: + // nothing to do + case reflect.Slice: + // nothing to do + default: + c.t.Fatalf("SetArg(%d, ...) referring to argument of non-pointer non-interface non-slice type %v [%s]", + n, at, c.origin) + } + + c.addAction(func(args []interface{}) []interface{} { + v := reflect.ValueOf(value) + switch reflect.TypeOf(args[n]).Kind() { + case reflect.Slice: + setSlice(args[n], v) + default: + reflect.ValueOf(args[n]).Elem().Set(v) + } + return nil + }) + return c +} + +// isPreReq returns true if other is a direct or indirect prerequisite to c. +func (c *Call) isPreReq(other *Call) bool { + for _, preReq := range c.preReqs { + if other == preReq || preReq.isPreReq(other) { + return true + } + } + return false +} + +// After declares that the call may only match after preReq has been exhausted. +func (c *Call) After(preReq *Call) *Call { + c.t.Helper() + + if c == preReq { + c.t.Fatalf("A call isn't allowed to be its own prerequisite") + } + if preReq.isPreReq(c) { + c.t.Fatalf("Loop in call order: %v is a prerequisite to %v (possibly indirectly).", c, preReq) + } + + c.preReqs = append(c.preReqs, preReq) + return c +} + +// Returns true if the minimum number of calls have been made. +func (c *Call) satisfied() bool { + return c.numCalls >= c.minCalls +} + +// Returns true iff the maximum number of calls have been made. +func (c *Call) exhausted() bool { + return c.numCalls >= c.maxCalls +} + +func (c *Call) String() string { + args := make([]string, len(c.args)) + for i, arg := range c.args { + args[i] = arg.String() + } + arguments := strings.Join(args, ", ") + return fmt.Sprintf("%T.%v(%s) %s", c.receiver, c.method, arguments, c.origin) +} + +// Tests if the given call matches the expected call. +// If yes, returns nil. If no, returns error with message explaining why it does not match. +func (c *Call) matches(args []interface{}) error { + if !c.methodType.IsVariadic() { + if len(args) != len(c.args) { + return fmt.Errorf("Expected call at %s has the wrong number of arguments. Got: %d, want: %d", + c.origin, len(args), len(c.args)) + } + + for i, m := range c.args { + if !m.Matches(args[i]) { + return fmt.Errorf("Expected call at %s doesn't match the argument at index %s.\nGot: %v\nWant: %v", + c.origin, strconv.Itoa(i), args[i], m) + } + } + } else { + if len(c.args) < c.methodType.NumIn()-1 { + return fmt.Errorf("Expected call at %s has the wrong number of matchers. Got: %d, want: %d", + c.origin, len(c.args), c.methodType.NumIn()-1) + } + if len(c.args) != c.methodType.NumIn() && len(args) != len(c.args) { + return fmt.Errorf("Expected call at %s has the wrong number of arguments. Got: %d, want: %d", + c.origin, len(args), len(c.args)) + } + if len(args) < len(c.args)-1 { + return fmt.Errorf("Expected call at %s has the wrong number of arguments. Got: %d, want: greater than or equal to %d", + c.origin, len(args), len(c.args)-1) + } + + for i, m := range c.args { + if i < c.methodType.NumIn()-1 { + // Non-variadic args + if !m.Matches(args[i]) { + return fmt.Errorf("Expected call at %s doesn't match the argument at index %s.\nGot: %v\nWant: %v", + c.origin, strconv.Itoa(i), args[i], m) + } + continue + } + // The last arg has a possibility of a variadic argument, so let it branch + + // sample: Foo(a int, b int, c ...int) + if i < len(c.args) && i < len(args) { + if m.Matches(args[i]) { + // Got Foo(a, b, c) want Foo(matcherA, matcherB, gomock.Any()) + // Got Foo(a, b, c) want Foo(matcherA, matcherB, someSliceMatcher) + // Got Foo(a, b, c) want Foo(matcherA, matcherB, matcherC) + // Got Foo(a, b) want Foo(matcherA, matcherB) + // Got Foo(a, b, c, d) want Foo(matcherA, matcherB, matcherC, matcherD) + continue + } + } + + // The number of actual args don't match the number of matchers, + // or the last matcher is a slice and the last arg is not. + // If this function still matches it is because the last matcher + // matches all the remaining arguments or the lack of any. + // Convert the remaining arguments, if any, into a slice of the + // expected type. + vargsType := c.methodType.In(c.methodType.NumIn() - 1) + vargs := reflect.MakeSlice(vargsType, 0, len(args)-i) + for _, arg := range args[i:] { + vargs = reflect.Append(vargs, reflect.ValueOf(arg)) + } + if m.Matches(vargs.Interface()) { + // Got Foo(a, b, c, d, e) want Foo(matcherA, matcherB, gomock.Any()) + // Got Foo(a, b, c, d, e) want Foo(matcherA, matcherB, someSliceMatcher) + // Got Foo(a, b) want Foo(matcherA, matcherB, gomock.Any()) + // Got Foo(a, b) want Foo(matcherA, matcherB, someEmptySliceMatcher) + break + } + // Wrong number of matchers or not match. Fail. + // Got Foo(a, b) want Foo(matcherA, matcherB, matcherC, matcherD) + // Got Foo(a, b, c) want Foo(matcherA, matcherB, matcherC, matcherD) + // Got Foo(a, b, c, d) want Foo(matcherA, matcherB, matcherC, matcherD, matcherE) + // Got Foo(a, b, c, d, e) want Foo(matcherA, matcherB, matcherC, matcherD) + // Got Foo(a, b, c) want Foo(matcherA, matcherB) + return fmt.Errorf("Expected call at %s doesn't match the argument at index %s.\nGot: %v\nWant: %v", + c.origin, strconv.Itoa(i), args[i:], c.args[i]) + + } + } + + // Check that all prerequisite calls have been satisfied. + for _, preReqCall := range c.preReqs { + if !preReqCall.satisfied() { + return fmt.Errorf("Expected call at %s doesn't have a prerequisite call satisfied:\n%v\nshould be called before:\n%v", + c.origin, preReqCall, c) + } + } + + // Check that the call is not exhausted. + if c.exhausted() { + return fmt.Errorf("Expected call at %s has already been called the max number of times.", c.origin) + } + + return nil +} + +// dropPrereqs tells the expected Call to not re-check prerequisite calls any +// longer, and to return its current set. +func (c *Call) dropPrereqs() (preReqs []*Call) { + preReqs = c.preReqs + c.preReqs = nil + return +} + +func (c *Call) call(args []interface{}) []func([]interface{}) []interface{} { + c.numCalls++ + return c.actions +} + +// InOrder declares that the given calls should occur in order. +func InOrder(calls ...*Call) { + for i := 1; i < len(calls); i++ { + calls[i].After(calls[i-1]) + } +} + +func setSlice(arg interface{}, v reflect.Value) { + va := reflect.ValueOf(arg) + for i := 0; i < v.Len(); i++ { + va.Index(i).Set(v.Index(i)) + } +} + +func (c *Call) addAction(action func([]interface{}) []interface{}) { + c.actions = append(c.actions, action) +} diff --git a/vendor/github.com/golang/mock/gomock/callset.go b/vendor/github.com/golang/mock/gomock/callset.go new file mode 100644 index 00000000000..c44a8a585b3 --- /dev/null +++ b/vendor/github.com/golang/mock/gomock/callset.go @@ -0,0 +1,108 @@ +// Copyright 2011 Google Inc. +// +// 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 gomock + +import ( + "bytes" + "fmt" +) + +// callSet represents a set of expected calls, indexed by receiver and method +// name. +type callSet struct { + // Calls that are still expected. + expected map[callSetKey][]*Call + // Calls that have been exhausted. + exhausted map[callSetKey][]*Call +} + +// callSetKey is the key in the maps in callSet +type callSetKey struct { + receiver interface{} + fname string +} + +func newCallSet() *callSet { + return &callSet{make(map[callSetKey][]*Call), make(map[callSetKey][]*Call)} +} + +// Add adds a new expected call. +func (cs callSet) Add(call *Call) { + key := callSetKey{call.receiver, call.method} + m := cs.expected + if call.exhausted() { + m = cs.exhausted + } + m[key] = append(m[key], call) +} + +// Remove removes an expected call. +func (cs callSet) Remove(call *Call) { + key := callSetKey{call.receiver, call.method} + calls := cs.expected[key] + for i, c := range calls { + if c == call { + // maintain order for remaining calls + cs.expected[key] = append(calls[:i], calls[i+1:]...) + cs.exhausted[key] = append(cs.exhausted[key], call) + break + } + } +} + +// FindMatch searches for a matching call. Returns error with explanation message if no call matched. +func (cs callSet) FindMatch(receiver interface{}, method string, args []interface{}) (*Call, error) { + key := callSetKey{receiver, method} + + // Search through the expected calls. + expected := cs.expected[key] + var callsErrors bytes.Buffer + for _, call := range expected { + err := call.matches(args) + if err != nil { + fmt.Fprintf(&callsErrors, "\n%v", err) + } else { + return call, nil + } + } + + // If we haven't found a match then search through the exhausted calls so we + // get useful error messages. + exhausted := cs.exhausted[key] + for _, call := range exhausted { + if err := call.matches(args); err != nil { + fmt.Fprintf(&callsErrors, "\n%v", err) + } + } + + if len(expected)+len(exhausted) == 0 { + fmt.Fprintf(&callsErrors, "there are no expected calls of the method %q for that receiver", method) + } + + return nil, fmt.Errorf(callsErrors.String()) +} + +// Failures returns the calls that are not satisfied. +func (cs callSet) Failures() []*Call { + failures := make([]*Call, 0, len(cs.expected)) + for _, calls := range cs.expected { + for _, call := range calls { + if !call.satisfied() { + failures = append(failures, call) + } + } + } + return failures +} diff --git a/vendor/github.com/golang/mock/gomock/controller.go b/vendor/github.com/golang/mock/gomock/controller.go new file mode 100644 index 00000000000..6fde25f5087 --- /dev/null +++ b/vendor/github.com/golang/mock/gomock/controller.go @@ -0,0 +1,235 @@ +// Copyright 2010 Google Inc. +// +// 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. + +// GoMock - a mock framework for Go. +// +// Standard usage: +// (1) Define an interface that you wish to mock. +// type MyInterface interface { +// SomeMethod(x int64, y string) +// } +// (2) Use mockgen to generate a mock from the interface. +// (3) Use the mock in a test: +// func TestMyThing(t *testing.T) { +// mockCtrl := gomock.NewController(t) +// defer mockCtrl.Finish() +// +// mockObj := something.NewMockMyInterface(mockCtrl) +// mockObj.EXPECT().SomeMethod(4, "blah") +// // pass mockObj to a real object and play with it. +// } +// +// By default, expected calls are not enforced to run in any particular order. +// Call order dependency can be enforced by use of InOrder and/or Call.After. +// Call.After can create more varied call order dependencies, but InOrder is +// often more convenient. +// +// The following examples create equivalent call order dependencies. +// +// Example of using Call.After to chain expected call order: +// +// firstCall := mockObj.EXPECT().SomeMethod(1, "first") +// secondCall := mockObj.EXPECT().SomeMethod(2, "second").After(firstCall) +// mockObj.EXPECT().SomeMethod(3, "third").After(secondCall) +// +// Example of using InOrder to declare expected call order: +// +// gomock.InOrder( +// mockObj.EXPECT().SomeMethod(1, "first"), +// mockObj.EXPECT().SomeMethod(2, "second"), +// mockObj.EXPECT().SomeMethod(3, "third"), +// ) +// +// TODO: +// - Handle different argument/return types (e.g. ..., chan, map, interface). +package gomock + +import ( + "context" + "fmt" + "reflect" + "runtime" + "sync" +) + +// A TestReporter is something that can be used to report test failures. +// It is satisfied by the standard library's *testing.T. +type TestReporter interface { + Errorf(format string, args ...interface{}) + Fatalf(format string, args ...interface{}) +} + +// TestHelper is a TestReporter that has the Helper method. It is satisfied +// by the standard library's *testing.T. +type TestHelper interface { + TestReporter + Helper() +} + +// A Controller represents the top-level control of a mock ecosystem. +// It defines the scope and lifetime of mock objects, as well as their expectations. +// It is safe to call Controller's methods from multiple goroutines. +type Controller struct { + // T should only be called within a generated mock. It is not intended to + // be used in user code and may be changed in future versions. T is the + // TestReporter passed in when creating the Controller via NewController. + // If the TestReporter does not implment a TestHelper it will be wrapped + // with a nopTestHelper. + T TestHelper + mu sync.Mutex + expectedCalls *callSet + finished bool +} + +func NewController(t TestReporter) *Controller { + h, ok := t.(TestHelper) + if !ok { + h = nopTestHelper{t} + } + + return &Controller{ + T: h, + expectedCalls: newCallSet(), + } +} + +type cancelReporter struct { + TestHelper + cancel func() +} + +func (r *cancelReporter) Errorf(format string, args ...interface{}) { + r.TestHelper.Errorf(format, args...) +} +func (r *cancelReporter) Fatalf(format string, args ...interface{}) { + defer r.cancel() + r.TestHelper.Fatalf(format, args...) +} + +// WithContext returns a new Controller and a Context, which is cancelled on any +// fatal failure. +func WithContext(ctx context.Context, t TestReporter) (*Controller, context.Context) { + h, ok := t.(TestHelper) + if !ok { + h = nopTestHelper{t} + } + + ctx, cancel := context.WithCancel(ctx) + return NewController(&cancelReporter{h, cancel}), ctx +} + +type nopTestHelper struct { + TestReporter +} + +func (h nopTestHelper) Helper() {} + +func (ctrl *Controller) RecordCall(receiver interface{}, method string, args ...interface{}) *Call { + ctrl.T.Helper() + + recv := reflect.ValueOf(receiver) + for i := 0; i < recv.Type().NumMethod(); i++ { + if recv.Type().Method(i).Name == method { + return ctrl.RecordCallWithMethodType(receiver, method, recv.Method(i).Type(), args...) + } + } + ctrl.T.Fatalf("gomock: failed finding method %s on %T", method, receiver) + panic("unreachable") +} + +func (ctrl *Controller) RecordCallWithMethodType(receiver interface{}, method string, methodType reflect.Type, args ...interface{}) *Call { + ctrl.T.Helper() + + call := newCall(ctrl.T, receiver, method, methodType, args...) + + ctrl.mu.Lock() + defer ctrl.mu.Unlock() + ctrl.expectedCalls.Add(call) + + return call +} + +func (ctrl *Controller) Call(receiver interface{}, method string, args ...interface{}) []interface{} { + ctrl.T.Helper() + + // Nest this code so we can use defer to make sure the lock is released. + actions := func() []func([]interface{}) []interface{} { + ctrl.T.Helper() + ctrl.mu.Lock() + defer ctrl.mu.Unlock() + + expected, err := ctrl.expectedCalls.FindMatch(receiver, method, args) + if err != nil { + origin := callerInfo(2) + ctrl.T.Fatalf("Unexpected call to %T.%v(%v) at %s because: %s", receiver, method, args, origin, err) + } + + // Two things happen here: + // * the matching call no longer needs to check prerequite calls, + // * and the prerequite calls are no longer expected, so remove them. + preReqCalls := expected.dropPrereqs() + for _, preReqCall := range preReqCalls { + ctrl.expectedCalls.Remove(preReqCall) + } + + actions := expected.call(args) + if expected.exhausted() { + ctrl.expectedCalls.Remove(expected) + } + return actions + }() + + var rets []interface{} + for _, action := range actions { + if r := action(args); r != nil { + rets = r + } + } + + return rets +} + +func (ctrl *Controller) Finish() { + ctrl.T.Helper() + + ctrl.mu.Lock() + defer ctrl.mu.Unlock() + + if ctrl.finished { + ctrl.T.Fatalf("Controller.Finish was called more than once. It has to be called exactly once.") + } + ctrl.finished = true + + // If we're currently panicking, probably because this is a deferred call, + // pass through the panic. + if err := recover(); err != nil { + panic(err) + } + + // Check that all remaining expected calls are satisfied. + failures := ctrl.expectedCalls.Failures() + for _, call := range failures { + ctrl.T.Errorf("missing call(s) to %v", call) + } + if len(failures) != 0 { + ctrl.T.Fatalf("aborting test due to missing call(s)") + } +} + +func callerInfo(skip int) string { + if _, file, line, ok := runtime.Caller(skip + 1); ok { + return fmt.Sprintf("%s:%d", file, line) + } + return "unknown file" +} diff --git a/vendor/github.com/golang/mock/gomock/matchers.go b/vendor/github.com/golang/mock/gomock/matchers.go new file mode 100644 index 00000000000..189796f8656 --- /dev/null +++ b/vendor/github.com/golang/mock/gomock/matchers.go @@ -0,0 +1,122 @@ +// Copyright 2010 Google Inc. +// +// 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 gomock + +import ( + "fmt" + "reflect" +) + +// A Matcher is a representation of a class of values. +// It is used to represent the valid or expected arguments to a mocked method. +type Matcher interface { + // Matches returns whether x is a match. + Matches(x interface{}) bool + + // String describes what the matcher matches. + String() string +} + +type anyMatcher struct{} + +func (anyMatcher) Matches(x interface{}) bool { + return true +} + +func (anyMatcher) String() string { + return "is anything" +} + +type eqMatcher struct { + x interface{} +} + +func (e eqMatcher) Matches(x interface{}) bool { + return reflect.DeepEqual(e.x, x) +} + +func (e eqMatcher) String() string { + return fmt.Sprintf("is equal to %v", e.x) +} + +type nilMatcher struct{} + +func (nilMatcher) Matches(x interface{}) bool { + if x == nil { + return true + } + + v := reflect.ValueOf(x) + switch v.Kind() { + case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, + reflect.Ptr, reflect.Slice: + return v.IsNil() + } + + return false +} + +func (nilMatcher) String() string { + return "is nil" +} + +type notMatcher struct { + m Matcher +} + +func (n notMatcher) Matches(x interface{}) bool { + return !n.m.Matches(x) +} + +func (n notMatcher) String() string { + // TODO: Improve this if we add a NotString method to the Matcher interface. + return "not(" + n.m.String() + ")" +} + +type assignableToTypeOfMatcher struct { + targetType reflect.Type +} + +func (m assignableToTypeOfMatcher) Matches(x interface{}) bool { + return reflect.TypeOf(x).AssignableTo(m.targetType) +} + +func (m assignableToTypeOfMatcher) String() string { + return "is assignable to " + m.targetType.Name() +} + +// Constructors +func Any() Matcher { return anyMatcher{} } +func Eq(x interface{}) Matcher { return eqMatcher{x} } +func Nil() Matcher { return nilMatcher{} } +func Not(x interface{}) Matcher { + if m, ok := x.(Matcher); ok { + return notMatcher{m} + } + return notMatcher{Eq(x)} +} + +// AssignableToTypeOf is a Matcher that matches if the parameter to the mock +// function is assignable to the type of the parameter to this function. +// +// Example usage: +// +// dbMock.EXPECT(). +// Insert(gomock.AssignableToTypeOf(&EmployeeRecord{})). +// Return(errors.New("DB error")) +// +func AssignableToTypeOf(x interface{}) Matcher { + return assignableToTypeOfMatcher{reflect.TypeOf(x)} +} diff --git a/vendor/github.com/golang/mock/mockgen/model/BUILD.bazel b/vendor/github.com/golang/mock/mockgen/model/BUILD.bazel new file mode 100644 index 00000000000..c7a5d928556 --- /dev/null +++ b/vendor/github.com/golang/mock/mockgen/model/BUILD.bazel @@ -0,0 +1,9 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["model.go"], + importmap = "sigs.k8s.io/cluster-api-provider-azure/vendor/github.com/golang/mock/mockgen/model", + importpath = "github.com/golang/mock/mockgen/model", + visibility = ["//visibility:public"], +) diff --git a/vendor/github.com/golang/mock/mockgen/model/model.go b/vendor/github.com/golang/mock/mockgen/model/model.go new file mode 100644 index 00000000000..1b6683dd8df --- /dev/null +++ b/vendor/github.com/golang/mock/mockgen/model/model.go @@ -0,0 +1,454 @@ +// Copyright 2012 Google Inc. +// +// 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 model contains the data model necessary for generating mock implementations. +package model + +import ( + "encoding/gob" + "fmt" + "io" + "reflect" + "strings" +) + +// pkgPath is the importable path for package model +const pkgPath = "github.com/golang/mock/mockgen/model" + +// Package is a Go package. It may be a subset. +type Package struct { + Name string + Interfaces []*Interface + DotImports []string +} + +func (pkg *Package) Print(w io.Writer) { + fmt.Fprintf(w, "package %s\n", pkg.Name) + for _, intf := range pkg.Interfaces { + intf.Print(w) + } +} + +// Imports returns the imports needed by the Package as a set of import paths. +func (pkg *Package) Imports() map[string]bool { + im := make(map[string]bool) + for _, intf := range pkg.Interfaces { + intf.addImports(im) + } + return im +} + +// Interface is a Go interface. +type Interface struct { + Name string + Methods []*Method +} + +func (intf *Interface) Print(w io.Writer) { + fmt.Fprintf(w, "interface %s\n", intf.Name) + for _, m := range intf.Methods { + m.Print(w) + } +} + +func (intf *Interface) addImports(im map[string]bool) { + for _, m := range intf.Methods { + m.addImports(im) + } +} + +// Method is a single method of an interface. +type Method struct { + Name string + In, Out []*Parameter + Variadic *Parameter // may be nil +} + +func (m *Method) Print(w io.Writer) { + fmt.Fprintf(w, " - method %s\n", m.Name) + if len(m.In) > 0 { + fmt.Fprintf(w, " in:\n") + for _, p := range m.In { + p.Print(w) + } + } + if m.Variadic != nil { + fmt.Fprintf(w, " ...:\n") + m.Variadic.Print(w) + } + if len(m.Out) > 0 { + fmt.Fprintf(w, " out:\n") + for _, p := range m.Out { + p.Print(w) + } + } +} + +func (m *Method) addImports(im map[string]bool) { + for _, p := range m.In { + p.Type.addImports(im) + } + if m.Variadic != nil { + m.Variadic.Type.addImports(im) + } + for _, p := range m.Out { + p.Type.addImports(im) + } +} + +// Parameter is an argument or return parameter of a method. +type Parameter struct { + Name string // may be empty + Type Type +} + +func (p *Parameter) Print(w io.Writer) { + n := p.Name + if n == "" { + n = `""` + } + fmt.Fprintf(w, " - %v: %v\n", n, p.Type.String(nil, "")) +} + +// Type is a Go type. +type Type interface { + String(pm map[string]string, pkgOverride string) string + addImports(im map[string]bool) +} + +func init() { + gob.Register(&ArrayType{}) + gob.Register(&ChanType{}) + gob.Register(&FuncType{}) + gob.Register(&MapType{}) + gob.Register(&NamedType{}) + gob.Register(&PointerType{}) + + // Call gob.RegisterName to make sure it has the consistent name registered + // for both gob decoder and encoder. + // + // For a non-pointer type, gob.Register will try to get package full path by + // calling rt.PkgPath() for a name to register. If your project has vendor + // directory, it is possible that PkgPath will get a path like this: + // ../../../vendor/github.com/golang/mock/mockgen/model + gob.RegisterName(pkgPath+".PredeclaredType", PredeclaredType("")) +} + +// ArrayType is an array or slice type. +type ArrayType struct { + Len int // -1 for slices, >= 0 for arrays + Type Type +} + +func (at *ArrayType) String(pm map[string]string, pkgOverride string) string { + s := "[]" + if at.Len > -1 { + s = fmt.Sprintf("[%d]", at.Len) + } + return s + at.Type.String(pm, pkgOverride) +} + +func (at *ArrayType) addImports(im map[string]bool) { at.Type.addImports(im) } + +// ChanType is a channel type. +type ChanType struct { + Dir ChanDir // 0, 1 or 2 + Type Type +} + +func (ct *ChanType) String(pm map[string]string, pkgOverride string) string { + s := ct.Type.String(pm, pkgOverride) + if ct.Dir == RecvDir { + return "<-chan " + s + } + if ct.Dir == SendDir { + return "chan<- " + s + } + return "chan " + s +} + +func (ct *ChanType) addImports(im map[string]bool) { ct.Type.addImports(im) } + +// ChanDir is a channel direction. +type ChanDir int + +const ( + RecvDir ChanDir = 1 + SendDir ChanDir = 2 +) + +// FuncType is a function type. +type FuncType struct { + In, Out []*Parameter + Variadic *Parameter // may be nil +} + +func (ft *FuncType) String(pm map[string]string, pkgOverride string) string { + args := make([]string, len(ft.In)) + for i, p := range ft.In { + args[i] = p.Type.String(pm, pkgOverride) + } + if ft.Variadic != nil { + args = append(args, "..."+ft.Variadic.Type.String(pm, pkgOverride)) + } + rets := make([]string, len(ft.Out)) + for i, p := range ft.Out { + rets[i] = p.Type.String(pm, pkgOverride) + } + retString := strings.Join(rets, ", ") + if nOut := len(ft.Out); nOut == 1 { + retString = " " + retString + } else if nOut > 1 { + retString = " (" + retString + ")" + } + return "func(" + strings.Join(args, ", ") + ")" + retString +} + +func (ft *FuncType) addImports(im map[string]bool) { + for _, p := range ft.In { + p.Type.addImports(im) + } + if ft.Variadic != nil { + ft.Variadic.Type.addImports(im) + } + for _, p := range ft.Out { + p.Type.addImports(im) + } +} + +// MapType is a map type. +type MapType struct { + Key, Value Type +} + +func (mt *MapType) String(pm map[string]string, pkgOverride string) string { + return "map[" + mt.Key.String(pm, pkgOverride) + "]" + mt.Value.String(pm, pkgOverride) +} + +func (mt *MapType) addImports(im map[string]bool) { + mt.Key.addImports(im) + mt.Value.addImports(im) +} + +// NamedType is an exported type in a package. +type NamedType struct { + Package string // may be empty + Type string // TODO: should this be typed Type? +} + +func (nt *NamedType) String(pm map[string]string, pkgOverride string) string { + // TODO: is this right? + if pkgOverride == nt.Package { + return nt.Type + } + prefix := pm[nt.Package] + if prefix != "" { + return prefix + "." + nt.Type + } else { + return nt.Type + } +} +func (nt *NamedType) addImports(im map[string]bool) { + if nt.Package != "" { + im[nt.Package] = true + } +} + +// PointerType is a pointer to another type. +type PointerType struct { + Type Type +} + +func (pt *PointerType) String(pm map[string]string, pkgOverride string) string { + return "*" + pt.Type.String(pm, pkgOverride) +} +func (pt *PointerType) addImports(im map[string]bool) { pt.Type.addImports(im) } + +// PredeclaredType is a predeclared type such as "int". +type PredeclaredType string + +func (pt PredeclaredType) String(pm map[string]string, pkgOverride string) string { return string(pt) } +func (pt PredeclaredType) addImports(im map[string]bool) {} + +// The following code is intended to be called by the program generated by ../reflect.go. + +func InterfaceFromInterfaceType(it reflect.Type) (*Interface, error) { + if it.Kind() != reflect.Interface { + return nil, fmt.Errorf("%v is not an interface", it) + } + intf := &Interface{} + + for i := 0; i < it.NumMethod(); i++ { + mt := it.Method(i) + // TODO: need to skip unexported methods? or just raise an error? + m := &Method{ + Name: mt.Name, + } + + var err error + m.In, m.Variadic, m.Out, err = funcArgsFromType(mt.Type) + if err != nil { + return nil, err + } + + intf.Methods = append(intf.Methods, m) + } + + return intf, nil +} + +// t's Kind must be a reflect.Func. +func funcArgsFromType(t reflect.Type) (in []*Parameter, variadic *Parameter, out []*Parameter, err error) { + nin := t.NumIn() + if t.IsVariadic() { + nin-- + } + var p *Parameter + for i := 0; i < nin; i++ { + p, err = parameterFromType(t.In(i)) + if err != nil { + return + } + in = append(in, p) + } + if t.IsVariadic() { + p, err = parameterFromType(t.In(nin).Elem()) + if err != nil { + return + } + variadic = p + } + for i := 0; i < t.NumOut(); i++ { + p, err = parameterFromType(t.Out(i)) + if err != nil { + return + } + out = append(out, p) + } + return +} + +func parameterFromType(t reflect.Type) (*Parameter, error) { + tt, err := typeFromType(t) + if err != nil { + return nil, err + } + return &Parameter{Type: tt}, nil +} + +var errorType = reflect.TypeOf((*error)(nil)).Elem() + +var byteType = reflect.TypeOf(byte(0)) + +func typeFromType(t reflect.Type) (Type, error) { + // Hack workaround for https://golang.org/issue/3853. + // This explicit check should not be necessary. + if t == byteType { + return PredeclaredType("byte"), nil + } + + if imp := t.PkgPath(); imp != "" { + // PkgPath might return a path that includes "vendor" + // These paths do not compile, so we need to remove everything + // up to and including "/vendor/" + // see https://github.com/golang/go/issues/12019 + if i := strings.LastIndex(imp, "/vendor/"); i != -1 { + imp = imp[i+len("/vendor/"):] + } + return &NamedType{ + Package: imp, + Type: t.Name(), + }, nil + } + + // only unnamed or predeclared types after here + + // Lots of types have element types. Let's do the parsing and error checking for all of them. + var elemType Type + switch t.Kind() { + case reflect.Array, reflect.Chan, reflect.Map, reflect.Ptr, reflect.Slice: + var err error + elemType, err = typeFromType(t.Elem()) + if err != nil { + return nil, err + } + } + + switch t.Kind() { + case reflect.Array: + return &ArrayType{ + Len: t.Len(), + Type: elemType, + }, nil + case reflect.Bool, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, + reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128, reflect.String: + return PredeclaredType(t.Kind().String()), nil + case reflect.Chan: + var dir ChanDir + switch t.ChanDir() { + case reflect.RecvDir: + dir = RecvDir + case reflect.SendDir: + dir = SendDir + } + return &ChanType{ + Dir: dir, + Type: elemType, + }, nil + case reflect.Func: + in, variadic, out, err := funcArgsFromType(t) + if err != nil { + return nil, err + } + return &FuncType{ + In: in, + Out: out, + Variadic: variadic, + }, nil + case reflect.Interface: + // Two special interfaces. + if t.NumMethod() == 0 { + return PredeclaredType("interface{}"), nil + } + if t == errorType { + return PredeclaredType("error"), nil + } + case reflect.Map: + kt, err := typeFromType(t.Key()) + if err != nil { + return nil, err + } + return &MapType{ + Key: kt, + Value: elemType, + }, nil + case reflect.Ptr: + return &PointerType{ + Type: elemType, + }, nil + case reflect.Slice: + return &ArrayType{ + Len: -1, + Type: elemType, + }, nil + case reflect.Struct: + if t.NumField() == 0 { + return PredeclaredType("struct{}"), nil + } + } + + // TODO: Struct, UnsafePointer + return nil, fmt.Errorf("can't yet turn %v (%v) into a model.Type", t, t.Kind()) +}