Skip to content

Commit 08ac1b3

Browse files
justaugustusk8s-ci-robot
authored andcommitted
Add mock interfaces (#182)
Signed-off-by: Stephen Augustus <[email protected]>
1 parent 0345fdf commit 08ac1b3

File tree

84 files changed

+5480
-888
lines changed

Some content is hidden

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

84 files changed

+5480
-888
lines changed

Gopkg.lock

Lines changed: 20 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
# unused-packages = true
2626

2727
required = [
28+
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/computeapi",
29+
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network/networkapi",
30+
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/resourcesapi",
31+
"github.com/Azure/go-autorest/autorest",
32+
"github.com/golang/mock/gomock",
33+
"github.com/golang/mock/mockgen/model",
2834
"github.com/emicklei/go-restful",
2935
"github.com/onsi/ginkgo", # for test framework
3036
"github.com/onsi/gomega", # for test matchers

Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,25 @@ dep-ensure: check-install ## Ensure dependencies are up to date
160160
gazelle: ## Run Bazel Gazelle
161161
bazel run //:gazelle $(BAZEL_ARGS)
162162

163-
# TODO: Uncomment mock generation once mocks exist
164163
.PHONY: generate
165164
generate: ## Generate mocks, CRDs and runs `go generate` through Bazel
166165
GOPATH=$(shell go env GOPATH) bazel run //:generate $(BAZEL_ARGS)
167166
$(MAKE) dep-ensure
167+
bazel build $(BAZEL_ARGS) //pkg/cloud/azure/mocks:mocks \
168+
//pkg/cloud/azure/services/availabilityzones/mock_availabilityzones:mocks \
169+
//pkg/cloud/azure/services/groups/mock_groups:mocks \
170+
//pkg/cloud/azure/services/internalloadbalancers/mock_internalloadbalancers:mocks \
171+
//pkg/cloud/azure/services/networkinterfaces/mock_networkinterfaces:mocks \
172+
//pkg/cloud/azure/services/publicips/mock_publicips:mocks \
173+
//pkg/cloud/azure/services/publicloadbalancers/mock_publicloadbalancers:mocks \
174+
//pkg/cloud/azure/services/routetables/mock_routetables:mocks \
175+
//pkg/cloud/azure/services/securitygroups/mock_securitygroups:mocks \
176+
//pkg/cloud/azure/services/subnets/mock_subnets:mocks \
177+
//pkg/cloud/azure/services/virtualmachineextensions/mock_virtualmachineextensions:mocks \
178+
//pkg/cloud/azure/services/virtualmachines/mock_virtualmachines:mocks \
179+
//pkg/cloud/azure/services/virtualnetworks/mock_virtualnetworks:mocks
180+
./hack/copy-bazel-mocks.sh
168181
$(MAKE) generate-deepcopy
169-
# bazel build $(BAZEL_ARGS) //pkg/cloud/azure/services/mocks:go_mock_interfaces \
170-
# //pkg/cloud/azure/services/ec2/mock_ec2iface:go_default_library \
171-
# //pkg/cloud/azure/services/elb/mock_elbiface:go_default_library
172-
# cp -Rf bazel-genfiles/pkg/* pkg/
173182
$(MAKE) generate-crds
174183

175184
.PHONY: generate-deepcopy

WORKSPACE

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
16-
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
1716

1817
http_archive(
1918
name = "io_bazel_rules_go",
@@ -96,6 +95,12 @@ go_repository(
9695
tag = "v1.2.0",
9796
)
9897

98+
go_repository(
99+
name = "bazel_gomock",
100+
commit = "08cc809a2f68f6d810c2013987970a9a5c1181b4",
101+
importpath = "github.com/jmhodges/bazel_gomock",
102+
)
103+
99104
go_repository(
100105
name = "io_k8s_sigs_kind",
101106
commit = "161151a26faf0dbe962ac9f323cc0cdebac79ba8",

build/asmshim/BUILD

Lines changed: 0 additions & 14 deletions
This file was deleted.

build/asmshim/c.go

Lines changed: 0 additions & 21 deletions
This file was deleted.

build/asmshim/textflag.h

Lines changed: 0 additions & 34 deletions
This file was deleted.

build/go_mock.bzl

Lines changed: 0 additions & 91 deletions
This file was deleted.

hack/copy-bazel-mocks.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2019 The Kubernetes Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -o errexit
17+
set -o nounset
18+
set -o pipefail
19+
20+
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
21+
cd "${REPO_ROOT}" || exit 1
22+
23+
BOILERPLATE=$(sed "s/YEAR/$(date +%Y)/g" < hack/boilerplate/boilerplate.go.txt)
24+
25+
while IFS= read -r -d '' file
26+
do
27+
out=$(echo "${file}" | sed "s#bazel-bin/##g")
28+
echo -e "${BOILERPLATE}\n" > "${out}"
29+
cat "${file}" >> "${out}"
30+
done < <(find bazel-bin/pkg -name '*_mock.go' -type f -print0)

pkg/apis/azureprovider/v1alpha1/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ import (
2323
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2424
)
2525

26+
// ResourceSpec defines a generic spec that can used to define Azure resources.
27+
// TODO: ResourceSpec should be removed once concrete specs have been defined for all Azure resources in use.
28+
type ResourceSpec interface{}
29+
2630
// TODO: Write type tests
2731

2832
// AzureResourceReference is a reference to a specific Azure resource by ID

0 commit comments

Comments
 (0)