Skip to content

Commit

Permalink
fix examples/ compilation so that test/ also compiles
Browse files Browse the repository at this point in the history
fix network-tester cauldron serve_hostnames
  • Loading branch information
mikedanese committed Dec 12, 2016
1 parent c87de85 commit 82d9ed7
Show file tree
Hide file tree
Showing 25 changed files with 230 additions and 61 deletions.
3 changes: 2 additions & 1 deletion .gazelcfg.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"./third_party",
"./plugin",
"./test",
"./federation"
"./federation",
"./examples"
]
}
39 changes: 39 additions & 0 deletions examples/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package(default_visibility = ["//visibility:public"])

licenses(["notice"])

load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)

filegroup(
name = "config",
srcs = glob([
Expand All @@ -17,3 +25,34 @@ filegroup(
"**/*",
]),
)

go_library(
name = "go_default_library",
srcs = ["doc.go"],
tags = ["automanaged"],
)

go_test(
name = "go_default_xtest",
srcs = ["examples_test.go"],
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
"//pkg/api/testapi:go_default_library",
"//pkg/api/validation:go_default_library",
"//pkg/apis/apps:go_default_library",
"//pkg/apis/apps/validation:go_default_library",
"//pkg/apis/batch:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//pkg/apis/extensions/validation:go_default_library",
"//pkg/capabilities:go_default_library",
"//pkg/registry/batch/job:go_default_library",
"//pkg/runtime:go_default_library",
"//pkg/types:go_default_library",
"//pkg/util/validation/field:go_default_library",
"//pkg/util/yaml:go_default_library",
"//plugin/pkg/scheduler/api:go_default_library",
"//plugin/pkg/scheduler/api/latest:go_default_library",
"//vendor:github.com/golang/glog",
],
)
31 changes: 31 additions & 0 deletions examples/apiserver/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package(default_visibility = ["//visibility:public"])

licenses(["notice"])

load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)

go_library(
name = "go_default_library",
srcs = ["apiserver.go"],
tags = ["automanaged"],
deps = [
"//cmd/libs/go2idl/client-gen/test_apis/testgroup/install:go_default_library",
"//cmd/libs/go2idl/client-gen/test_apis/testgroup/v1:go_default_library",
"//examples/apiserver/rest:go_default_library",
"//pkg/api:go_default_library",
"//pkg/api/rest:go_default_library",
"//pkg/apimachinery/registered:go_default_library",
"//pkg/genericapiserver:go_default_library",
"//pkg/genericapiserver/authorizer:go_default_library",
"//pkg/genericapiserver/options:go_default_library",
"//pkg/genericapiserver/validation:go_default_library",
"//pkg/registry/generic:go_default_library",
"//pkg/runtime/schema:go_default_library",
"//pkg/storage/storagebackend:go_default_library",
"//pkg/util/errors:go_default_library",
"//vendor:github.com/golang/glog",
],
)
25 changes: 25 additions & 0 deletions examples/apiserver/rest/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package(default_visibility = ["//visibility:public"])

licenses(["notice"])

load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)

go_library(
name = "go_default_library",
srcs = ["reststorage.go"],
tags = ["automanaged"],
deps = [
"//cmd/libs/go2idl/client-gen/test_apis/testgroup:go_default_library",
"//pkg/api:go_default_library",
"//pkg/fields:go_default_library",
"//pkg/labels:go_default_library",
"//pkg/registry/generic:go_default_library",
"//pkg/registry/generic/registry:go_default_library",
"//pkg/runtime:go_default_library",
"//pkg/storage:go_default_library",
"//pkg/util/validation/field:go_default_library",
],
)
21 changes: 21 additions & 0 deletions examples/apiserver/server/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package(default_visibility = ["//visibility:public"])

licenses(["notice"])

load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
)

go_binary(
name = "server",
srcs = ["main.go"],
tags = ["automanaged"],
deps = [
"//examples/apiserver:go_default_library",
"//pkg/util/flag:go_default_library",
"//pkg/util/wait:go_default_library",
"//vendor:github.com/golang/glog",
"//vendor:github.com/spf13/pflag",
],
)
15 changes: 15 additions & 0 deletions examples/explorer/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package(default_visibility = ["//visibility:public"])

licenses(["notice"])

load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
)

go_binary(
name = "explorer",
srcs = ["explorer.go"],
tags = ["automanaged"],
deps = ["//vendor:github.com/davecgh/go-spew/spew"],
)
1 change: 1 addition & 0 deletions examples/guestbook-go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
guestbook_bin
19 changes: 19 additions & 0 deletions examples/guestbook-go/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package(default_visibility = ["//visibility:public"])

licenses(["notice"])

load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
)

go_binary(
name = "guestbook-go",
srcs = ["main.go"],
tags = ["automanaged"],
deps = [
"//vendor:github.com/codegangsta/negroni",
"//vendor:github.com/gorilla/mux",
"//vendor:github.com/xyproto/simpleredis",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

FROM busybox:ubuntu-14.04

ADD ./bin/guestbook /app/guestbook
ADD ./_src/public/index.html /app/public/index.html
ADD ./_src/public/script.js /app/public/script.js
ADD ./_src/public/style.css /app/public/style.css
ADD ./guestbook_bin /app/guestbook
ADD ./public/index.html /app/public/index.html
ADD ./public/script.js /app/public/script.js
ADD ./public/style.css /app/public/style.css

WORKDIR /app
CMD ["./guestbook"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ release: clean build push clean

# builds a docker image that builds the app and packages it into a minimal docker image
build:
@cp ../../bazel-bin/examples/guestbook-go/guestbook-go guestbook_bin
docker build --rm --force-rm -t ${REGISTRY}/guestbook-builder .
docker run --rm ${REGISTRY}/guestbook-builder | docker build -t "${REGISTRY}/guestbook:${VERSION}" -

Expand All @@ -32,6 +33,7 @@ push:

# remove previous images and containers
clean:
rm -f guestbook_bin
docker rm -f ${REGISTRY}/guestbook-builder 2> /dev/null || true
docker rmi -f ${REGISTRY}/guestbook-builder || true
docker rmi -f "${REGISTRY}/guestbook:${VERSION}" || true
Expand Down
23 changes: 0 additions & 23 deletions examples/guestbook-go/_src/Dockerfile

This file was deleted.

25 changes: 0 additions & 25 deletions examples/guestbook-go/_src/README.md

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions examples/https-nginx/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package(default_visibility = ["//visibility:public"])

licenses(["notice"])

load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
)

go_binary(
name = "https-nginx",
srcs = ["make_secret.go"],
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
"//pkg/api/install:go_default_library",
"//pkg/apimachinery/registered:go_default_library",
"//pkg/runtime:go_default_library",
],
)
19 changes: 19 additions & 0 deletions examples/k8petstore/web-server/src/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package(default_visibility = ["//visibility:public"])

licenses(["notice"])

load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
)

go_binary(
name = "src",
srcs = ["main.go"],
tags = ["automanaged"],
deps = [
"//vendor:github.com/codegangsta/negroni",
"//vendor:github.com/gorilla/mux",
"//vendor:github.com/xyproto/simpleredis",
],
)
19 changes: 19 additions & 0 deletions examples/sharing-clusters/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package(default_visibility = ["//visibility:public"])

licenses(["notice"])

load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
)

go_binary(
name = "sharing-clusters",
srcs = ["make_secret.go"],
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
"//pkg/apimachinery/registered:go_default_library",
"//pkg/runtime:go_default_library",
],
)
4 changes: 2 additions & 2 deletions test/e2e/generated/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ genrule(
],
outs = ["bindata.go"],
cmd = """
$(location //vendor:github.com/jteeuwen/go-bindata/go-bindata) \
$(location //vendor:github.com/jteeuwen/go-bindata/go-bindata_bin) \
-nometadata -o "$(OUTS)" -pkg generated \
-prefix $$(pwd) \
-ignore .jpg -ignore .png -ignore .md \
$(SRCS)
""",
tools = [
"//vendor:github.com/jteeuwen/go-bindata/go-bindata",
"//vendor:github.com/jteeuwen/go-bindata/go-bindata_bin",
],
)
1 change: 1 addition & 0 deletions test/images/network-tester/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ go_binary(
srcs = ["webserver.go"],
tags = ["automanaged"],
deps = [
"//pkg/apis/meta/v1:go_default_library",
"//pkg/client/clientset_generated/internalclientset:go_default_library",
"//pkg/client/restclient:go_default_library",
"//pkg/util/sets:go_default_library",
Expand Down
3 changes: 2 additions & 1 deletion test/images/network-tester/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"syscall"
"time"

v1 "k8s.io/kubernetes/pkg/apis/meta/v1"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/util/sets"
Expand Down Expand Up @@ -268,7 +269,7 @@ func contactOthers(state *State) {

//getWebserverEndpoints returns the webserver endpoints as a set of String, each in the format like "http://{ip}:{port}"
func getWebserverEndpoints(client clientset.Interface) sets.String {
endpoints, err := client.Core().Endpoints(*namespace).Get(*service)
endpoints, err := client.Core().Endpoints(*namespace).Get(*service, v1.GetOptions{})
eps := sets.String{}
if err != nil {
state.Logf("Unable to read the endpoints for %v/%v: %v.", *namespace, *service, err)
Expand Down
1 change: 1 addition & 0 deletions test/soak/cauldron/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ go_binary(
deps = [
"//pkg/api:go_default_library",
"//pkg/api/errors:go_default_library",
"//pkg/apis/meta/v1:go_default_library",
"//pkg/client/clientset_generated/internalclientset:go_default_library",
"//pkg/client/restclient:go_default_library",
"//pkg/util/intstr:go_default_library",
Expand Down
5 changes: 3 additions & 2 deletions test/soak/cauldron/cauldron.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
v1 "k8s.io/kubernetes/pkg/apis/meta/v1"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/util/intstr"
Expand Down Expand Up @@ -105,7 +106,7 @@ func main() {
} else {
// wait until the namespace disappears
for i := 0; i < int(namespaceDeleteTimeout/time.Second); i++ {
if _, err := client.Core().Namespaces().Get(ns); err != nil {
if _, err := client.Core().Namespaces().Get(ns, v1.GetOptions{}); err != nil {
if errors.IsNotFound(err) {
return
}
Expand Down Expand Up @@ -220,7 +221,7 @@ func main() {
for _, podName := range podNames {
var pod *api.Pod
for start := time.Now(); time.Since(start) < podStartTimeout; time.Sleep(5 * time.Second) {
pod, err = client.Core().Pods(ns).Get(podName)
pod, err = client.Core().Pods(ns).Get(podName, v1.GetOptions{})
if err != nil {
glog.Warningf("Get pod %s/%s failed, ignoring for %v: %v", ns, podName, err, podStartTimeout)
continue
Expand Down
Loading

0 comments on commit 82d9ed7

Please sign in to comment.