diff --git a/.gitignore b/.gitignore index 8affaf3096..d70076c038 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,9 @@ hack/deployer/config/deployer-config.yml # ignore CI config files deployer-config.yml .env + +# ignore test output +integration-tests.json +integration-tests.xml +unit-tests.json +unit-tests.xml diff --git a/.golangci.yml b/.golangci.yml index 419e66cde9..b1ebd6a520 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -8,6 +8,7 @@ linters: enable-all: true disable: - dupl + - funlen - gochecknoglobals - gochecknoinits - interfacer diff --git a/Dockerfile b/Dockerfile index efc1cf4cb9..ac0d2df7c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,16 @@ # Build the manager binary -FROM golang:1.11 as builder +FROM golang:1.13 as builder -# Copy in the go src WORKDIR /go/src/github.com/elastic/cloud-on-k8s +COPY go.mod go.mod +COPY go.sum go.sum +# cache deps before building and copying source so that we don't need to re-download as much +# and so that source changes don't invalidate our downloaded layer +RUN go mod download + +# Copy the go source COPY pkg/ pkg/ COPY cmd/ cmd/ -COPY vendor/ vendor/ ARG GO_LDFLAGS ARG GO_TAGS diff --git a/Gopkg.lock b/Gopkg.lock index 22661bfc14..d181249591 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -33,14 +33,6 @@ revision = "258b00ffa7318e8b109a141349980ffbd30a35db" version = "v2.20.0" -[[projects]] - digest = "1:464aef731a5f82ded547c62e249a2e9ec59fbbc9ddab53cda7b9857852630a61" - name = "github.com/appscode/jsonpatch" - packages = ["."] - pruneopts = "T" - revision = "7c0e3b262f30165a8ec3d0b4c6059fd92703bfb2" - version = "1.0.0" - [[projects]] branch = "master" digest = "1:ad4589ec239820ee99eb01c1ad47ebc5f8e02c4f5103a9b210adff9696d89f36" @@ -100,6 +92,14 @@ revision = "72bf35d0ff611848c1dc9df0f976c81192392fa5" version = "v4.1.0" +[[projects]] + digest = "1:865079840386857c809b72ce300be7580cb50d3d3129ce11bf9aa6ca2bc1934a" + name = "github.com/fatih/color" + packages = ["."] + pruneopts = "T" + revision = "5b77d2a35fb0ede96d138fc9a99f5c9b6aef11b4" + version = "v1.7.0" + [[projects]] digest = "1:7fc160b460a6fc506b37fcca68332464c3f2cd57b6e3f111f26c5bbfd2d5518e" name = "github.com/fsnotify/fsnotify" @@ -141,12 +141,12 @@ version = "v1.0.1" [[projects]] - digest = "1:3e34b0a53d651b06655475eb488745c912596e08557a33b83d336aab41cb6fe9" - name = "github.com/gobuffalo/envy" + digest = "1:f6ca5975d71edbb975eb76351e919b5d001bd4061e81a82e8b10299b113c3e98" + name = "github.com/gobuffalo/flect" packages = ["."] pruneopts = "T" - revision = "801d7253ade1f895f74596b9a96147ed2d3b087e" - version = "v1.6.11" + revision = "86360480338dcc8c7b61de28a928595f77079989" + version = "v0.1.6" [[projects]] digest = "1:f5ccd717b5f093cbabc51ee2e7a5979b92f17d217f9031d6d64f337101c408e4" @@ -189,14 +189,6 @@ revision = "2a8bb927dd31d8daada140a5d09578521ce5c36a" version = "v0.0.1" -[[projects]] - branch = "master" - digest = "1:0bfbe13936953a98ae3cfe8ed6670d396ad81edf069a806d2f6515d7bb6950df" - name = "github.com/google/btree" - packages = ["."] - pruneopts = "T" - revision = "4030bb1f1f0c35b30ca7009e9ebd06849dd45306" - [[projects]] branch = "master" digest = "1:3ee90c0d94da31b442dde97c99635aaafec68d0b8a3c12ee2075c6bdabeec6bb" @@ -225,17 +217,6 @@ revision = "7c663266750e7d82587642f65e60bc4083f1f84e" version = "v0.2.0" -[[projects]] - branch = "master" - digest = "1:8c0ceab65d43f49dce22aac0e8f670c170fc74dcf2dfba66d3a89516f7ae2c15" - name = "github.com/gregjones/httpcache" - packages = [ - ".", - "diskcache", - ] - pruneopts = "T" - revision = "c63ab54fda8f77302f8d414e19933f2b6026a089" - [[projects]] digest = "1:0ade334594e69404d80d9d323445d2297ff8161637f9b2d347cc6973d2d6f05b" name = "github.com/hashicorp/errwrap" @@ -368,14 +349,6 @@ revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" -[[projects]] - digest = "1:ee5840274624ad20cac08227aeca582fbdaf3727ef9dd37ae935706240679e09" - name = "github.com/joho/godotenv" - packages = ["."] - pruneopts = "T" - revision = "23d116af351c84513e1946b527c88823e476be13" - version = "v1.3.0" - [[projects]] digest = "1:5d713dbcad44f3358fec51fd5573d4f733c02cac5a40dcb177787ad5ffe9272f" name = "github.com/json-iterator/go" @@ -396,12 +369,20 @@ version = "v1.8.0" [[projects]] - digest = "1:3804a3a02964db8e6db3e5e7960ac1c1a9b12835642dd4f4ac4e56c749ec73eb" - name = "github.com/markbates/inflect" + digest = "1:b168836ecd85a2d138391dbc464d2442ea9400c29cc0636f2c6056b996692e29" + name = "github.com/mattn/go-colorable" + packages = ["."] + pruneopts = "T" + revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072" + version = "v0.0.9" + +[[projects]] + digest = "1:4179033b21c4a209f2b0325cd63c254e84a619b859f00829f550896ef8ce17b6" + name = "github.com/mattn/go-isatty" packages = ["."] pruneopts = "T" - revision = "24b83195037b3bc61fcda2d28b7b0518bce293b6" - version = "v1.0.4" + revision = "e1f7b56ace729e4a73a29a6b4fac6cd5fcda7ab3" + version = "v0.0.9" [[projects]] digest = "1:a8e3d14801bed585908d130ebfc3b925ba642208e6f30d879437ddfc7bb9b413" @@ -509,22 +490,6 @@ revision = "c01d1270ff3e442a8a57cddc1c92dc1138598194" version = "v1.2.0" -[[projects]] - branch = "master" - digest = "1:0c29d499ffc3b9f33e7136444575527d0c3a9463a89b3cbeda0523b737f910b3" - name = "github.com/petar/GoLLRB" - packages = ["llrb"] - pruneopts = "T" - revision = "53be0d36a84c2a886ca057d34b6aa4468df9ccb4" - -[[projects]] - digest = "1:598241bd36d3a5f6d9102a306bd9bf78f3bc253672460d92ac70566157eae648" - name = "github.com/peterbourgon/diskv" - packages = ["."] - pruneopts = "T" - revision = "5f041e8faa004a95c88a202771f4cc3e991971e6" - version = "v2.0.1" - [[projects]] digest = "1:6f63e3870088f391da9a988fa1459cd0665fb07a4f8889d7b8266e9f345d61d7" name = "github.com/pierrec/lz4" @@ -597,18 +562,6 @@ pruneopts = "T" revision = "1dc9a6cbc91aacc3e8b2d63db4d2e957a5394ac4" -[[projects]] - digest = "1:fac620096bacf6e41b3beb93ff03af9fe545d77421b3e7320f114b2da2e10824" - name = "github.com/rogpeppe/go-internal" - packages = [ - "modfile", - "module", - "semver", - ] - pruneopts = "T" - revision = "d87f08a7d80821c797ffc8eb8f4e01675f378736" - version = "v1.0.0" - [[projects]] digest = "1:6baa565fe16f8657cf93469b2b8a6c61a277827734400d27e44d589547297279" name = "github.com/ryanuber/go-glob" @@ -831,6 +784,14 @@ pruneopts = "T" revision = "3c39ce7b61056afe4473b651789da5f89d4aeb20" +[[projects]] + digest = "1:7c65747ea6380bd254afcf806cc06be1d1a9de73ee7ce6e896127f54e1ee10fe" + name = "gomodules.xyz/jsonpatch" + packages = ["v2"] + pruneopts = "T" + revision = "e8422f09d27ee2c8cfb2c7f8089eb9eeb0764849" + version = "v2.0.1" + [[projects]] digest = "1:fb4ee7f835110d238c58366cfa442da7dfa62cec87d42da2d8049000f4330758" name = "google.golang.org/appengine" @@ -897,11 +858,18 @@ version = "v2.2.2" [[projects]] - digest = "1:a8dd0f5c1137ed558bca1fed6617b019aa645783731d15138abc6f184952fef5" + branch = "v3" + digest = "1:698122d666025ff02316a3ca307e35b9889fa54789d617718fbff3264fd34663" + name = "gopkg.in/yaml.v3" + packages = ["."] + pruneopts = "T" + revision = "827449938966de02e59eecfd53d81305d5a5f78a" + +[[projects]] + digest = "1:bbd4fd8b2a8a552b0c8ac509c3993c83c22897804bb262ae176e6bd202ab9f6b" name = "k8s.io/api" packages = [ "admission/v1beta1", - "admissionregistration/v1alpha1", "admissionregistration/v1beta1", "apps/v1", "apps/v1beta1", @@ -918,15 +886,20 @@ "batch/v1beta1", "batch/v2alpha1", "certificates/v1beta1", + "coordination/v1", "coordination/v1beta1", "core/v1", "events/v1beta1", "extensions/v1beta1", "networking/v1", + "networking/v1beta1", + "node/v1alpha1", + "node/v1beta1", "policy/v1beta1", "rbac/v1", "rbac/v1alpha1", "rbac/v1beta1", + "scheduling/v1", "scheduling/v1alpha1", "scheduling/v1beta1", "settings/v1alpha1", @@ -935,11 +908,11 @@ "storage/v1beta1", ] pruneopts = "T" - revision = "05914d821849570fba9eacfb29466f2d8d3cd229" - version = "kubernetes-1.13.1" + revision = "6e4e0e4f393bf5e8bbff570acd13217aa5a770cd" + version = "kubernetes-1.14.1" [[projects]] - digest = "1:d6b5f1f23ca1b4a68aacbe3167fdd56babaf4b0a72b5d0c166595cee4b71532d" + digest = "1:1f6bc48bbe26c234a28657428a6c8e8ab54d370b87ffafb192192d516a9877e8" name = "k8s.io/apiextensions-apiserver" packages = [ "pkg/apis/apiextensions", @@ -949,19 +922,22 @@ "pkg/client/clientset/clientset/typed/apiextensions/v1beta1", ] pruneopts = "T" - revision = "0fe22c71c47604641d9aa352c785b7912c200562" - version = "kubernetes-1.13.1" + revision = "727a075fdec8319bf095330e344b3ccc668abc73" + version = "kubernetes-1.14.1" [[projects]] - digest = "1:6326c0acd4934569b53d305d4a79a30f7074b3d4fdb3537af06203b68297a22b" + digest = "1:e0ec21060953ced38018fae667796890cd67dac80f969eec1634ff5ecfcf59a8" name = "k8s.io/apimachinery" packages = [ + "pkg/api/equality", "pkg/api/errors", "pkg/api/meta", "pkg/api/resource", + "pkg/api/validation", "pkg/apis/meta/internalversion", "pkg/apis/meta/v1", "pkg/apis/meta/v1/unstructured", + "pkg/apis/meta/v1/validation", "pkg/apis/meta/v1beta1", "pkg/conversion", "pkg/conversion/queryparams", @@ -1007,11 +983,11 @@ "third_party/forked/golang/reflect", ] pruneopts = "T" - revision = "2b1284ed4c93a43499e781493253e2ac5959c4fd" - version = "kubernetes-1.13.1" + revision = "6a84e37a896db9780c75367af8d2ed2bb944022e" + version = "kubernetes-1.14.1" [[projects]] - digest = "1:0b3ba6818a03b0f0f181ab6b88d9be03789d02ede8929d876f45210471811fdb" + digest = "1:8574daaa2a4643b60706a37e73d304caca2c48f5076b0ab35f694730f98b235e" name = "k8s.io/client-go" packages = [ "discovery", @@ -1019,7 +995,6 @@ "dynamic", "informers", "informers/admissionregistration", - "informers/admissionregistration/v1alpha1", "informers/admissionregistration/v1beta1", "informers/apps", "informers/apps/v1", @@ -1038,6 +1013,7 @@ "informers/certificates", "informers/certificates/v1beta1", "informers/coordination", + "informers/coordination/v1", "informers/coordination/v1beta1", "informers/core", "informers/core/v1", @@ -1048,6 +1024,10 @@ "informers/internalinterfaces", "informers/networking", "informers/networking/v1", + "informers/networking/v1beta1", + "informers/node", + "informers/node/v1alpha1", + "informers/node/v1beta1", "informers/policy", "informers/policy/v1beta1", "informers/rbac", @@ -1055,6 +1035,7 @@ "informers/rbac/v1alpha1", "informers/rbac/v1beta1", "informers/scheduling", + "informers/scheduling/v1", "informers/scheduling/v1alpha1", "informers/scheduling/v1beta1", "informers/settings", @@ -1066,8 +1047,6 @@ "kubernetes", "kubernetes/fake", "kubernetes/scheme", - "kubernetes/typed/admissionregistration/v1alpha1", - "kubernetes/typed/admissionregistration/v1alpha1/fake", "kubernetes/typed/admissionregistration/v1beta1", "kubernetes/typed/admissionregistration/v1beta1/fake", "kubernetes/typed/apps/v1", @@ -1100,6 +1079,8 @@ "kubernetes/typed/batch/v2alpha1/fake", "kubernetes/typed/certificates/v1beta1", "kubernetes/typed/certificates/v1beta1/fake", + "kubernetes/typed/coordination/v1", + "kubernetes/typed/coordination/v1/fake", "kubernetes/typed/coordination/v1beta1", "kubernetes/typed/coordination/v1beta1/fake", "kubernetes/typed/core/v1", @@ -1110,6 +1091,12 @@ "kubernetes/typed/extensions/v1beta1/fake", "kubernetes/typed/networking/v1", "kubernetes/typed/networking/v1/fake", + "kubernetes/typed/networking/v1beta1", + "kubernetes/typed/networking/v1beta1/fake", + "kubernetes/typed/node/v1alpha1", + "kubernetes/typed/node/v1alpha1/fake", + "kubernetes/typed/node/v1beta1", + "kubernetes/typed/node/v1beta1/fake", "kubernetes/typed/policy/v1beta1", "kubernetes/typed/policy/v1beta1/fake", "kubernetes/typed/rbac/v1", @@ -1118,6 +1105,8 @@ "kubernetes/typed/rbac/v1alpha1/fake", "kubernetes/typed/rbac/v1beta1", "kubernetes/typed/rbac/v1beta1/fake", + "kubernetes/typed/scheduling/v1", + "kubernetes/typed/scheduling/v1/fake", "kubernetes/typed/scheduling/v1alpha1", "kubernetes/typed/scheduling/v1alpha1/fake", "kubernetes/typed/scheduling/v1beta1", @@ -1130,7 +1119,6 @@ "kubernetes/typed/storage/v1alpha1/fake", "kubernetes/typed/storage/v1beta1", "kubernetes/typed/storage/v1beta1/fake", - "listers/admissionregistration/v1alpha1", "listers/admissionregistration/v1beta1", "listers/apps/v1", "listers/apps/v1beta1", @@ -1143,15 +1131,20 @@ "listers/batch/v1beta1", "listers/batch/v2alpha1", "listers/certificates/v1beta1", + "listers/coordination/v1", "listers/coordination/v1beta1", "listers/core/v1", "listers/events/v1beta1", "listers/extensions/v1beta1", "listers/networking/v1", + "listers/networking/v1beta1", + "listers/node/v1alpha1", + "listers/node/v1beta1", "listers/policy/v1beta1", "listers/rbac/v1", "listers/rbac/v1alpha1", "listers/rbac/v1beta1", + "listers/scheduling/v1", "listers/scheduling/v1alpha1", "listers/scheduling/v1beta1", "listers/settings/v1alpha1", @@ -1181,24 +1174,24 @@ "tools/pager", "tools/portforward", "tools/record", + "tools/record/util", "tools/reference", "tools/remotecommand", "transport", "transport/spdy", - "util/buffer", "util/cert", "util/connrotation", "util/exec", "util/flowcontrol", "util/homedir", - "util/integer", "util/jsonpath", + "util/keyutil", "util/retry", "util/workqueue", ] pruneopts = "T" - revision = "8d9ed539ba3134352c586810e749e58df4e94e4f" - version = "kubernetes-1.13.1" + revision = "1a26190bd76a9017e289958b9fba936430aa3704" + version = "kubernetes-1.14.1" [[projects]] branch = "master" @@ -1254,17 +1247,23 @@ revision = "0317810137be915b9cf888946c6e115c1bfac693" [[projects]] - digest = "1:17316c2e91c840fa9975f229b5f1a6393e1cce5206320ccd0ff0896a480d4493" - name = "k8s.io/kubernetes" - packages = ["pkg/controller/volume/events"] + branch = "master" + digest = "1:75ea823fa8126ea20f2c34040f3f34876a1e52427f5831045da3605d97610b7e" + name = "k8s.io/utils" + packages = [ + "buffer", + "integer", + "trace", + ] pruneopts = "T" - revision = "4485c6f18cee9a5d3c3b4e523bd27972b1b53892" - version = "v1.15.1" + revision = "6c36bc71fc4aeb1f49801054e71aebdaef1fbeb4" [[projects]] - digest = "1:5aa50779f75cc439edd3455a6dee7cf179b52f8dde764a47cc929693485d1afb" + digest = "1:57ba0ac1fe6337a216cfccd60f180149966969752501b2a31fc815da391232f9" name = "sigs.k8s.io/controller-runtime" packages = [ + ".", + "pkg/builder", "pkg/cache", "pkg/cache/internal", "pkg/client", @@ -1273,59 +1272,62 @@ "pkg/client/fake", "pkg/controller", "pkg/controller/controllerutil", + "pkg/conversion", "pkg/envtest", "pkg/envtest/printer", "pkg/event", "pkg/handler", "pkg/internal/controller", "pkg/internal/controller/metrics", + "pkg/internal/log", + "pkg/internal/objectutil", "pkg/internal/recorder", "pkg/leaderelection", + "pkg/log", + "pkg/log/zap", "pkg/manager", + "pkg/manager/signals", "pkg/metrics", - "pkg/patch", "pkg/predicate", "pkg/reconcile", "pkg/recorder", "pkg/runtime/inject", "pkg/runtime/log", - "pkg/runtime/scheme", "pkg/runtime/signals", + "pkg/scheme", "pkg/source", "pkg/source/internal", "pkg/webhook", "pkg/webhook/admission", - "pkg/webhook/admission/builder", - "pkg/webhook/admission/types", - "pkg/webhook/internal/cert", - "pkg/webhook/internal/cert/generator", - "pkg/webhook/internal/cert/writer", - "pkg/webhook/internal/cert/writer/atomic", + "pkg/webhook/conversion", + "pkg/webhook/internal/certwatcher", "pkg/webhook/internal/metrics", - "pkg/webhook/types", ] pruneopts = "T" - revision = "12d98582e72927b6cd0123e2b4e819f9341ce62c" - version = "v0.1.10" + revision = "1592b5ee945140d042351098bf3217d71f36cace" + version = "v0.2.1" [[projects]] - digest = "1:adfc3ea3c2a575c2f6315f17dfcddd6fb49247a1a1b055febc2a44b35e59ca10" + digest = "1:6cafacc8221c3e70c935f34753ac363735e158849f18ea164696145cc299bb8e" name = "sigs.k8s.io/controller-tools" packages = [ "cmd/controller-gen", - "pkg/crd/generator", - "pkg/crd/util", - "pkg/internal/codegen", - "pkg/internal/codegen/parse", - "pkg/internal/general", + "pkg/crd", + "pkg/crd/markers", + "pkg/deepcopy", + "pkg/genall", + "pkg/genall/help", + "pkg/genall/help/pretty", + "pkg/loader", + "pkg/markers", "pkg/rbac", - "pkg/util", + "pkg/schemapatcher", + "pkg/schemapatcher/internal/yaml", "pkg/webhook", - "pkg/webhook/internal", ] pruneopts = "T" - revision = "fbf141159251d035089e7acdd5a343f8cec91b94" - version = "v0.1.9" + revision = "ba11932048e4538f6e435f5ca0cdea19bf458338" + version = "v0.2.1" [[projects]] digest = "1:290b4da306982122bcdff12dbababbb95c6e4a94a2995db88baf235ef2f6e93e" @@ -1359,29 +1361,31 @@ "github.com/emicklei/go-restful", "github.com/ghodss/yaml", "github.com/go-logr/logr", + "github.com/go-logr/zapr", "github.com/go-test/deep", + "github.com/hashicorp/go-multierror", "github.com/hashicorp/vault/api", "github.com/imdario/mergo", "github.com/magiconair/properties/assert", "github.com/pkg/errors", "github.com/spf13/cobra", + "github.com/spf13/pflag", "github.com/spf13/viper", "github.com/stretchr/testify/assert", "github.com/stretchr/testify/require", + "go.uber.org/zap", + "go.uber.org/zap/zapcore", "golang.org/x/crypto/bcrypt", "gopkg.in/yaml.v2", - "k8s.io/api/admission/v1beta1", - "k8s.io/api/admissionregistration/v1beta1", "k8s.io/api/apps/v1", "k8s.io/api/core/v1", "k8s.io/api/policy/v1beta1", - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1", "k8s.io/apimachinery/pkg/api/errors", "k8s.io/apimachinery/pkg/api/meta", "k8s.io/apimachinery/pkg/api/resource", + "k8s.io/apimachinery/pkg/api/validation", "k8s.io/apimachinery/pkg/apis/meta/v1", "k8s.io/apimachinery/pkg/fields", - "k8s.io/apimachinery/pkg/labels", "k8s.io/apimachinery/pkg/runtime", "k8s.io/apimachinery/pkg/runtime/schema", "k8s.io/apimachinery/pkg/types", @@ -1390,6 +1394,7 @@ "k8s.io/apimachinery/pkg/util/rand", "k8s.io/apimachinery/pkg/util/runtime", "k8s.io/apimachinery/pkg/util/uuid", + "k8s.io/apimachinery/pkg/util/validation", "k8s.io/apimachinery/pkg/util/version", "k8s.io/apimachinery/pkg/util/wait", "k8s.io/apimachinery/pkg/util/yaml", @@ -1402,6 +1407,7 @@ "k8s.io/client-go/kubernetes/scheme", "k8s.io/client-go/plugin/pkg/client/auth/gcp", "k8s.io/client-go/rest", + "k8s.io/client-go/restmapper", "k8s.io/client-go/tools/cache", "k8s.io/client-go/tools/clientcmd", "k8s.io/client-go/tools/portforward", @@ -1411,7 +1417,8 @@ "k8s.io/client-go/util/workqueue", "k8s.io/code-generator/cmd/client-gen", "k8s.io/code-generator/cmd/deepcopy-gen", - "k8s.io/kubernetes/pkg/controller/volume/events", + "k8s.io/klog", + "sigs.k8s.io/controller-runtime", "sigs.k8s.io/controller-runtime/pkg/client", "sigs.k8s.io/controller-runtime/pkg/client/apiutil", "sigs.k8s.io/controller-runtime/pkg/client/config", @@ -1421,17 +1428,14 @@ "sigs.k8s.io/controller-runtime/pkg/envtest", "sigs.k8s.io/controller-runtime/pkg/event", "sigs.k8s.io/controller-runtime/pkg/handler", + "sigs.k8s.io/controller-runtime/pkg/log/zap", "sigs.k8s.io/controller-runtime/pkg/manager", "sigs.k8s.io/controller-runtime/pkg/reconcile", "sigs.k8s.io/controller-runtime/pkg/runtime/inject", "sigs.k8s.io/controller-runtime/pkg/runtime/log", - "sigs.k8s.io/controller-runtime/pkg/runtime/scheme", "sigs.k8s.io/controller-runtime/pkg/runtime/signals", + "sigs.k8s.io/controller-runtime/pkg/scheme", "sigs.k8s.io/controller-runtime/pkg/source", - "sigs.k8s.io/controller-runtime/pkg/webhook", - "sigs.k8s.io/controller-runtime/pkg/webhook/admission", - "sigs.k8s.io/controller-runtime/pkg/webhook/admission/builder", - "sigs.k8s.io/controller-runtime/pkg/webhook/admission/types", "sigs.k8s.io/controller-tools/cmd/controller-gen", "sigs.k8s.io/testing_frameworks/integration", ] diff --git a/Gopkg.toml b/Gopkg.toml index 5d52dfb62d..d04d053dd2 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -5,31 +5,21 @@ required = [ "k8s.io/code-generator/cmd/client-gen", # for go generate "k8s.io/code-generator/cmd/deepcopy-gen", # for go generate "sigs.k8s.io/controller-tools/cmd/controller-gen", # for crd/rbac generation - "sigs.k8s.io/controller-runtime/pkg/client/config", - "sigs.k8s.io/controller-runtime/pkg/controller", - "sigs.k8s.io/controller-runtime/pkg/handler", - "sigs.k8s.io/controller-runtime/pkg/manager", - "sigs.k8s.io/controller-runtime/pkg/runtime/signals", - "sigs.k8s.io/controller-runtime/pkg/source", "sigs.k8s.io/testing_frameworks/integration", # for integration testing - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1", - "github.com/go-test/deep", - "github.com/elastic/go-ucfg" + "github.com/go-test/deep", + "github.com/elastic/go-ucfg" ] [prune] go-tests = true - -# STANZAS BELOW ARE GENERATED AND MAY BE WRITTEN - DO NOT MODIFY BELOW THIS LINE. - [[constraint]] name="sigs.k8s.io/controller-runtime" - version="v0.1.10" + version="v0.2.1" [[constraint]] name="sigs.k8s.io/controller-tools" - version="v0.1.9" + version="v0.2.1" # For dependency below: Refer to issue https://github.com/golang/dep/issues/1799 [[override]] diff --git a/Makefile b/Makefile index c1b1d9087f..587142592e 100644 --- a/Makefile +++ b/Makefile @@ -25,12 +25,29 @@ LATEST_RELEASED_IMG ?= "docker.elastic.co/eck/$(NAME):0.8.0" # Default to debug logging LOG_VERBOSITY ?= 1 +# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) +ifeq (,$(shell go env GOBIN)) +GOBIN=$(shell go env GOPATH)/bin +else +GOBIN=$(shell go env GOBIN) +endif + +# find or download controller-gen +# note this does not validate the version +controller-gen: +ifeq (, $(shell which controller-gen)) + go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.0 +CONTROLLER_GEN=$(GOBIN)/controller-gen +else +CONTROLLER_GEN=$(shell which controller-gen) +endif + ## -- Docker image # on GKE, use GCR and GCLOUD_PROJECT ifneq ($(findstring gke_,$(KUBECTL_CLUSTER)),) REGISTRY ?= eu.gcr.io - REPOSITORY ?= ${GCLOUD_PROJECT} + REPOSITORY ?= $(GCLOUD_PROJECT) else # default to local registry REGISTRY ?= localhost:5000 @@ -81,12 +98,14 @@ dep-vendor-only: # don't attempt to upgrade Gopkg.lock dep ensure --vendor-only -# Generate API types code and manifests from annotations e.g. CRD, RBAC etc. -generate: +# Generate code +generate: controller-gen + # we use this in pkg/controller/common/license go generate -tags='$(GO_TAGS)' ./pkg/... ./cmd/... - go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all + $(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./pkg/apis/... $(MAKE) --no-print-directory generate-all-in-one - $(MAKE) --no-print-directory generate-api-docs + # TODO (sabo): reenable when new tag is cut and can work with the new repo path + # $(MAKE) --no-print-directory generate-api-docs generate-api-docs: @hack/api-docs/build.sh @@ -351,7 +370,8 @@ e2e-local: ## -- Continuous integration -- ## ########################################## -ci: dep-vendor-only check-fmt lint generate check-local-changes unit_xml integration_xml e2e-compile docker-build +# TODO consider re-adding check-fmt and check-local-changes +ci: dep-vendor-only lint generate unit_xml integration_xml e2e-compile docker-build # Run e2e tests in a dedicated cluster. ci-e2e: dep-vendor-only run-deployer install-crds apply-psp e2e diff --git a/build/ci/Dockerfile b/build/ci/Dockerfile index 90fdf3a686..40db5d32cf 100644 --- a/build/ci/Dockerfile +++ b/build/ci/Dockerfile @@ -1,11 +1,11 @@ # Docker image aimed to run compilation and tests in CI -FROM golang:1.11-stretch +FROM golang:1.13-stretch -ENV KUBEBUILDER_VERSION=1.0.8 +ENV KUBEBUILDER_VERSION=2.0.0 ENV GCLOUD_VERSION=232.0.0 ENV KUBECTL_VERSION=1.13.6 ENV DOCKER_VERSION=18.03.1-ce -ENV GOLANGCILINT_VERSION=1.17.1 +ENV GOLANGCILINT_VERSION=1.18.0 ENV GOTESTSUM_VERSION=0.3.5 # Download required golang tools diff --git a/cmd/manager/main.go b/cmd/manager/main.go index c3d44e2ecc..3cb75e4668 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -13,19 +13,32 @@ import ( "time" "github.com/elastic/cloud-on-k8s/pkg/about" - "github.com/elastic/cloud-on-k8s/pkg/apis" - "github.com/elastic/cloud-on-k8s/pkg/controller" + // allow gcp authentication + _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" + + "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver" + asesassn "github.com/elastic/cloud-on-k8s/pkg/controller/apmserverelasticsearchassociation" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/common/operator" + controllerscheme "github.com/elastic/cloud-on-k8s/pkg/controller/common/scheme" + "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch" + "github.com/elastic/cloud-on-k8s/pkg/controller/kibana" + kbassn "github.com/elastic/cloud-on-k8s/pkg/controller/kibanaassociation" + "github.com/elastic/cloud-on-k8s/pkg/controller/license" + licensetrial "github.com/elastic/cloud-on-k8s/pkg/controller/license/trial" "github.com/elastic/cloud-on-k8s/pkg/dev" "github.com/elastic/cloud-on-k8s/pkg/dev/portforward" "github.com/elastic/cloud-on-k8s/pkg/utils/net" - "github.com/elastic/cloud-on-k8s/pkg/webhook" + + // TODO (sabo): re-enable when webhooks are usable + // "github.com/elastic/cloud-on-k8s/pkg/webhook" + + clientgoscheme "k8s.io/client-go/kubernetes/scheme" + ctrl "sigs.k8s.io/controller-runtime" + "github.com/spf13/cobra" "github.com/spf13/viper" "k8s.io/client-go/kubernetes" - "sigs.k8s.io/controller-runtime/pkg/client/config" - "sigs.k8s.io/controller-runtime/pkg/manager" logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" "sigs.k8s.io/controller-runtime/pkg/runtime/signals" ) @@ -187,15 +200,19 @@ func execute() { // Get a config to talk to the apiserver log.Info("Setting up client for manager") - cfg, err := config.GetConfig() + cfg := ctrl.GetConfigOrDie() + // Setup Scheme for all resources + log.Info("Setting up scheme") + err := controllerscheme.SetupScheme() if err != nil { - log.Error(err, "unable to set up client config") + log.Error(err, "Error setting up schemes") os.Exit(1) } // Create a new Cmd to provide shared dependencies and start components log.Info("Setting up manager") - opts := manager.Options{ + opts := ctrl.Options{ + Scheme: clientgoscheme.Scheme, // restrict the operator to watch resources within a single namespace, unless empty Namespace: viper.GetString(NamespaceFlagName), } @@ -207,22 +224,16 @@ func execute() { opts.MetricsBindAddress = fmt.Sprintf(":%d", metricsPort) } - mgr, err := manager.New(cfg, opts) + mgr, err := ctrl.NewManager(cfg, opts) if err != nil { - log.Error(err, "unable to set up overall controller manager") - os.Exit(1) - } - - // Setup Scheme for all resources - log.Info("Setting up scheme") - if err := apis.AddToScheme(mgr.GetScheme()); err != nil { - log.Error(err, "unable add APIs to scheme") + log.Error(err, "unable to create controller manager") os.Exit(1) } // Verify cert validity options caCertValidity, caCertRotateBefore := ValidateCertExpirationFlags(CACertValidityFlag, CACertRotateBeforeFlag) certValidity, certRotateBefore := ValidateCertExpirationFlags(CertValidityFlag, CertRotateBeforeFlag) + // Setup all Controllers roles := viper.GetStringSlice(operator.RoleFlag) err = operator.ValidateRoles(roles) @@ -243,9 +254,8 @@ func execute() { log.Error(err, "unable to get operator info") os.Exit(1) } - log.Info("Setting up controllers", "roles", roles) - if err := controller.AddToManager(mgr, roles, operator.Parameters{ + params := operator.Parameters{ Dialer: dialer, OperatorNamespace: operatorNamespace, OperatorInfo: operatorInfo, @@ -257,17 +267,44 @@ func execute() { Validity: certValidity, RotateBefore: certRotateBefore, }, - }); err != nil { - log.Error(err, "unable to register controllers to the manager") - os.Exit(1) } - log.Info("Setting up webhooks") - if err := webhook.AddToManager(mgr, roles, newWebhookParameters); err != nil { - log.Error(err, "unable to register webhooks to the manager") + if err = apmserver.Add(mgr, params); err != nil { + log.Error(err, "unable to create controller", "controller", "ApmServer") + os.Exit(1) + } + if err = elasticsearch.Add(mgr, params); err != nil { + log.Error(err, "unable to create controller", "controller", "Elasticsearch") + os.Exit(1) + } + if err = kibana.Add(mgr, params); err != nil { + log.Error(err, "unable to create controller", "controller", "Kibana") + os.Exit(1) + } + if err = asesassn.Add(mgr, params); err != nil { + log.Error(err, "unable to create controller", "controller", "ApmServerElasticsearchAssociation") + os.Exit(1) + } + if err = kbassn.Add(mgr, params); err != nil { + log.Error(err, "unable to create controller", "controller", "KibanaAssociation") + os.Exit(1) + } + if err = license.Add(mgr, params); err != nil { + log.Error(err, "unable to create controller", "controller", "License") + os.Exit(1) + } + if err = licensetrial.Add(mgr, params); err != nil { + log.Error(err, "unable to create controller", "controller", "LicenseTrial") os.Exit(1) } + // TODO (sabo): re-enable when webhooks are usable + // log.Info("Setting up webhooks") + // if err := webhook.AddToManager(mgr, roles, newWebhookParameters); err != nil { + // log.Error(err, "unable to register webhooks to the manager") + // os.Exit(1) + // } + log.Info("Starting the manager", "uuid", operatorInfo.OperatorUUID, "namespace", operatorNamespace, "version", operatorInfo.BuildInfo.Version, "build_hash", operatorInfo.BuildInfo.Hash, "build_date", operatorInfo.BuildInfo.Date, @@ -278,24 +315,25 @@ func execute() { } } -func newWebhookParameters() (*webhook.Parameters, error) { - autoInstall := viper.GetBool(AutoInstallWebhooksFlag) - ns := viper.GetString(OperatorNamespaceFlag) - if ns == "" && autoInstall { - return nil, fmt.Errorf("%s needs to be set for webhook auto installation", OperatorNamespaceFlag) - } - svcSelector := viper.GetString(WebhookPodsLabelFlag) - sec := viper.GetString(WebhookSecretFlag) - return &webhook.Parameters{ - Bootstrap: webhook.NewBootstrapOptions(webhook.BootstrapOptionsParams{ - Namespace: ns, - ManagedNamespace: viper.GetString(NamespaceFlagName), - SecretName: sec, - ServiceSelector: svcSelector, - }), - AutoInstall: autoInstall, - }, nil -} +// TODO (sabo): re-enable when webhooks are usable +// func newWebhookParameters() (*webhook.Parameters, error) { +// autoInstall := viper.GetBool(AutoInstallWebhooksFlag) +// ns := viper.GetString(OperatorNamespaceFlag) +// if ns == "" && autoInstall { +// return nil, fmt.Errorf("%s needs to be set for webhook auto installation", OperatorNamespaceFlag) +// } +// svcSelector := viper.GetString(WebhookPodsLabelFlag) +// sec := viper.GetString(WebhookSecretFlag) +// return &webhook.Parameters{ +// Bootstrap: webhook.NewBootstrapOptions(webhook.BootstrapOptionsParams{ +// Namespace: ns, +// ManagedNamespace: viper.GetString(NamespaceFlagName), +// SecretName: sec, +// ServiceSelector: svcSelector, +// }), +// AutoInstall: autoInstall, +// }, nil +// } func ValidateCertExpirationFlags(validityFlag string, rotateBeforeFlag string) (time.Duration, time.Duration) { certValidity := viper.GetDuration(validityFlag) diff --git a/go.mod b/go.mod new file mode 100644 index 0000000000..3bebfcfacb --- /dev/null +++ b/go.mod @@ -0,0 +1,48 @@ +module github.com/elastic/cloud-on-k8s + +go 1.13 + +require ( + github.com/Masterminds/goutils v1.1.0 // indirect + github.com/Masterminds/semver v1.4.2 // indirect + github.com/Masterminds/sprig v2.20.0+incompatible + github.com/davecgh/go-spew v1.1.1 + github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect + github.com/elastic/go-ucfg v0.7.0 + github.com/elazarl/goproxy v0.0.0-20190711103511-473e67f1d7d2 // indirect + github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2 // indirect + github.com/ghodss/yaml v1.0.0 + github.com/go-logr/logr v0.1.0 + github.com/go-logr/zapr v0.1.0 + github.com/go-test/deep v1.0.3 + github.com/gogo/protobuf v1.3.0 // indirect + github.com/google/uuid v1.1.1 // indirect + github.com/hashicorp/go-multierror v1.0.0 + github.com/hashicorp/vault/api v1.0.4 + github.com/huandu/xstrings v1.2.0 // indirect + github.com/imdario/mergo v0.3.6 + github.com/json-iterator/go v1.1.7 // indirect + github.com/magiconair/properties v1.8.1 + github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/onsi/ginkgo v1.8.0 // indirect + github.com/onsi/gomega v1.5.0 // indirect + github.com/pelletier/go-toml v1.4.0 // indirect + github.com/pkg/errors v0.8.1 + github.com/spf13/cobra v0.0.5 + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/spf13/pflag v1.0.3 + github.com/spf13/viper v1.4.0 + github.com/stretchr/testify v1.3.0 + go.uber.org/zap v1.10.0 + golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 + golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2 // indirect + golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7 // indirect + golang.org/x/text v0.3.2 // indirect + gopkg.in/yaml.v2 v2.2.2 + k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b + k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d + k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible + k8s.io/klog v0.4.0 + k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf // indirect + sigs.k8s.io/controller-runtime v0.2.1 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000000..b8f1024cea --- /dev/null +++ b/go.sum @@ -0,0 +1,437 @@ +cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ= +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg= +github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc= +github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/Masterminds/sprig v2.20.0+incompatible h1:dJTKKuUkYW3RMFdQFXPU/s6hg10RgctmTjRcbZ98Ap8= +github.com/Masterminds/sprig v2.20.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= +github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c h1:ZfSZ3P3BedhKGUhzj7BQlPSU4OvT6tfOKe3DVHzOA7s= +github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= +github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= +github.com/elastic/go-ucfg v0.7.0 h1:1+C/sZdJKww8hKl7XtLPTjs4cFslhQF2fazKTF+ZE+4= +github.com/elastic/go-ucfg v0.7.0/go.mod h1:iaiY0NBIYeasNgycLyTvhJftQlQEUO2hpF+FX0JKxzo= +github.com/elazarl/goproxy v0.0.0-20190711103511-473e67f1d7d2 h1:aZtFdDNWY/yH86JPR2WX/PN63635VsE/f/nXNPAbYxY= +github.com/elazarl/goproxy v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= +github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2 h1:dWB6v3RcOy03t/bUadywsbyrQwCqZeNIEX6M1OtSZOM= +github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8= +github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M= +github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logr/logr v0.1.0 h1:M1Tv3VzNlEHg6uyACnRdtrploV2P7wZqH8BoQMtz0cg= +github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= +github.com/go-logr/zapr v0.1.0 h1:h+WVe9j6HAA01niTJPA/kKH0i7e0rLZBCwauQFcRE54= +github.com/go-logr/zapr v0.1.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk= +github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= +github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= +github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= +github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/gogo/protobuf v1.3.0 h1:G8O7TerXerS4F6sx9OV7/nRfJdnXgHZu/S/7F2SN+UE= +github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20180513044358-24b0969c4cb7 h1:u4bArs140e9+AfE52mFHOXVFnOSBJBRlzTHrOPLOIhE= +github.com/golang/groupcache v0.0.0-20180513044358-24b0969c4cb7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef h1:veQD95Isof8w9/WXiA+pa3tz3fJXkt5B7QaRBrM62gk= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1 h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck= +github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/googleapis/gnostic v0.3.1 h1:WeAefnSUHlBb0iJKwxFDZdbfGwkd7xRNuV+IpXMJhYk= +github.com/googleapis/gnostic v0.3.1/go.mod h1:on+2t9HRStVgn95RSsFWFz+6Q0Snyqv1awfrALZdbtU= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= +github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= +github.com/hashicorp/go-retryablehttp v0.5.4 h1:1BZvpawXoJCWX6pNtow9+rpEj+3itIlutiqnntI6jOE= +github.com/hashicorp/go-retryablehttp v0.5.4/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-rootcerts v1.0.1 h1:DMo4fmknnz0E0evoNYnV48RjWndOsmd6OW+09R3cEP8= +github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= +github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc= +github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/golang-lru v0.0.0-20180201235237-0fb14efe8c47 h1:UnszMmmmm5vLwWzDjTFVIkfhvWF1NdrmChl8L2NUDCw= +github.com/hashicorp/golang-lru v0.0.0-20180201235237-0fb14efe8c47/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/vault/api v1.0.4 h1:j08Or/wryXT4AcHj1oCbMd7IijXcKzYUGw59LGu9onU= +github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoIospckxBxk6Q= +github.com/hashicorp/vault/sdk v0.1.13 h1:mOEPeOhT7jl0J4AMl1E705+BcmeRs1VmKNb9F0sMLy8= +github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M= +github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0= +github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= +github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE= +github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= +github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= +github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= +github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I= +github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= +github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pborman/uuid v0.0.0-20170612153648-e790cca94e6c h1:MUyE44mTvnI5A0xrxIxaMqoWFzPfQvtE2IWUollMDMs= +github.com/pborman/uuid v0.0.0-20170612153648-e790cca94e6c/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= +github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.4.0 h1:u3Z1r+oOXJIkxqw34zVhyPgjBsm6X2wn21NWs/HfSeg= +github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= +github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/prometheus/client_golang v0.9.0 h1:tXuTFVHC03mW0D+Ua1Q2d1EAVqLTuggX50V0VLICCzY= +github.com/prometheus/client_golang v0.9.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3 h1:9iH4JKXLzFbOAdtqv/a+j8aewx2Y8lAjAydhbaScPF8= +github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 h1:S/YWwWx/RA8rT8tKFRuGUZhuA90OyIBpPCXkcbwU8DE= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e h1:n/3MEhJQjQxrOUCzh1Y3Re6aJUUWRp2M9+Oc3eVn/54= +github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.0 h1:7etb9YClo3a6HjLzfl6rIQaU+FDfi0VSX39io3aQ+DM= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273 h1:agujYaXJSxSo18YNX3jzl+4G6Bstwt+kqv47GS12uL0= +github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084 h1:sofwID9zm4tzrgykg80hfFph1mryUeLRsUfoocVVmRY= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc= +github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk= +github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= +github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= +github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= +github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= +github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= +github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= +github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.2 h1:Fy0orTDgHdbnzHcsOgfCN4LtHf0ec3wwtiwJqwvf3Gc= +github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU= +github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.9.1 h1:XCJQEf3W6eZaVwhRBof6ImoYGJSITeKWsyeh3HFu/5o= +go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac h1:7d7lG9fHOLdL6jZPtnV4LpI41SbohIJ1Atq7U991dMg= +golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 h1:0hQKqeLdqlt5iIwVOBErRisrHJAN57yOiPRQItI20fU= +golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092 h1:4QSRKanuywn15aTZvI/mIDEgPQpswuFndXpOj3rKEco= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2 h1:4dVFTC832rPn4pomLSz1vA+are2+dU19w1H8OngV7nc= +golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e h1:nFYrTHrdrAOpShe27kaFHjsqYSEQ0KWqdWLu3xuZJts= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7 h1:wYqz/tQaWUgGKyx+B/rssSE6wkIKdY5Ee6ryOmzarIg= +golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db h1:6/JqlYfC1CCaLnGceQTI+sDGhC9UBSPAsBqI0Gun6kU= +golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 h1:5Beo0mZN8dRzgrMMkDp0jc8YXQKx9DiJ2k1dkvGsn5A= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +gomodules.xyz/jsonpatch/v2 v2.0.1 h1:xyiBuvkD2g5n7cYzx6u2sxQvsAy4QJsZFCzGVdzOXZ0= +gomodules.xyz/jsonpatch/v2 v2.0.1/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU= +google.golang.org/appengine v1.1.0 h1:igQkv0AAhEIvTEpD5LIpAfav2eeVO9HBTjvKHVJPRSs= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/square/go-jose.v2 v2.3.1 h1:SK5KegNXmKmqE342YYN2qPHEnUYeoMiXXl1poUlI+o4= +gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b h1:aBGgKJUM9Hk/3AE8WaZIApnTxG35kbuQba2w+SXqezo= +k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= +k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8 h1:q1Qvjzs/iEdXF6A1a8H3AKVFDzJNcJn3nXMs6R6qFtA= +k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8/go.mod h1:IxkesAMoaCRoLrPJdZNZUQp9NfZnzqaVzLhb2VEQzXE= +k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d h1:Jmdtdt1ZnoGfWWIIik61Z7nKYgO3J+swQJtPYsP9wHA= +k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= +k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible h1:U5Bt+dab9K8qaUmXINrkXO135kA11/i5Kg1RUydgaMQ= +k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s= +k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= +k8s.io/klog v0.3.0 h1:0VPpR+sizsiivjIfIAQH/rl8tan6jvWkS7lU+0di3lE= +k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= +k8s.io/klog v0.4.0 h1:lCJCxf/LIowc2IGS9TPjWDyXY4nOmdGdfcwwDQCOURQ= +k8s.io/klog v0.4.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= +k8s.io/kube-openapi v0.0.0-20180731170545-e3762e86a74c h1:3KSCztE7gPitlZmWbNwue/2U0YruD65DqX3INopDAQM= +k8s.io/kube-openapi v0.0.0-20180731170545-e3762e86a74c/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= +k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf h1:EYm5AW/UUDbnmnI+gK0TJDVK9qPLhM+sRHYanNKw0EQ= +k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= +k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5 h1:VBM/0P5TWxwk+Nw6Z+lAw3DKgO76g90ETOiA6rfLV1Y= +k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +sigs.k8s.io/controller-runtime v0.2.1 h1:XwUV7gwU/2Uerl9Vb5TpoA3wMQgOxI/LdLq8UhkSSRA= +sigs.k8s.io/controller-runtime v0.2.1/go.mod h1:9dyohw3ZtoXQuV1e766PHUn+cmrRCIcBh6XIMFNMZ+I= +sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= +sigs.k8s.io/testing_frameworks v0.1.1 h1:cP2l8fkA3O9vekpy5Ks8mmA0NW/F7yBdXf8brkWhVrs= +sigs.k8s.io/testing_frameworks v0.1.1/go.mod h1:VVBKrHmJ6Ekkfz284YKhQePcdycOzNH9qL6ht1zEr/U= +sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/pkg/apis/addtoscheme_apm_v1alpha1.go b/pkg/apis/addtoscheme_apm_v1alpha1.go deleted file mode 100644 index ce997e8bd0..0000000000 --- a/pkg/apis/addtoscheme_apm_v1alpha1.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package apis - -import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" -) - -func init() { - // Register the types with the Scheme so the components can map objects to GroupVersionKinds and back - AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme) -} diff --git a/pkg/apis/addtoscheme_associations_v1alpha1.go b/pkg/apis/addtoscheme_associations_v1alpha1.go deleted file mode 100644 index 19f8efbbb8..0000000000 --- a/pkg/apis/addtoscheme_associations_v1alpha1.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package apis - -import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/associations/v1alpha1" -) - -func init() { - // Register the types with the Scheme so the components can map objects to GroupVersionKinds and back - AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme) -} diff --git a/pkg/apis/addtoscheme_common_v1alpha1.go b/pkg/apis/addtoscheme_common_v1alpha1.go deleted file mode 100644 index a59c86ec4d..0000000000 --- a/pkg/apis/addtoscheme_common_v1alpha1.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package apis - -import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" -) - -func init() { - // Register the types with the Scheme so the components can map objects to GroupVersionKinds and back - AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme) -} diff --git a/pkg/apis/addtoscheme_elasticsearch_v1alpha1.go b/pkg/apis/addtoscheme_elasticsearch_v1alpha1.go deleted file mode 100644 index 7f220a029a..0000000000 --- a/pkg/apis/addtoscheme_elasticsearch_v1alpha1.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package apis - -import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" -) - -func init() { - // Register the types with the Scheme so the components can map objects to GroupVersionKinds and back - AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme) -} diff --git a/pkg/apis/addtoscheme_kibana_v1alpha1.go b/pkg/apis/addtoscheme_kibana_v1alpha1.go deleted file mode 100644 index f54ad63c78..0000000000 --- a/pkg/apis/addtoscheme_kibana_v1alpha1.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package apis - -import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" -) - -func init() { - // Register the types with the Scheme so the components can map objects to GroupVersionKinds and back - AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme) -} diff --git a/pkg/apis/apis.go b/pkg/apis/apis.go deleted file mode 100644 index 391b0603c8..0000000000 --- a/pkg/apis/apis.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// Generate deepcopy for apis -//go:generate go run ../../vendor/k8s.io/code-generator/cmd/deepcopy-gen/main.go -O zz_generated.deepcopy -i ./... -h ../../hack/boilerplate.go.txt - -// Package apis contains Kubernetes API groups. -package apis - -import ( - "k8s.io/apimachinery/pkg/runtime" -) - -// AddToSchemes may be used to add all resources defined in the project to a Scheme -var AddToSchemes runtime.SchemeBuilder - -// AddToScheme adds all Resources to the Scheme -func AddToScheme(s *runtime.Scheme) error { - return AddToSchemes.AddToScheme(s) -} diff --git a/pkg/apis/apm/group.go b/pkg/apis/apm/group.go deleted file mode 100644 index 24b2cc0d11..0000000000 --- a/pkg/apis/apm/group.go +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// Package apm contains apm API versions -package apm diff --git a/pkg/apis/apm/v1alpha1/apmserver_types.go b/pkg/apis/apm/v1alpha1/apmserver_types.go index d51adfaf06..99b2b63061 100644 --- a/pkg/apis/apm/v1alpha1/apmserver_types.go +++ b/pkg/apis/apm/v1alpha1/apmserver_types.go @@ -39,7 +39,7 @@ type ApmServerSpec struct { // PodTemplate can be used to propagate configuration to APM Server pods. // This allows specifying custom annotations, labels, environment variables, // affinity, resources, etc. for the pods created from this NodeSpec. - // +optional + // +kubebuilder:validation:Optional PodTemplate corev1.PodTemplateSpec `json:"podTemplate,omitempty"` // SecureSettings references secrets containing secure settings, to be injected @@ -83,7 +83,6 @@ func (as ApmServerStatus) IsDegraded(prev ApmServerStatus) bool { // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // ApmServer is the Schema for the apmservers API -// +k8s:openapi-gen=true // +kubebuilder:categories=elastic // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="health",type="string",JSONPath=".status.health" @@ -99,7 +98,7 @@ type ApmServer struct { assocConf *commonv1alpha1.AssociationConf } -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true // ApmServerList contains a list of ApmServer type ApmServerList struct { diff --git a/pkg/apis/apm/v1alpha1/doc.go b/pkg/apis/apm/v1alpha1/doc.go deleted file mode 100644 index 9794ab22a1..0000000000 --- a/pkg/apis/apm/v1alpha1/doc.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// Package v1alpha1 contains API Schema definitions for the apm v1alpha1 API group -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=github.com/elastic/cloud-on-k8s/pkg/apis/apm -// +k8s:defaulter-gen=TypeMeta -// +groupName=apm.k8s.elastic.co -package v1alpha1 diff --git a/pkg/apis/apm/v1alpha1/groupversion_info.go b/pkg/apis/apm/v1alpha1/groupversion_info.go new file mode 100644 index 0000000000..9ff9146576 --- /dev/null +++ b/pkg/apis/apm/v1alpha1/groupversion_info.go @@ -0,0 +1,24 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// Package v1alpha1 contains API Schema definitions for the apm v1alpha1 API group +// +kubebuilder:object:generate=true +// +groupName=apm.k8s.elastic.co +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "apm.k8s.elastic.co", Version: "v1alpha1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/pkg/apis/apm/v1alpha1/register.go b/pkg/apis/apm/v1alpha1/register.go deleted file mode 100644 index 322e4a1f27..0000000000 --- a/pkg/apis/apm/v1alpha1/register.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// NOTE: Boilerplate only. Ignore this file. - -// Package v1alpha1 contains API Schema definitions for the apm v1alpha1 API group -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=github.com/elastic/cloud-on-k8s/pkg/apis/apm -// +k8s:defaulter-gen=TypeMeta -// +groupName=apm.k8s.elastic.co -package v1alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/runtime/scheme" -) - -var ( - // SchemeGroupVersion is group version used to register these objects - SchemeGroupVersion = schema.GroupVersion{Group: "apm.k8s.elastic.co", Version: "v1alpha1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} - - // AddToScheme is required by pkg/client/... - AddToScheme = SchemeBuilder.AddToScheme -) - -// Resource is required by pkg/client/listers/... -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} diff --git a/pkg/apis/apm/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/apm/v1alpha1/zz_generated.deepcopy.go index aa4463c590..68210f86ff 100644 --- a/pkg/apis/apm/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/apm/v1alpha1/zz_generated.deepcopy.go @@ -4,13 +4,13 @@ // or more contributor license agreements. Licensed under the Elastic License; // you may not use this file except in compliance with the Elastic License. -// Code generated by main. DO NOT EDIT. +// Code generated by controller-gen. DO NOT EDIT. package v1alpha1 import ( commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - runtime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -25,7 +25,6 @@ func (in *ApmServer) DeepCopyInto(out *ApmServer) { *out = new(commonv1alpha1.AssociationConf) **out = **in } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApmServer. @@ -58,7 +57,6 @@ func (in *ApmServerList) DeepCopyInto(out *ApmServerList) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApmServerList. @@ -96,7 +94,6 @@ func (in *ApmServerSpec) DeepCopyInto(out *ApmServerSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApmServerSpec. @@ -113,7 +110,6 @@ func (in *ApmServerSpec) DeepCopy() *ApmServerSpec { func (in *ApmServerStatus) DeepCopyInto(out *ApmServerStatus) { *out = *in out.ReconcilerStatus = in.ReconcilerStatus - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApmServerStatus. diff --git a/pkg/apis/associations/group.go b/pkg/apis/associations/group.go deleted file mode 100644 index 9f7891c8b0..0000000000 --- a/pkg/apis/associations/group.go +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// Package associations contains associations API versions -package associations diff --git a/pkg/apis/associations/v1alpha1/doc.go b/pkg/apis/associations/v1alpha1/doc.go deleted file mode 100644 index 973db3c0d4..0000000000 --- a/pkg/apis/associations/v1alpha1/doc.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// Package v1alpha1 contains API Schema definitions for the associations v1alpha1 API group -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=github.com/elastic/cloud-on-k8s/pkg/apis/associations -// +k8s:defaulter-gen=TypeMeta -// +groupName=associations.k8s.elastic.co -package v1alpha1 diff --git a/pkg/apis/associations/v1alpha1/register.go b/pkg/apis/associations/v1alpha1/register.go deleted file mode 100644 index 1287aed059..0000000000 --- a/pkg/apis/associations/v1alpha1/register.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// NOTE: Boilerplate only. Ignore this file. - -// Package v1alpha1 contains API Schema definitions for the associations v1alpha1 API group -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=github.com/elastic/cloud-on-k8s/pkg/apis/associations -// +k8s:defaulter-gen=TypeMeta -// +groupName=associations.k8s.elastic.co -package v1alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/runtime/scheme" -) - -var ( - // SchemeGroupVersion is group version used to register these objects - SchemeGroupVersion = schema.GroupVersion{Group: "associations.k8s.elastic.co", Version: "v1alpha1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} - - // AddToScheme is required by pkg/client/... - AddToScheme = SchemeBuilder.AddToScheme -) - -// Resource is required by pkg/client/listers/... -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} diff --git a/pkg/apis/associations/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/associations/v1alpha1/zz_generated.deepcopy.go deleted file mode 100644 index e2d8e0c479..0000000000 --- a/pkg/apis/associations/v1alpha1/zz_generated.deepcopy.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build !ignore_autogenerated - -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// Code generated by main. DO NOT EDIT. - -package v1alpha1 diff --git a/pkg/apis/common/group.go b/pkg/apis/common/group.go deleted file mode 100644 index 7a47c4978a..0000000000 --- a/pkg/apis/common/group.go +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// Package common contains common API versions -package common diff --git a/pkg/apis/common/v1alpha1/association.go b/pkg/apis/common/v1alpha1/association.go index ddf8ca5e4e..dfa34fc289 100644 --- a/pkg/apis/common/v1alpha1/association.go +++ b/pkg/apis/common/v1alpha1/association.go @@ -23,6 +23,7 @@ const ( // An associated object needs some credentials to establish a connection to the Elasticsearch cluster and usually it // offers a keystore which in ECK is represented with an underlying Secret. // Kibana and the APM server are two examples of associated objects. +// +kubebuilder:object:generate=false type Associated interface { metav1.Object runtime.Object @@ -31,6 +32,7 @@ type Associated interface { } // Associator describes an object that allows its association to be set. +// +kubebuilder:object:generate=false type Associator interface { metav1.Object runtime.Object diff --git a/pkg/apis/common/v1alpha1/common.go b/pkg/apis/common/v1alpha1/common.go index 4add535607..6a6a774012 100644 --- a/pkg/apis/common/v1alpha1/common.go +++ b/pkg/apis/common/v1alpha1/common.go @@ -28,7 +28,7 @@ type ObjectSelector struct { Namespace string `json:"namespace,omitempty"` } -// NamespacedName is a convenience method to turn an ObjectSelector into a NamespaceName. +// NamespacedName is a convenience method to turn an ObjectSelector into a NamespacedName. func (s ObjectSelector) NamespacedName() types.NamespacedName { return types.NamespacedName{ Name: s.Name, @@ -96,11 +96,11 @@ type SubjectAlternativeName struct { type ServiceTemplate struct { // ObjectMeta is metadata for the service. // The name and namespace provided here is managed by ECK and will be ignored. - // +optional + // +kubebuilder:validation:Optional ObjectMeta metav1.ObjectMeta `json:"metadata,omitempty"` // Spec defines the behavior of the service. - // +optional + // +kubebuilder:validation:Optional Spec v1.ServiceSpec `json:"spec,omitempty"` } @@ -111,11 +111,11 @@ var DefaultPodDisruptionBudgetMaxUnavailable = intstr.FromInt(1) type PodDisruptionBudgetTemplate struct { // ObjectMeta is metadata for the service. // The name and namespace provided here is managed by ECK and will be ignored. - // +optional + // +kubebuilder:validation:Optional ObjectMeta metav1.ObjectMeta `json:"metadata,omitempty"` // Spec of the desired behavior of the PodDisruptionBudget - // +optional + // +kubebuilder:validation:Optional Spec v1beta1.PodDisruptionBudgetSpec `json:"spec,omitempty"` } @@ -128,7 +128,7 @@ type SecretSource struct { // key and content is the value. If specified, the listed keys will be // projected into the specified paths, and unlisted keys will not be // present. - // +optional + // +kubebuilder:validation:Optional Entries []KeyToPath `json:"entries,omitempty"` } @@ -141,6 +141,6 @@ type KeyToPath struct { // May not be an absolute path. // May not contain the path element '..'. // May not start with the string '..'. - // +optional + // +kubebuilder:validation:Optional Path string `json:"path,omitempty"` } diff --git a/pkg/apis/common/v1alpha1/doc.go b/pkg/apis/common/v1alpha1/doc.go deleted file mode 100644 index 72d6655957..0000000000 --- a/pkg/apis/common/v1alpha1/doc.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// Package v1alpha1 contains API Schema definitions for the common v1alpha1 API group -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=github.com/elastic/cloud-on-k8s/pkg/apis/common -// +k8s:defaulter-gen=TypeMeta -// +groupName=common.k8s.elastic.co -package v1alpha1 diff --git a/pkg/apis/common/v1alpha1/groupversion_info.go b/pkg/apis/common/v1alpha1/groupversion_info.go new file mode 100644 index 0000000000..51daf044bd --- /dev/null +++ b/pkg/apis/common/v1alpha1/groupversion_info.go @@ -0,0 +1,24 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// Package v1alpha1 contains API Schema definitions for the apm v1alpha1 API group +// +kubebuilder:object:generate=true +// +groupName=common.k8s.elastic.co +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "common.k8s.elastic.co", Version: "v1alpha1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/pkg/apis/common/v1alpha1/register.go b/pkg/apis/common/v1alpha1/register.go deleted file mode 100644 index 44997e0879..0000000000 --- a/pkg/apis/common/v1alpha1/register.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// NOTE: Boilerplate only. Ignore this file. - -// Package v1alpha1 contains API Schema definitions for the common v1alpha1 API group -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=github.com/elastic/cloud-on-k8s/pkg/apis/common -// +k8s:defaulter-gen=TypeMeta -// +groupName=common.k8s.elastic.co -package v1alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/runtime/scheme" -) - -var ( - // SchemeGroupVersion is group version used to register these objects - SchemeGroupVersion = schema.GroupVersion{Group: "common.k8s.elastic.co", Version: "v1alpha1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} - - // AddToScheme is required by pkg/client/... - AddToScheme = SchemeBuilder.AddToScheme -) - -// Resource is required by pkg/client/listers/... -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} diff --git a/pkg/apis/common/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/common/v1alpha1/zz_generated.deepcopy.go index 912f666c16..6be61a9959 100644 --- a/pkg/apis/common/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/common/v1alpha1/zz_generated.deepcopy.go @@ -4,14 +4,15 @@ // or more contributor license agreements. Licensed under the Elastic License; // you may not use this file except in compliance with the Elastic License. -// Code generated by main. DO NOT EDIT. +// Code generated by controller-gen. DO NOT EDIT. package v1alpha1 +import () + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AssociationConf) DeepCopyInto(out *AssociationConf) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AssociationConf. @@ -39,7 +40,6 @@ func (in *HTTPConfig) DeepCopyInto(out *HTTPConfig) { *out = *in in.Service.DeepCopyInto(&out.Service) in.TLS.DeepCopyInto(&out.TLS) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPConfig. @@ -55,7 +55,6 @@ func (in *HTTPConfig) DeepCopy() *HTTPConfig { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KeyToPath) DeepCopyInto(out *KeyToPath) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KeyToPath. @@ -71,7 +70,6 @@ func (in *KeyToPath) DeepCopy() *KeyToPath { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ObjectSelector) DeepCopyInto(out *ObjectSelector) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObjectSelector. @@ -89,7 +87,6 @@ func (in *PodDisruptionBudgetTemplate) DeepCopyInto(out *PodDisruptionBudgetTemp *out = *in in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodDisruptionBudgetTemplate. @@ -105,7 +102,6 @@ func (in *PodDisruptionBudgetTemplate) DeepCopy() *PodDisruptionBudgetTemplate { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ReconcilerStatus) DeepCopyInto(out *ReconcilerStatus) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReconcilerStatus. @@ -121,7 +117,6 @@ func (in *ReconcilerStatus) DeepCopy() *ReconcilerStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SecretRef) DeepCopyInto(out *SecretRef) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretRef. @@ -142,7 +137,6 @@ func (in *SecretSource) DeepCopyInto(out *SecretSource) { *out = make([]KeyToPath, len(*in)) copy(*out, *in) } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretSource. @@ -163,7 +157,6 @@ func (in *SelfSignedCertificate) DeepCopyInto(out *SelfSignedCertificate) { *out = make([]SubjectAlternativeName, len(*in)) copy(*out, *in) } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SelfSignedCertificate. @@ -181,7 +174,6 @@ func (in *ServiceTemplate) DeepCopyInto(out *ServiceTemplate) { *out = *in in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceTemplate. @@ -197,7 +189,6 @@ func (in *ServiceTemplate) DeepCopy() *ServiceTemplate { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SubjectAlternativeName) DeepCopyInto(out *SubjectAlternativeName) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubjectAlternativeName. @@ -219,7 +210,6 @@ func (in *TLSOptions) DeepCopyInto(out *TLSOptions) { (*in).DeepCopyInto(*out) } out.Certificate = in.Certificate - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TLSOptions. diff --git a/pkg/apis/elasticsearch/group.go b/pkg/apis/elasticsearch/group.go deleted file mode 100644 index e3e822c90b..0000000000 --- a/pkg/apis/elasticsearch/group.go +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// Package elasticsearch contains elasticsearch API versions -package elasticsearch diff --git a/pkg/apis/elasticsearch/v1alpha1/doc.go b/pkg/apis/elasticsearch/v1alpha1/doc.go deleted file mode 100644 index bccbfe0e2b..0000000000 --- a/pkg/apis/elasticsearch/v1alpha1/doc.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// Package v1alpha1 contains API Schema definitions for the elasticsearch v1alpha1 API group -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch -// +k8s:defaulter-gen=TypeMeta -// +groupName=elasticsearch.k8s.elastic.co -package v1alpha1 diff --git a/pkg/apis/elasticsearch/v1alpha1/elasticsearch_types.go b/pkg/apis/elasticsearch/v1alpha1/elasticsearch_types.go index 0e0629e1cf..5a79e0002d 100644 --- a/pkg/apis/elasticsearch/v1alpha1/elasticsearch_types.go +++ b/pkg/apis/elasticsearch/v1alpha1/elasticsearch_types.go @@ -42,7 +42,7 @@ type ElasticsearchSpec struct { // // The default budget selects all cluster pods and sets maxUnavailable to 1. // To disable it entirely, set to the empty value (`{}` in YAML). - // +optional + // +kubebuilder:validation:Optional PodDisruptionBudget *commonv1alpha1.PodDisruptionBudgetTemplate `json:"podDisruptionBudget,omitempty"` // SecureSettings references secrets containing secure settings, to be injected @@ -80,7 +80,7 @@ type NodeSpec struct { // PodTemplate can be used to propagate configuration to Elasticsearch pods. // This allows specifying custom annotations, labels, environment variables, // volumes, affinity, resources, etc. for the pods created from this NodeSpec. - // +optional + // +kubebuilder:validation:Optional PodTemplate corev1.PodTemplateSpec `json:"podTemplate,omitempty"` // VolumeClaimTemplates is a list of claims that pods are allowed to reference. @@ -89,7 +89,7 @@ type NodeSpec struct { // any volumes in the template, with the same name. // TODO: Define the behavior if a claim already exists with the same name. // TODO: define special behavior based on claim metadata.name. (e.g data / logs volumes) - // +optional + // +kubebuilder:validation:Optional VolumeClaimTemplates []corev1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty"` } @@ -214,11 +214,9 @@ func (es ElasticsearchStatus) IsDegraded(prev ElasticsearchStatus) bool { return es.Health.Less(prev.Health) } -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true // Elasticsearch is the Schema for the elasticsearches API -// +k8s:openapi-gen=true // +kubebuilder:subresource:status // +kubebuilder:resource:shortName=es // +kubebuilder:categories=elastic @@ -250,7 +248,7 @@ func (e Elasticsearch) Kind() string { return Kind } -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true // ElasticsearchList contains a list of Elasticsearch clusters type ElasticsearchList struct { @@ -260,7 +258,5 @@ type ElasticsearchList struct { } func init() { - SchemeBuilder.Register( - &Elasticsearch{}, &ElasticsearchList{}, - ) + SchemeBuilder.Register(&Elasticsearch{}, &ElasticsearchList{}) } diff --git a/pkg/apis/elasticsearch/v1alpha1/groupversion_info.go b/pkg/apis/elasticsearch/v1alpha1/groupversion_info.go new file mode 100644 index 0000000000..a14587346d --- /dev/null +++ b/pkg/apis/elasticsearch/v1alpha1/groupversion_info.go @@ -0,0 +1,24 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// Package v1 contains API Schema definitions for the batch v1 API group +// +kubebuilder:object:generate=true +// +groupName=elasticsearch.k8s.elastic.co +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "elasticsearch.k8s.elastic.co", Version: "v1alpha1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/pkg/apis/elasticsearch/v1alpha1/register.go b/pkg/apis/elasticsearch/v1alpha1/register.go deleted file mode 100644 index 40653e83bf..0000000000 --- a/pkg/apis/elasticsearch/v1alpha1/register.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// NOTE: Boilerplate only. Ignore this file. - -// Package v1alpha1 contains API Schema definitions for the elasticsearch v1alpha1 API group -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch -// +k8s:defaulter-gen=TypeMeta -// +groupName=elasticsearch.k8s.elastic.co -package v1alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/runtime/scheme" -) - -var ( - // SchemeGroupVersion is group version used to register these objects - SchemeGroupVersion = schema.GroupVersion{Group: "elasticsearch.k8s.elastic.co", Version: "v1alpha1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} - - // AddToScheme is required by pkg/client/... - AddToScheme = SchemeBuilder.AddToScheme -) - -// Resource is required by pkg/client/listers/... -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} diff --git a/pkg/apis/elasticsearch/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/elasticsearch/v1alpha1/zz_generated.deepcopy.go index 3faee55da5..a2e69fa357 100644 --- a/pkg/apis/elasticsearch/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/elasticsearch/v1alpha1/zz_generated.deepcopy.go @@ -4,20 +4,19 @@ // or more contributor license agreements. Licensed under the Elastic License; // you may not use this file except in compliance with the Elastic License. -// Code generated by main. DO NOT EDIT. +// Code generated by controller-gen. DO NOT EDIT. package v1alpha1 import ( commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" - v1 "k8s.io/api/core/v1" + "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ChangeBudget) DeepCopyInto(out *ChangeBudget) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChangeBudget. @@ -38,7 +37,6 @@ func (in *ClusterSettings) DeepCopyInto(out *ClusterSettings) { *out = make([]string, len(*in)) copy(*out, *in) } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSettings. @@ -58,7 +56,6 @@ func (in *Elasticsearch) DeepCopyInto(out *Elasticsearch) { in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) out.Status = in.Status - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Elasticsearch. @@ -91,7 +88,6 @@ func (in *ElasticsearchList) DeepCopyInto(out *ElasticsearchList) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ElasticsearchList. @@ -117,7 +113,6 @@ func (in *ElasticsearchSettings) DeepCopyInto(out *ElasticsearchSettings) { *out = *in out.Node = in.Node in.Cluster.DeepCopyInto(&out.Cluster) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ElasticsearchSettings. @@ -159,7 +154,6 @@ func (in *ElasticsearchSpec) DeepCopyInto(out *ElasticsearchSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ElasticsearchSpec. @@ -177,7 +171,6 @@ func (in *ElasticsearchStatus) DeepCopyInto(out *ElasticsearchStatus) { *out = *in out.ReconcilerStatus = in.ReconcilerStatus out.ZenDiscovery = in.ZenDiscovery - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ElasticsearchStatus. @@ -193,7 +186,6 @@ func (in *ElasticsearchStatus) DeepCopy() *ElasticsearchStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Node) DeepCopyInto(out *Node) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Node. @@ -221,7 +213,6 @@ func (in *NodeSpec) DeepCopyInto(out *NodeSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeSpec. @@ -242,7 +233,6 @@ func (in *UpdateStrategy) DeepCopyInto(out *UpdateStrategy) { *out = new(ChangeBudget) **out = **in } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpdateStrategy. @@ -258,7 +248,6 @@ func (in *UpdateStrategy) DeepCopy() *UpdateStrategy { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ZenDiscoveryStatus) DeepCopyInto(out *ZenDiscoveryStatus) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ZenDiscoveryStatus. diff --git a/pkg/apis/kibana/group.go b/pkg/apis/kibana/group.go deleted file mode 100644 index 905f42d54c..0000000000 --- a/pkg/apis/kibana/group.go +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// Package kibana contains kibana API versions -package kibana diff --git a/pkg/apis/kibana/v1alpha1/doc.go b/pkg/apis/kibana/v1alpha1/doc.go deleted file mode 100644 index b2583e7bfb..0000000000 --- a/pkg/apis/kibana/v1alpha1/doc.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// Package v1alpha1 contains API Schema definitions for the kibana v1alpha1 API group -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=github.com/elastic/cloud-on-k8s/pkg/apis/kibana -// +k8s:defaulter-gen=TypeMeta -// +groupName=kibana.k8s.elastic.co -package v1alpha1 diff --git a/pkg/apis/kibana/v1alpha1/groupversion_info.go b/pkg/apis/kibana/v1alpha1/groupversion_info.go new file mode 100644 index 0000000000..ff60a188bc --- /dev/null +++ b/pkg/apis/kibana/v1alpha1/groupversion_info.go @@ -0,0 +1,24 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// Package v1alpha1 contains API Schema definitions for the apm v1alpha1 API group +// +kubebuilder:object:generate=true +// +groupName=kibana.k8s.elastic.co +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "kibana.k8s.elastic.co", Version: "v1alpha1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/pkg/apis/kibana/v1alpha1/kibana_types.go b/pkg/apis/kibana/v1alpha1/kibana_types.go index 4a9711adbe..2d17cf0718 100644 --- a/pkg/apis/kibana/v1alpha1/kibana_types.go +++ b/pkg/apis/kibana/v1alpha1/kibana_types.go @@ -40,7 +40,7 @@ type KibanaSpec struct { // PodTemplate can be used to propagate configuration to Kibana pods. // This allows specifying custom annotations, labels, environment variables, // affinity, resources, etc. for the pods created from this NodeSpec. - // +optional + // +kubebuilder:validation:Optional PodTemplate corev1.PodTemplateSpec `json:"podTemplate,omitempty"` // SecureSettings references secrets containing secure settings, to be injected @@ -106,7 +106,6 @@ func (k *Kibana) SetAssociationConf(assocConf *commonv1alpha1.AssociationConf) { // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // Kibana is the Schema for the kibanas API -// +k8s:openapi-gen=true // +kubebuilder:categories=elastic // +kubebuilder:resource:shortName=kb // +kubebuilder:subresource:status @@ -123,7 +122,7 @@ type Kibana struct { assocConf *commonv1alpha1.AssociationConf } -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true // KibanaList contains a list of Kibana type KibanaList struct { diff --git a/pkg/apis/kibana/v1alpha1/register.go b/pkg/apis/kibana/v1alpha1/register.go deleted file mode 100644 index a590becadb..0000000000 --- a/pkg/apis/kibana/v1alpha1/register.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// NOTE: Boilerplate only. Ignore this file. - -// Package v1alpha1 contains API Schema definitions for the kibana v1alpha1 API group -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=github.com/elastic/cloud-on-k8s/pkg/apis/kibana -// +k8s:defaulter-gen=TypeMeta -// +groupName=kibana.k8s.elastic.co -package v1alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/runtime/scheme" -) - -var ( - // SchemeGroupVersion is group version used to register these objects - SchemeGroupVersion = schema.GroupVersion{Group: "kibana.k8s.elastic.co", Version: "v1alpha1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} - - // AddToScheme is required by pkg/client/... - AddToScheme = SchemeBuilder.AddToScheme -) - -// Resource is required by pkg/client/listers/... -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} diff --git a/pkg/apis/kibana/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/kibana/v1alpha1/zz_generated.deepcopy.go index c8d42427a5..02148dc1a6 100644 --- a/pkg/apis/kibana/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/kibana/v1alpha1/zz_generated.deepcopy.go @@ -4,7 +4,7 @@ // or more contributor license agreements. Licensed under the Elastic License; // you may not use this file except in compliance with the Elastic License. -// Code generated by main. DO NOT EDIT. +// Code generated by controller-gen. DO NOT EDIT. package v1alpha1 @@ -25,7 +25,6 @@ func (in *Kibana) DeepCopyInto(out *Kibana) { *out = new(commonv1alpha1.AssociationConf) **out = **in } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Kibana. @@ -58,7 +57,6 @@ func (in *KibanaList) DeepCopyInto(out *KibanaList) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KibanaList. @@ -96,7 +94,6 @@ func (in *KibanaSpec) DeepCopyInto(out *KibanaSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KibanaSpec. @@ -113,7 +110,6 @@ func (in *KibanaSpec) DeepCopy() *KibanaSpec { func (in *KibanaStatus) DeepCopyInto(out *KibanaStatus) { *out = *in out.ReconcilerStatus = in.ReconcilerStatus - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KibanaStatus. diff --git a/pkg/controller/add_apmserver.go b/pkg/controller/add_apmserver.go deleted file mode 100644 index 773e6024d0..0000000000 --- a/pkg/controller/add_apmserver.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package controller - -import ( - "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver" - "github.com/elastic/cloud-on-k8s/pkg/controller/common/operator" -) - -func init() { - // AddToManagerFuncs is a list of functions to create controllers and add them to a manager. - Register(operator.NamespaceOperator, apmserver.Add) -} diff --git a/pkg/controller/add_apmserverelasticsearchassociation.go b/pkg/controller/add_apmserverelasticsearchassociation.go deleted file mode 100644 index 0b01e56195..0000000000 --- a/pkg/controller/add_apmserverelasticsearchassociation.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package controller - -import ( - "github.com/elastic/cloud-on-k8s/pkg/controller/apmserverelasticsearchassociation" - "github.com/elastic/cloud-on-k8s/pkg/controller/common/operator" -) - -func init() { - Register(operator.NamespaceOperator, apmserverelasticsearchassociation.Add) -} diff --git a/pkg/controller/add_association.go b/pkg/controller/add_association.go deleted file mode 100644 index 7a90e3e3f3..0000000000 --- a/pkg/controller/add_association.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package controller - -import ( - "github.com/elastic/cloud-on-k8s/pkg/controller/common/operator" - "github.com/elastic/cloud-on-k8s/pkg/controller/kibanaassociation" -) - -func init() { - Register(operator.NamespaceOperator, kibanaassociation.Add) -} diff --git a/pkg/controller/add_elasticsearch.go b/pkg/controller/add_elasticsearch.go deleted file mode 100644 index 14aa336eb6..0000000000 --- a/pkg/controller/add_elasticsearch.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package controller - -import ( - "github.com/elastic/cloud-on-k8s/pkg/controller/common/operator" - "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch" -) - -func init() { - Register(operator.NamespaceOperator, elasticsearch.Add) -} diff --git a/pkg/controller/add_kibana.go b/pkg/controller/add_kibana.go deleted file mode 100644 index 50d811e70e..0000000000 --- a/pkg/controller/add_kibana.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package controller - -import ( - "github.com/elastic/cloud-on-k8s/pkg/controller/common/operator" - "github.com/elastic/cloud-on-k8s/pkg/controller/kibana" -) - -func init() { - Register(operator.NamespaceOperator, kibana.Add) -} diff --git a/pkg/controller/add_license.go b/pkg/controller/add_license.go deleted file mode 100644 index be221bb9c1..0000000000 --- a/pkg/controller/add_license.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package controller - -import ( - "github.com/elastic/cloud-on-k8s/pkg/controller/common/operator" - "github.com/elastic/cloud-on-k8s/pkg/controller/license" - "github.com/elastic/cloud-on-k8s/pkg/controller/license/trial" -) - -func init() { - Register(operator.GlobalOperator, license.Add) - Register(operator.GlobalOperator, trial.Add) -} diff --git a/pkg/controller/apmserver/apmserver_controller.go b/pkg/controller/apmserver/apmserver_controller.go index 435f265780..7d2174570d 100644 --- a/pkg/controller/apmserver/apmserver_controller.go +++ b/pkg/controller/apmserver/apmserver_controller.go @@ -36,7 +36,6 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - k8slabels "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/rand" @@ -89,7 +88,7 @@ func newReconciler(mgr manager.Manager, params operator.Parameters) *ReconcileAp return &ReconcileApmServer{ Client: client, scheme: mgr.GetScheme(), - recorder: mgr.GetRecorder(name), + recorder: mgr.GetEventRecorderFor(name), dynamicWatches: watches.NewDynamicWatches(), finalizers: finalizer.NewHandler(client), Parameters: params, @@ -213,7 +212,7 @@ func (r *ReconcileApmServer) Reconcile(request reconcile.Request) (reconcile.Res } func (r *ReconcileApmServer) isCompatible(as *apmv1alpha1.ApmServer) (bool, error) { - selector := k8slabels.Set(map[string]string{labels.ApmServerNameLabelName: as.Name}).AsSelector() + selector := map[string]string{labels.ApmServerNameLabelName: as.Name} compat, err := annotation.ReconcileCompatibility(r.Client, as, selector, r.OperatorInfo.BuildInfo.Version) if err != nil { k8s.EmitErrorEvent(r.recorder, err, as, events.EventCompatCheckError, "Error during compatibility check: %v", err) diff --git a/pkg/controller/apmserverelasticsearchassociation/apmserverelasticsearchassociation_controller.go b/pkg/controller/apmserverelasticsearchassociation/apmserverelasticsearchassociation_controller.go index 7c963ad439..f48b0c28c9 100644 --- a/pkg/controller/apmserverelasticsearchassociation/apmserverelasticsearchassociation_controller.go +++ b/pkg/controller/apmserverelasticsearchassociation/apmserverelasticsearchassociation_controller.go @@ -28,7 +28,6 @@ import ( "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - k8slabels "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" @@ -70,7 +69,7 @@ func newReconciler(mgr manager.Manager, params operator.Parameters) *ReconcileAp Client: client, scheme: mgr.GetScheme(), watches: watches.NewDynamicWatches(), - recorder: mgr.GetRecorder(name), + recorder: mgr.GetEventRecorderFor(name), Parameters: params, } } @@ -145,7 +144,7 @@ func (r *ReconcileApmServerElasticsearchAssociation) Reconcile(request reconcile err := handler.Handle( &apmServer, watchFinalizer(apmName, r.watches), - user.UserFinalizer(r.Client, NewUserLabelSelector(apmName), apmServer.Kind()), + user.UserFinalizer(r.Client, apmServer.Kind(), NewUserLabelSelector(apmName)), ) if err != nil { // failed to prepare finalizer or run finalizer: retry @@ -215,7 +214,7 @@ func resultFromStatus(status commonv1alpha1.AssociationStatus) reconcile.Result } func (r *ReconcileApmServerElasticsearchAssociation) isCompatible(apmServer *apmtype.ApmServer) (bool, error) { - selector := k8slabels.Set(map[string]string{labels.ApmServerNameLabelName: apmServer.Name}).AsSelector() + selector := map[string]string{labels.ApmServerNameLabelName: apmServer.Name} compat, err := annotation.ReconcileCompatibility(r.Client, apmServer, selector, r.OperatorInfo.BuildInfo.Version) if err != nil { k8s.EmitErrorEvent(r.recorder, err, apmServer, events.EventCompatCheckError, "Error during compatibility check: %v", err) @@ -341,8 +340,9 @@ func (r *ReconcileApmServerElasticsearchAssociation) reconcileElasticsearchCA(ap // combinations and deletes them. func deleteOrphanedResources(c k8s.Client, apm *apmtype.ApmServer) error { var secrets corev1.SecretList - selector := NewResourceSelector(apm.Name) - if err := c.List(&client.ListOptions{LabelSelector: selector}, &secrets); err != nil { + ns := client.InNamespace(apm.Namespace) + matchLabels := client.MatchingLabels(NewResourceLabels(apm.Name)) + if err := c.List(&secrets, ns, matchLabels); err != nil { return err } diff --git a/pkg/controller/apmserverelasticsearchassociation/apmserverelasticsearchassociation_controller_test.go b/pkg/controller/apmserverelasticsearchassociation/apmserverelasticsearchassociation_controller_test.go index 26c06711a7..3cf906dce9 100644 --- a/pkg/controller/apmserverelasticsearchassociation/apmserverelasticsearchassociation_controller_test.go +++ b/pkg/controller/apmserverelasticsearchassociation/apmserverelasticsearchassociation_controller_test.go @@ -8,7 +8,6 @@ import ( "testing" apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" - assoctype "github.com/elastic/cloud-on-k8s/pkg/apis/associations/v1alpha1" commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" @@ -53,9 +52,6 @@ var apmFixture = apmtype.ApmServer{ func setupScheme(t *testing.T) *runtime.Scheme { sc := scheme.Scheme - if err := assoctype.SchemeBuilder.AddToScheme(sc); err != nil { - assert.Fail(t, "failed to add assoc types") - } if err := apmtype.SchemeBuilder.AddToScheme(sc); err != nil { assert.Fail(t, "failed to add apm types") } diff --git a/pkg/controller/apmserverelasticsearchassociation/labels.go b/pkg/controller/apmserverelasticsearchassociation/labels.go index 56f5fac11d..6fda5c6ff4 100644 --- a/pkg/controller/apmserverelasticsearchassociation/labels.go +++ b/pkg/controller/apmserverelasticsearchassociation/labels.go @@ -7,8 +7,8 @@ package apmserverelasticsearchassociation import ( "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/user" - "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" ) const ( @@ -18,17 +18,15 @@ const ( AssociationLabelNamespace = "apmassociation.k8s.elastic.co/namespace" ) -// NewResourceSelector selects resources labeled as related to the named association. -func NewResourceSelector(name string) labels.Selector { - return labels.Set(map[string]string{ - AssociationLabelName: name, - }).AsSelector() +// NewResourceLabels returns the labels to identify an APM association +func NewResourceLabels(name string) map[string]string { + return map[string]string{AssociationLabelName: name} } func NewUserLabelSelector( namespacedName types.NamespacedName, -) labels.Selector { - return labels.SelectorFromSet( +) client.MatchingLabels { + return client.MatchingLabels( map[string]string{ AssociationLabelName: namespacedName.Name, AssociationLabelNamespace: namespacedName.Namespace, diff --git a/pkg/controller/common/annotation/controller_version.go b/pkg/controller/common/annotation/controller_version.go index fc7ca377a4..ec79a47172 100644 --- a/pkg/controller/common/annotation/controller_version.go +++ b/pkg/controller/common/annotation/controller_version.go @@ -10,7 +10,6 @@ import ( "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" - "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" ctrlclient "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -59,7 +58,7 @@ func UpdateControllerVersion(client k8s.Client, obj runtime.Object, version stri // controller versions 0.9.0+ cannot reconcile resources created with earlier controllers, so this lets our controller skip those resources until they can be manually recreated // if an object does not have an annotation, it will determine if it is a new object or if it has been previously reconciled by an older controller version, as this annotation // was not applied by earlier controller versions. it will update the object's annotations indicating it is incompatible if so -func ReconcileCompatibility(client k8s.Client, obj runtime.Object, selector labels.Selector, controllerVersion string) (bool, error) { +func ReconcileCompatibility(client k8s.Client, obj runtime.Object, selector map[string]string, controllerVersion string) (bool, error) { accessor := meta.NewAccessor() namespace, err := accessor.Namespace(obj) if err != nil { @@ -119,8 +118,9 @@ func ReconcileCompatibility(client k8s.Client, obj runtime.Object, selector labe return false, nil } -// checkExistingResources returns a bool indicating if there are existing resources created for a given resource -func checkExistingResources(client k8s.Client, obj runtime.Object, selector labels.Selector) (bool, error) { +// checkExistingResources returns a bool indicating if there are existing resources created for a given resource. +// The labels provided must exactly match. +func checkExistingResources(client k8s.Client, obj runtime.Object, labels map[string]string) (bool, error) { accessor := meta.NewAccessor() namespace, err := accessor.Namespace(obj) @@ -128,13 +128,11 @@ func checkExistingResources(client k8s.Client, obj runtime.Object, selector labe log.Error(err, "error getting namespace", "kind", obj.GetObjectKind().GroupVersionKind().Kind) return false, err } + labelSelector := ctrlclient.MatchingLabels(labels) + nsSelector := ctrlclient.InNamespace(namespace) // if there's no controller version annotation on the object, then we need to see maybe the object has been reconciled by an older, incompatible controller version - opts := ctrlclient.ListOptions{ - LabelSelector: selector, - Namespace: namespace, - } var svcs corev1.ServiceList - err = client.List(&opts, &svcs) + err = client.List(&svcs, labelSelector, nsSelector) if err != nil { return false, err } diff --git a/pkg/controller/common/annotation/controller_version_test.go b/pkg/controller/common/annotation/controller_version_test.go index d91435a863..e5921ab5a7 100644 --- a/pkg/controller/common/annotation/controller_version_test.go +++ b/pkg/controller/common/annotation/controller_version_test.go @@ -15,13 +15,11 @@ import ( "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client/fake" apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" - assoctype "github.com/elastic/cloud-on-k8s/pkg/apis/associations/v1alpha1" "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" "k8s.io/client-go/kubernetes/scheme" @@ -198,9 +196,7 @@ func TestNewerAnnotation(t *testing.T) { // setupScheme creates a scheme to use for our fake clients so they know about our custom resources func setupScheme(t *testing.T) *runtime.Scheme { sc := scheme.Scheme - err := assoctype.SchemeBuilder.AddToScheme(sc) - require.NoError(t, err) - err = apmtype.SchemeBuilder.AddToScheme(sc) + err := apmtype.AddToScheme(sc) require.NoError(t, err) err = estype.SchemeBuilder.AddToScheme(sc) require.NoError(t, err) @@ -209,6 +205,6 @@ func setupScheme(t *testing.T) *runtime.Scheme { return sc } -func getElasticsearchSelector(es *v1alpha1.Elasticsearch) labels.Selector { - return labels.Set(map[string]string{label.ClusterNameLabelName: es.Name}).AsSelector() +func getElasticsearchSelector(es *v1alpha1.Elasticsearch) map[string]string { + return map[string]string{label.ClusterNameLabelName: es.Name} } diff --git a/pkg/controller/common/annotation/pod.go b/pkg/controller/common/annotation/pod.go index 78e8af917d..5ca68cff50 100644 --- a/pkg/controller/common/annotation/pod.go +++ b/pkg/controller/common/annotation/pod.go @@ -26,16 +26,13 @@ var ( // MarkPodsAsUpdated updates a specific annotation on the pods to speedup secret propagation. func MarkPodsAsUpdated( c k8s.Client, - podListOptions client.ListOptions, + podListOptions ...client.ListOption, ) { // Get all pods var podList corev1.PodList - err := c.List(&podListOptions, &podList) + err := c.List(&podList, podListOptions...) if err != nil { - log.Error( - err, "failed to list pods for annotation update", - "namespace", podListOptions.Namespace, - ) + log.Error(err, "failed to list pods for annotation update") return } // Update annotation diff --git a/pkg/controller/common/association/association.go b/pkg/controller/common/association/association.go index 94c0a7a1da..7f4224518c 100644 --- a/pkg/controller/common/association/association.go +++ b/pkg/controller/common/association/association.go @@ -5,7 +5,7 @@ package association import ( - "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" @@ -15,7 +15,7 @@ import ( // against an Elasticsearch cluster. func ElasticsearchAuthSettings( c k8s.Client, - associated v1alpha1.Associated, + associated commonv1alpha1.Associated, ) (username, password string, err error) { assocConf := associated.AssociationConf() if !assocConf.AuthIsConfigured() { diff --git a/pkg/controller/common/association/ca.go b/pkg/controller/common/association/ca.go index 7cb7451db4..710d55e8e6 100644 --- a/pkg/controller/common/association/ca.go +++ b/pkg/controller/common/association/ca.go @@ -7,7 +7,7 @@ package association import ( "reflect" - "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates" "github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates/http" "github.com/elastic/cloud-on-k8s/pkg/controller/common/reconciler" @@ -28,7 +28,7 @@ type CASecret struct { // ElasticsearchCACertSecretName returns the name of the secret holding the certificate chain used // by the associated resource to establish and validate a secured HTTP connection to Elasticsearch. -func ElasticsearchCACertSecretName(associated v1alpha1.Associated, suffix string) string { +func ElasticsearchCACertSecretName(associated commonv1alpha1.Associated, suffix string) string { return associated.GetName() + "-" + suffix } @@ -37,7 +37,7 @@ func ElasticsearchCACertSecretName(associated v1alpha1.Associated, suffix string func ReconcileCASecret( client k8s.Client, scheme *runtime.Scheme, - associated v1alpha1.Associated, + associated commonv1alpha1.Associated, es types.NamespacedName, labels map[string]string, suffix string, diff --git a/pkg/controller/common/association/user_test.go b/pkg/controller/common/association/user_test.go index 20cba63a5c..e7a6fb9555 100644 --- a/pkg/controller/common/association/user_test.go +++ b/pkg/controller/common/association/user_test.go @@ -24,7 +24,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" - "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" ) @@ -150,7 +149,7 @@ func Test_reconcileEsUser(t *testing.T) { wantErr: false, postCondition: func(c k8s.Client) { list := corev1.SecretList{} - assert.NoError(t, c.List(&client.ListOptions{}, &list)) + assert.NoError(t, c.List(&list)) assert.Equal(t, 3, len(list.Items)) s := user.GetSecret(list, types.NamespacedName{Namespace: "other", Name: userSecretName}) assert.NotNil(t, s) diff --git a/pkg/controller/common/license/crud.go b/pkg/controller/common/license/crud.go index 0f71e0c2ed..b937e28d37 100644 --- a/pkg/controller/common/license/crud.go +++ b/pkg/controller/common/license/crud.go @@ -15,15 +15,13 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" utilerrors "k8s.io/apimachinery/pkg/util/errors" - "sigs.k8s.io/controller-runtime/pkg/client" ) // EnterpriseLicensesOrErrors lists all Enterprise licenses and all errors encountered during retrieval. func EnterpriseLicensesOrErrors(c k8s.Client) ([]EnterpriseLicense, []error) { licenseList := corev1.SecretList{} - err := c.List(&client.ListOptions{ - LabelSelector: NewLicenseByTypeSelector(string(LicenseTypeEnterprise)), - }, &licenseList) + matchingLabels := NewLicenseByTypeSelector(string(LicenseTypeEnterprise)) + err := c.List(&licenseList, matchingLabels) if err != nil { return nil, []error{err} } diff --git a/pkg/controller/common/license/fixtures_test.go b/pkg/controller/common/license/fixtures_test.go index 5dd8059f81..67fa829c67 100644 --- a/pkg/controller/common/license/fixtures_test.go +++ b/pkg/controller/common/license/fixtures_test.go @@ -10,6 +10,7 @@ import ( "encoding/json" "testing" + "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -45,6 +46,10 @@ func asRuntimeObjects(l EnterpriseLicense, sig []byte) []runtime.Object { ObjectMeta: metav1.ObjectMeta{ Namespace: "test-system", Name: "test-license", + Labels: map[string]string{ + common.TypeLabelName: Type, + LicenseLabelType: string(l.License.Type), + }, }, Data: map[string][]byte{ FileName: bytes, diff --git a/pkg/controller/common/license/labels.go b/pkg/controller/common/license/labels.go index 750ac527fe..41b68042b0 100644 --- a/pkg/controller/common/license/labels.go +++ b/pkg/controller/common/license/labels.go @@ -6,7 +6,7 @@ package license import ( "github.com/elastic/cloud-on-k8s/pkg/controller/common" - "k8s.io/apimachinery/pkg/labels" + "sigs.k8s.io/controller-runtime/pkg/client" ) const ( @@ -36,14 +36,14 @@ func LabelsForType(licenseType LicenseType) map[string]string { } // NewLicenseByNameSelector is a list selector to filter by a label containing the license name. -func NewLicenseByNameSelector(licenseName string) labels.Selector { - return labels.Set(map[string]string{ +func NewLicenseByNameSelector(licenseName string) client.MatchingLabels { + return client.MatchingLabels(map[string]string{ LicenseLabelName: licenseName, - }).AsSelector() + }) } -func NewLicenseByTypeSelector(licenseType string) labels.Selector { - return labels.Set(map[string]string{ +func NewLicenseByTypeSelector(licenseType string) client.MatchingLabels { + return client.MatchingLabels(map[string]string{ LicenseLabelType: licenseType, - }).AsSelector() + }) } diff --git a/pkg/controller/common/license/model_test.go b/pkg/controller/common/license/model_test.go index 0bb6c77456..5cb56a20f6 100644 --- a/pkg/controller/common/license/model_test.go +++ b/pkg/controller/common/license/model_test.go @@ -10,12 +10,11 @@ import ( "testing" "time" - "github.com/elastic/cloud-on-k8s/pkg/apis" + controllerscheme "github.com/elastic/cloud-on-k8s/pkg/controller/common/scheme" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client" "github.com/elastic/cloud-on-k8s/pkg/utils/chrono" "github.com/go-test/deep" "github.com/stretchr/testify/require" - "k8s.io/client-go/kubernetes/scheme" ) func TestLicense_IsValidAt(t *testing.T) { @@ -138,7 +137,7 @@ var expectedLicenseSpec = EnterpriseLicense{ } func Test_unmarshalModel(t *testing.T) { - require.NoError(t, apis.AddToScheme(scheme.Scheme)) + _ = controllerscheme.SetupScheme() type args struct { licenseFile string } diff --git a/pkg/controller/common/license/trial_test.go b/pkg/controller/common/license/trial_test.go index 5676aebfae..0ed603ae24 100644 --- a/pkg/controller/common/license/trial_test.go +++ b/pkg/controller/common/license/trial_test.go @@ -19,6 +19,7 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernetes/scheme" + "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" ) @@ -26,7 +27,7 @@ type failingClient struct { k8s.Client } -func (failingClient) Create(o runtime.Object) error { +func (failingClient) Create(o runtime.Object, opts ...client.CreateOption) error { return errors.New("boom") } diff --git a/pkg/controller/common/scheme/scheme.go b/pkg/controller/common/scheme/scheme.go new file mode 100644 index 0000000000..70241c7929 --- /dev/null +++ b/pkg/controller/common/scheme/scheme.go @@ -0,0 +1,32 @@ +package scheme + +import ( + apmv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" + commonv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1alpha1" + esv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" + kbv1alpha1 "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" + clientgoscheme "k8s.io/client-go/kubernetes/scheme" +) + +// SetupScheme sets up a scheme with all of the relevant types. This is only needed once for the manager but is often used for tests +// Afterwards you can use clientgoscheme.Scheme +func SetupScheme() error { + err := clientgoscheme.AddToScheme(clientgoscheme.Scheme) + if err != nil { + return err + } + err = apmv1alpha1.AddToScheme(clientgoscheme.Scheme) + if err != nil { + return err + } + err = commonv1alpha1.AddToScheme(clientgoscheme.Scheme) + if err != nil { + return err + } + err = esv1alpha1.AddToScheme(clientgoscheme.Scheme) + if err != nil { + return err + } + err = kbv1alpha1.AddToScheme(clientgoscheme.Scheme) + return err +} diff --git a/pkg/controller/common/user/finalizer.go b/pkg/controller/common/user/finalizer.go index 71c8280f98..2dfd71da88 100644 --- a/pkg/controller/common/user/finalizer.go +++ b/pkg/controller/common/user/finalizer.go @@ -11,17 +11,16 @@ import ( "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" "sigs.k8s.io/controller-runtime/pkg/client" ) // UserFinalizer ensures that any external user created for an associated object is removed. -func UserFinalizer(c k8s.Client, selector labels.Selector, kind string) finalizer.Finalizer { +func UserFinalizer(c k8s.Client, kind string, opts ...client.ListOption) finalizer.Finalizer { return finalizer.Finalizer{ Name: "finalizer.association." + strings.ToLower(kind) + ".k8s.elastic.co/external-user", Execute: func() error { var secrets corev1.SecretList - if err := c.List(&client.ListOptions{LabelSelector: selector}, &secrets); err != nil { + if err := c.List(&secrets, opts...); err != nil { return err } for _, s := range secrets.Items { diff --git a/pkg/controller/common/user/label.go b/pkg/controller/common/user/label.go index 726c09e1d3..f274f19630 100644 --- a/pkg/controller/common/user/label.go +++ b/pkg/controller/common/user/label.go @@ -8,8 +8,9 @@ import ( "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" - "k8s.io/apimachinery/pkg/labels" + "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" ) @@ -21,12 +22,8 @@ const ( // NewLabelSelectorForElasticsearch returns a labels.Selector that matches the labels as constructed by // NewLabels for the provided cluster name and of for a resource of type "user" -func NewLabelSelectorForElasticsearch(es v1alpha1.Elasticsearch) labels.Selector { - return labels.SelectorFromSet( - map[string]string{ - label.ClusterNameLabelName: es.Name, - common.TypeLabelName: UserType, - }) +func NewLabelSelectorForElasticsearch(es v1alpha1.Elasticsearch) client.MatchingLabels { + return client.MatchingLabels(NewLabels(k8s.ExtractNamespacedName(&es))) } // NewLabels constructs a new set of labels from an Elasticsearch cluster name for a resource of type "user". diff --git a/pkg/controller/common/watches/handler.go b/pkg/controller/common/watches/handler.go index 55f623bf8c..fea9ad0980 100644 --- a/pkg/controller/common/watches/handler.go +++ b/pkg/controller/common/watches/handler.go @@ -8,6 +8,7 @@ import ( "sync" "github.com/pkg/errors" + "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/util/workqueue" "sigs.k8s.io/controller-runtime/pkg/event" @@ -42,6 +43,8 @@ type DynamicEnqueueRequest struct { mutex sync.RWMutex registrations map[string]HandlerRegistration scheme *runtime.Scheme + // mapper maps GroupVersionKinds to Resources + mapper meta.RESTMapper } // AddHandlers adds the new event handlers to this DynamicEnqueueRequest. @@ -65,6 +68,10 @@ func (d *DynamicEnqueueRequest) AddHandler(handler HandlerRegistration) error { log.Error(err, "Failed to add handler to dynamic enqueue request") return err } + if _, err := inject.MapperInto(d.mapper, handler); err != nil { + log.Error(err, "Failed to add mapper to dynamic enqueue request") + return err + } _, exists := d.registrations[handler.Key()] if !exists { log.V(1).Info("Adding new handler registration", "key", handler.Key(), "current_registrations", d.registrations) @@ -144,3 +151,11 @@ func (d *DynamicEnqueueRequest) InjectScheme(scheme *runtime.Scheme) error { } var _ inject.Scheme = &DynamicEnqueueRequest{} + +// InjectMapper is called by the Controller to provide the rest mapper used by the manager. +func (d *DynamicEnqueueRequest) InjectMapper(m meta.RESTMapper) error { + d.mapper = m + return nil +} + +var _ inject.Mapper = &DynamicEnqueueRequest{} diff --git a/pkg/controller/common/watches/handler_test.go b/pkg/controller/common/watches/handler_test.go index 5555bd4325..ecf7f3f881 100644 --- a/pkg/controller/common/watches/handler_test.go +++ b/pkg/controller/common/watches/handler_test.go @@ -7,18 +7,20 @@ package watches import ( "testing" + "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/restmapper" "k8s.io/client-go/util/workqueue" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" - - "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" ) type fakeHandler struct { @@ -150,6 +152,7 @@ func TestDynamicEnqueueRequest_EventHandler(t *testing.T) { d := NewDynamicEnqueueRequest() require.NoError(t, d.InjectScheme(scheme.Scheme)) + require.NoError(t, d.InjectMapper(getRESTMapper())) q := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()) assertEmptyQueue := func() { @@ -352,3 +355,97 @@ func TestDynamicEnqueueRequest_EventHandler(t *testing.T) { req2 := getReconcileReqFromQueue() require.ElementsMatch(t, expected, []types.NamespacedName{req1.NamespacedName, req2.NamespacedName}) } + +func TestDynamicEnqueueRequest_OwnerWatch(t *testing.T) { + // Fixtures + nsn1 := types.NamespacedName{ + Namespace: "default", + Name: "watched1", + } + testObject1 := &corev1.Secret{ + ObjectMeta: k8s.ToObjectMeta(nsn1), + } + updated1 := testObject1 + updated1.Labels = map[string]string{"updated": "1"} + + nsn2 := types.NamespacedName{ + Namespace: "default", + Name: "watched2", + } + testObject2 := &corev1.Secret{ + ObjectMeta: k8s.ToObjectMeta(nsn2), + } + updated2 := testObject2 + updated2.Labels = map[string]string{"updated": "2"} + + d := NewDynamicEnqueueRequest() + require.NoError(t, d.InjectScheme(scheme.Scheme)) + require.NoError(t, d.InjectMapper(getRESTMapper())) + q := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()) + + assertEmptyQueue := func() { + require.Equal(t, 0, q.Len()) + } + getReconcileReqFromQueue := func() reconcile.Request { + item, shutdown := q.Get() + defer q.Done(item) + require.False(t, shutdown) + req, ok := item.(reconcile.Request) + require.True(t, ok) + return req + } + assertReconcileReq := func(nsn types.NamespacedName) { + require.Equal(t, getReconcileReqFromQueue().NamespacedName, nsn) + } + + assertEmptyQueue() + // setup an owner watch where owner is testObject1 + require.NoError(t, d.AddHandler(&OwnerWatch{ + EnqueueRequestForOwner: handler.EnqueueRequestForOwner{ + OwnerType: testObject1, + IsController: true, + }, + })) + // END FIXTURES + + require.NoError(t, controllerutil.SetControllerReference(testObject1, testObject2, scheme.Scheme)) + + d.Create(event.CreateEvent{ + Meta: testObject1.GetObjectMeta(), + Object: testObject1, + }, q) + d.Create(event.CreateEvent{ + Meta: testObject2.GetObjectMeta(), + Object: testObject2, + }, q) + + // an update on object 2 should enqueue a request for object 1 (the owner) + d.Update(event.UpdateEvent{ + MetaOld: testObject2.GetObjectMeta(), + ObjectOld: testObject2, + MetaNew: updated2.GetObjectMeta(), + ObjectNew: updated2, + }, q) + assertReconcileReq(nsn1) +} + +// getRESTMapper returns a RESTMapper used to inject a mapper into a dynamic queue request +func getRESTMapper() meta.RESTMapper { + resources := []*restmapper.APIGroupResources{ + { + Group: metav1.APIGroup{ + Versions: []metav1.GroupVersionForDiscovery{ + {Version: "v1"}, + }, + PreferredVersion: metav1.GroupVersionForDiscovery{Version: "v1"}, + }, + VersionedResources: map[string][]metav1.APIResource{ + "v1": { + {Name: "secrets", Namespaced: true, Kind: "Secret"}, + }, + }, + }, + } + + return restmapper.NewDiscoveryRESTMapper(resources) +} diff --git a/pkg/controller/elasticsearch/certificates/transport/reconcile.go b/pkg/controller/elasticsearch/certificates/transport/reconcile.go index 0e6111e0f2..6b0e2bcab2 100644 --- a/pkg/controller/elasticsearch/certificates/transport/reconcile.go +++ b/pkg/controller/elasticsearch/certificates/transport/reconcile.go @@ -36,10 +36,9 @@ func ReconcileTransportCertificatesSecrets( rotationParams certificates.RotationParams, ) (reconcile.Result, error) { var pods corev1.PodList - if err := c.List(&client.ListOptions{ - LabelSelector: label.NewLabelSelectorForElasticsearch(es), - Namespace: es.Namespace, - }, &pods); err != nil { + matchLabels := label.NewLabelSelectorForElasticsearch(es) + ns := client.InNamespace(es.Namespace) + if err := c.List(&pods, matchLabels, ns); err != nil { return reconcile.Result{}, err } diff --git a/pkg/controller/elasticsearch/cleanup/resources.go b/pkg/controller/elasticsearch/cleanup/resources.go index 4735df887f..e04de13782 100644 --- a/pkg/controller/elasticsearch/cleanup/resources.go +++ b/pkg/controller/elasticsearch/cleanup/resources.go @@ -37,10 +37,9 @@ func IsTooYoungForGC(object metav1.Object) bool { // DeleteOrphanedSecrets cleans up secrets that are not needed anymore for the given es cluster. func DeleteOrphanedSecrets(c k8s.Client, es v1alpha1.Elasticsearch) error { var secrets corev1.SecretList - if err := c.List(&client.ListOptions{ - Namespace: es.Namespace, - LabelSelector: label.NewLabelSelectorForElasticsearch(es), - }, &secrets); err != nil { + ns := client.InNamespace(es.Namespace) + matchLabels := label.NewLabelSelectorForElasticsearch(es) + if err := c.List(&secrets, ns, matchLabels); err != nil { return err } resources := make([]runtime.Object, len(secrets.Items)) diff --git a/pkg/controller/elasticsearch/cleanup/resources_test.go b/pkg/controller/elasticsearch/cleanup/resources_test.go index e84e9ad594..d24fc65d24 100644 --- a/pkg/controller/elasticsearch/cleanup/resources_test.go +++ b/pkg/controller/elasticsearch/cleanup/resources_test.go @@ -15,7 +15,6 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/scheme" - "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" ) @@ -151,7 +150,7 @@ func TestDeleteOrphanedSecrets(t *testing.T) { require.NoError(t, err) // the correct number of secrets should remain in the cache var secrets corev1.SecretList - err = tt.client.List(&client.ListOptions{}, &secrets) + err = tt.client.List(&secrets) require.NoError(t, err) require.Equal(t, len(tt.secretsAfterCleanup), len(secrets.Items)) // remaining secret should be the expected ones diff --git a/pkg/controller/elasticsearch/driver/downscale_test.go b/pkg/controller/elasticsearch/driver/downscale_test.go index ed64525b75..c906378b0e 100644 --- a/pkg/controller/elasticsearch/driver/downscale_test.go +++ b/pkg/controller/elasticsearch/driver/downscale_test.go @@ -15,7 +15,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernetes/scheme" - "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" @@ -34,60 +33,81 @@ import ( // Sample StatefulSets to use in tests var ( - clusterName = "cluster" - ssetMaster3Replicas = sset.TestSset{Name: "ssetMaster3Replicas", Version: "7.2.0", Replicas: 3, Master: true, Data: false}.Build() + clusterName = "cluster-name" + ssetMaster3Replicas = sset.TestSset{ + Name: "ssetMaster3Replicas", + Namespace: "ns", + Version: "7.2.0", + Replicas: 3, + Master: true, + Data: false, + }.Build() podsSsetMaster3Replicas = []corev1.Pod{ sset.TestPod{ - Namespace: ssetMaster3Replicas.Namespace, - Name: sset.PodName(ssetMaster3Replicas.Name, 0), - ClusterName: clusterName, - Version: "7.2.0", - Master: true, + Namespace: ssetMaster3Replicas.Namespace, + Name: sset.PodName(ssetMaster3Replicas.Name, 0), + StatefulSetName: ssetMaster3Replicas.Name, + ClusterName: clusterName, + Version: "7.2.0", + Master: true, }.Build(), sset.TestPod{ - Namespace: ssetMaster3Replicas.Namespace, - Name: sset.PodName(ssetMaster3Replicas.Name, 1), - ClusterName: clusterName, - Version: "7.2.0", - Master: true, + Namespace: ssetMaster3Replicas.Namespace, + Name: sset.PodName(ssetMaster3Replicas.Name, 1), + StatefulSetName: ssetMaster3Replicas.Name, + ClusterName: clusterName, + Version: "7.2.0", + Master: true, }.Build(), sset.TestPod{ - Namespace: ssetMaster3Replicas.Namespace, - Name: sset.PodName(ssetMaster3Replicas.Name, 2), - ClusterName: clusterName, - Version: "7.2.0", - Master: true, + Namespace: ssetMaster3Replicas.Namespace, + Name: sset.PodName(ssetMaster3Replicas.Name, 2), + StatefulSetName: ssetMaster3Replicas.Name, + ClusterName: clusterName, + Version: "7.2.0", + Master: true, }.Build(), } - ssetData4Replicas = sset.TestSset{Name: "ssetData4Replicas", Version: "7.2.0", Replicas: 4, Master: false, Data: true}.Build() + ssetData4Replicas = sset.TestSset{ + Name: "ssetData4Replicas", + Namespace: "ns", + Version: "7.2.0", + Replicas: 4, + Master: false, + Data: true, + }.Build() podsSsetData4Replicas = []corev1.Pod{ sset.TestPod{ - Namespace: ssetData4Replicas.Namespace, - Name: sset.PodName(ssetData4Replicas.Name, 0), - ClusterName: clusterName, - Version: "7.2.0", - Data: true, + Namespace: ssetData4Replicas.Namespace, + Name: sset.PodName(ssetData4Replicas.Name, 0), + StatefulSetName: ssetData4Replicas.Name, + ClusterName: clusterName, + Version: "7.2.0", + Data: true, }.Build(), sset.TestPod{ - Namespace: ssetData4Replicas.Namespace, - Name: sset.PodName(ssetData4Replicas.Name, 1), - ClusterName: clusterName, - Version: "7.2.0", - Data: true, + Namespace: ssetData4Replicas.Namespace, + Name: sset.PodName(ssetData4Replicas.Name, 1), + StatefulSetName: ssetData4Replicas.Name, + ClusterName: clusterName, + Version: "7.2.0", + Data: true, }.Build(), sset.TestPod{ - Namespace: ssetData4Replicas.Namespace, - Name: sset.PodName(ssetData4Replicas.Name, 2), - ClusterName: clusterName, - Version: "7.2.0", - Data: true, + Namespace: ssetData4Replicas.Namespace, + Name: sset.PodName(ssetData4Replicas.Name, 2), + StatefulSetName: ssetData4Replicas.Name, + ClusterName: clusterName, + Version: "7.2.0", + Data: true, }.Build(), sset.TestPod{ - Namespace: ssetData4Replicas.Namespace, - Name: sset.PodName(ssetData4Replicas.Name, 3), - ClusterName: clusterName, - Version: "7.2.0", - Data: true, + Namespace: ssetData4Replicas.Namespace, + Name: sset.PodName(ssetData4Replicas.Name, 3), + StatefulSetName: ssetData4Replicas.Name, + ClusterName: clusterName, + Version: "7.2.0", + Data: true, }.Build(), } runtimeObjs = []runtime.Object{&ssetMaster3Replicas, &ssetData4Replicas, @@ -116,7 +136,7 @@ func TestHandleDownscale(t *testing.T) { reconcileState: reconcile.NewState(v1alpha1.Elasticsearch{}), observedState: observer.State{ ClusterState: &esclient.ClusterState{ - ClusterName: "cluster-name", + ClusterName: clusterName, Nodes: map[string]esclient.ClusterStateNode{ // nodes from 1st sset "ssetMaster3Replicas-0": {Name: "ssetMaster3Replicas-0"}, @@ -143,6 +163,12 @@ func TestHandleDownscale(t *testing.T) { }, }, esClient: esClient, + es: v1alpha1.Elasticsearch{ + ObjectMeta: metav1.ObjectMeta{ + Name: clusterName, + Namespace: "ns", + }, + }, } // request master nodes downscale from 3 to 1 replicas @@ -182,7 +208,7 @@ func TestHandleDownscale(t *testing.T) { // compare what has been updated in the apiserver with what we would expect var actual appsv1.StatefulSetList - err := k8sClient.List(&client.ListOptions{}, &actual) + err := k8sClient.List(&actual) require.NoError(t, err) require.Equal(t, expectedAfterDownscale, actual.Items) @@ -199,7 +225,7 @@ func TestHandleDownscale(t *testing.T) { // one less master nodespec.UpdateReplicas(&ssetMaster3ReplicasExpectedAfterDownscale, common.Int32(1)) expectedAfterDownscale = []appsv1.StatefulSet{ssetMaster3ReplicasExpectedAfterDownscale, ssetData4ReplicasExpectedAfterDownscale} - err = k8sClient.List(&client.ListOptions{}, &actual) + err = k8sClient.List(&actual) require.NoError(t, err) require.Equal(t, expectedAfterDownscale, actual.Items) // simulate master pod deletion @@ -211,7 +237,7 @@ func TestHandleDownscale(t *testing.T) { results = HandleDownscale(downscaleCtx, requestedStatefulSets, actual.Items) require.False(t, results.HasError()) require.Equal(t, emptyResults, results) - err = k8sClient.List(&client.ListOptions{}, &actual) + err = k8sClient.List(&actual) require.NoError(t, err) require.Equal(t, expectedAfterDownscale, actual.Items) @@ -226,7 +252,7 @@ func TestHandleDownscale(t *testing.T) { results = HandleDownscale(downscaleCtx, requestedStatefulSets, actual.Items) require.False(t, results.HasError()) require.Equal(t, emptyResults, results) - err = k8sClient.List(&client.ListOptions{}, &actual) + err = k8sClient.List(&actual) require.NoError(t, err) require.Equal(t, expectedAfterDownscale, actual.Items) @@ -645,7 +671,7 @@ func Test_attemptDownscale(t *testing.T) { require.NoError(t, err) // retrieve statefulsets var ssets appsv1.StatefulSetList - err = k8sClient.List(&client.ListOptions{}, &ssets) + err = k8sClient.List(&ssets) require.NoError(t, err) require.Equal(t, tt.expectedStatefulSets, ssets.Items) }) @@ -685,7 +711,7 @@ func Test_doDownscale_updateReplicasAndExpectations(t *testing.T) { // sset resource should be updated var ssets appsv1.StatefulSetList - err = k8sClient.List(&client.ListOptions{}, &ssets) + err = k8sClient.List(&ssets) require.NoError(t, err) require.Equal(t, []appsv1.StatefulSet{expectedSset1, sset2}, ssets.Items) @@ -697,8 +723,24 @@ func Test_doDownscale_updateReplicasAndExpectations(t *testing.T) { } func Test_doDownscale_zen2VotingConfigExclusions(t *testing.T) { - ssetMasters := sset.TestSset{Name: "masters", Version: "7.1.0", Replicas: 3, Master: true, Data: false}.Build() - ssetData := sset.TestSset{Name: "datas", Version: "7.1.0", Replicas: 3, Master: false, Data: true}.Build() + ssetMasters := sset.TestSset{ + Name: "masters", + Namespace: "ns", + ClusterName: "es", + Version: "7.1.0", + Replicas: 3, + Master: true, + Data: false, + }.Build() + ssetData := sset.TestSset{ + Name: "datas", + Namespace: "ns", + ClusterName: "es", + Version: "7.1.0", + Replicas: 3, + Master: false, + Data: true, + }.Build() tests := []struct { name string downscale ssetDownscale @@ -742,6 +784,7 @@ func Test_doDownscale_zen2VotingConfigExclusions(t *testing.T) { label.ClusterNameLabelName: es.Name, string(label.NodeTypesMasterLabelName): "true", label.VersionLabelName: "7.1.0", + label.StatefulSetNameLabelName: ssetMasters.Name, }, }, } @@ -752,6 +795,7 @@ func Test_doDownscale_zen2VotingConfigExclusions(t *testing.T) { expectations: expectations.NewExpectations(), reconcileState: reconcile.NewState(v1alpha1.Elasticsearch{}), esClient: esClient, + es: es, } // do the downscale err := doDownscale(downscaleCtx, tt.downscale, sset.StatefulSetList{ssetMasters, ssetData}) @@ -848,6 +892,7 @@ func Test_doDownscale_zen1MinimumMasterNodes(t *testing.T) { expectations: expectations.NewExpectations(), reconcileState: reconcile.NewState(v1alpha1.Elasticsearch{}), esClient: esClient, + es: es, } // do the downscale err := doDownscale(downscaleCtx, tt.downscale, tt.statefulSets) diff --git a/pkg/controller/elasticsearch/driver/fixtures.go b/pkg/controller/elasticsearch/driver/fixtures.go index c747e08def..be62f6bb5a 100644 --- a/pkg/controller/elasticsearch/driver/fixtures.go +++ b/pkg/controller/elasticsearch/driver/fixtures.go @@ -27,7 +27,9 @@ const ( ) type testPod struct { - name, version string + name string + version string + ssetName string master, data, healthy, toUpgrade, inCluster, terminating bool uid types.UID } @@ -39,13 +41,14 @@ func newTestPod(name string) testPod { } } -func (t testPod) isMaster(v bool) testPod { t.master = v; return t } -func (t testPod) isData(v bool) testPod { t.data = v; return t } -func (t testPod) isInCluster(v bool) testPod { t.inCluster = v; return t } -func (t testPod) isHealthy(v bool) testPod { t.healthy = v; return t } -func (t testPod) needsUpgrade(v bool) testPod { t.toUpgrade = v; return t } -func (t testPod) isTerminating(v bool) testPod { t.terminating = v; return t } -func (t testPod) withVersion(v string) testPod { t.version = v; return t } +func (t testPod) isMaster(v bool) testPod { t.master = v; return t } +func (t testPod) isData(v bool) testPod { t.data = v; return t } +func (t testPod) isInCluster(v bool) testPod { t.inCluster = v; return t } +func (t testPod) isHealthy(v bool) testPod { t.healthy = v; return t } +func (t testPod) needsUpgrade(v bool) testPod { t.toUpgrade = v; return t } +func (t testPod) isTerminating(v bool) testPod { t.terminating = v; return t } +func (t testPod) withVersion(v string) testPod { t.version = v; return t } +func (t testPod) inStatefulset(ssetName string) testPod { t.ssetName = ssetName; return t } //nolint:unparam // filter to simulate a Pod that has been removed while upgrading // unfortunately fake client does not support predicate @@ -107,6 +110,10 @@ func newUpgradeTestPods(pods ...testPod) upgradeTestPods { func (u upgradeTestPods) toES(maxUnavailable int) v1alpha1.Elasticsearch { return v1alpha1.Elasticsearch{ + ObjectMeta: metav1.ObjectMeta{ + Name: TestEsName, + Namespace: TestEsNamespace, + }, Spec: v1alpha1.ElasticsearchSpec{ UpdateStrategy: v1alpha1.UpdateStrategy{ ChangeBudget: &v1alpha1.ChangeBudget{ @@ -137,7 +144,7 @@ func (u upgradeTestPods) toStatefulSetList() sset.StatefulSetList { statefulSetList := make(sset.StatefulSetList, len(statefulSets)) i := 0 for statefulSet, replica := range statefulSets { - statefulSetList[i] = sset.TestSset{Name: statefulSet, Replicas: replica + 1}.Build() + statefulSetList[i] = sset.TestSset{Name: statefulSet, ClusterName: TestEsName, Namespace: TestEsNamespace, Replicas: replica + 1}.Build() i++ } return statefulSetList @@ -238,6 +245,7 @@ func (t testPod) toPod() corev1.Pod { labels[label.ClusterNameLabelName] = TestEsName label.NodeTypesMasterLabelName.Set(t.master, labels) label.NodeTypesDataLabelName.Set(t.data, labels) + labels[label.StatefulSetNameLabelName] = t.ssetName pod.Labels = labels if t.healthy { pod.Status = corev1.PodStatus{ diff --git a/pkg/controller/elasticsearch/driver/pvc.go b/pkg/controller/elasticsearch/driver/pvc.go index 848fd2323b..34afdc338d 100644 --- a/pkg/controller/elasticsearch/driver/pvc.go +++ b/pkg/controller/elasticsearch/driver/pvc.go @@ -26,10 +26,9 @@ func GarbageCollectPVCs( ) error { // PVCs are using the same labels as their corresponding StatefulSet, so we can filter on ES cluster name. var pvcs corev1.PersistentVolumeClaimList - if err := k8sClient.List(&client.ListOptions{ - Namespace: es.Namespace, - LabelSelector: label.NewLabelSelectorForElasticsearch(es), - }, &pvcs); err != nil { + ns := client.InNamespace(es.Namespace) + matchLabels := label.NewLabelSelectorForElasticsearch(es) + if err := k8sClient.List(&pvcs, ns, matchLabels); err != nil { return err } for _, pvc := range pvcsToRemove(pvcs.Items, actualStatefulSets, expectedStatefulSets) { diff --git a/pkg/controller/elasticsearch/driver/pvc_test.go b/pkg/controller/elasticsearch/driver/pvc_test.go index cd067f879c..2797e5e04e 100644 --- a/pkg/controller/elasticsearch/driver/pvc_test.go +++ b/pkg/controller/elasticsearch/driver/pvc_test.go @@ -9,7 +9,6 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" @@ -130,7 +129,7 @@ func Test_pvcsToRemove(t *testing.T) { func TestGarbageCollectPVCs(t *testing.T) { // Test_pvcsToRemove covers most of the testing logic, - // let's just checked everything is correctly plugged to the k8s api here. + // let's just check everything is correctly plugged to the k8s api here. es := v1alpha1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "es"}} existingPVCS := []runtime.Object{ buildPVCPtr("claim1-sset1-0"), // should not be removed @@ -143,6 +142,6 @@ func TestGarbageCollectPVCs(t *testing.T) { require.NoError(t, err) var retrievedPVCs corev1.PersistentVolumeClaimList - require.NoError(t, k8sClient.List(&client.ListOptions{}, &retrievedPVCs)) + require.NoError(t, k8sClient.List(&retrievedPVCs)) require.Equal(t, 1, len(retrievedPVCs.Items)) } diff --git a/pkg/controller/elasticsearch/driver/upgrade_pods_deletion.go b/pkg/controller/elasticsearch/driver/upgrade_pods_deletion.go index 60be2df556..354f7a7295 100644 --- a/pkg/controller/elasticsearch/driver/upgrade_pods_deletion.go +++ b/pkg/controller/elasticsearch/driver/upgrade_pods_deletion.go @@ -11,7 +11,6 @@ import ( "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" "github.com/elastic/cloud-on-k8s/pkg/utils/stringsutil" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -149,17 +148,14 @@ func (ctx *rollingUpgradeCtx) handleMasterScaleChange(pod corev1.Pod) error { } func (ctx *rollingUpgradeCtx) delete(pod *corev1.Pod) error { - uid := pod.UID log.Info("Deleting pod for rolling upgrade", "es_name", ctx.ES.Name, "namespace", ctx.ES.Namespace, "pod_name", pod.Name, "pod_uid", pod.UID) - return ctx.client.Delete(pod, func(options *client.DeleteOptions) { - if options.Preconditions == nil { - options.Preconditions = &metav1.Preconditions{} - } - // The name of the Pod we want to delete is not enough as it may have been already deleted/recreated. - // The uid of the Pod we want to delete is used as a precondition to check that we actually delete the right one. - // If not it means that we are running with a stale cache. - options.Preconditions.UID = &uid - }) + // The name of the Pod we want to delete is not enough as it may have been already deleted/recreated. + // The uid of the Pod we want to delete is used as a precondition to check that we actually delete the right one. + // If not it means that we are running with a stale cache. + opt := client.Preconditions{ + UID: &pod.UID, + } + return ctx.client.Delete(pod, opt) } func runPredicates( diff --git a/pkg/controller/elasticsearch/driver/upgrade_predicates_test.go b/pkg/controller/elasticsearch/driver/upgrade_predicates_test.go index 7c6ee021a2..daaa24461c 100644 --- a/pkg/controller/elasticsearch/driver/upgrade_predicates_test.go +++ b/pkg/controller/elasticsearch/driver/upgrade_predicates_test.go @@ -43,8 +43,8 @@ func TestUpgradePodsDeletion_WithNodeTypeMutations(t *testing.T) { name: "Risky mutation with 7.x nodes", fields: fields{ upgradeTestPods: newUpgradeTestPods( - newTestPod("masterdata-0").withVersion("7.2.0").isMaster(true).isData(true).isHealthy(true).needsUpgrade(false).isInCluster(true), - newTestPod("other-master-0").withVersion("7.2.0").isMaster(true).isData(true).isHealthy(true).needsUpgrade(true).isInCluster(true), + newTestPod("masterdata-0").withVersion("7.2.0").isMaster(true).isData(true).isHealthy(true).needsUpgrade(false).isInCluster(true).inStatefulset("masterdata"), + newTestPod("other-master-0").withVersion("7.2.0").isMaster(true).isData(true).isHealthy(true).needsUpgrade(true).isInCluster(true).inStatefulset("other-master"), ), maxUnavailable: 1, green: true, diff --git a/pkg/controller/elasticsearch/driver/upgrade_test.go b/pkg/controller/elasticsearch/driver/upgrade_test.go index d636d6dc5e..79f1e71c7f 100644 --- a/pkg/controller/elasticsearch/driver/upgrade_test.go +++ b/pkg/controller/elasticsearch/driver/upgrade_test.go @@ -5,7 +5,6 @@ package driver import ( - "reflect" "testing" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/sset" @@ -132,12 +131,16 @@ func Test_healthyPods(t *testing.T) { name: "All Pods are healthy", args: args{ pods: newUpgradeTestPods( - newTestPod("masters-2").isMaster(true).isData(false).isHealthy(true).needsUpgrade(true).isInCluster(true), - newTestPod("masters-1").isMaster(true).isData(false).isHealthy(true).needsUpgrade(true).isInCluster(true), - newTestPod("masters-0").isMaster(true).isData(false).isHealthy(true).needsUpgrade(true).isInCluster(true), + newTestPod("masters-2").inStatefulset("masters").isMaster(true).isData(false).isHealthy(true).needsUpgrade(true).isInCluster(true), + newTestPod("masters-1").inStatefulset("masters").isMaster(true).isData(false).isHealthy(true).needsUpgrade(true).isInCluster(true), + newTestPod("masters-0").inStatefulset("masters").isMaster(true).isData(false).isHealthy(true).needsUpgrade(true).isInCluster(true), ), statefulSets: sset.StatefulSetList{ - sset.TestSset{Name: "masters", Replicas: 3}.Build(), + sset.TestSset{ + Name: "masters", + Namespace: TestEsNamespace, + Replicas: 3, + }.Build(), }, }, }, @@ -145,12 +148,16 @@ func Test_healthyPods(t *testing.T) { name: "One Pod is terminating", args: args{ pods: newUpgradeTestPods( - newTestPod("masters-2").isMaster(true).isData(false).isHealthy(true).needsUpgrade(true).isInCluster(true), - newTestPod("masters-1").isMaster(true).isData(false).isHealthy(true).needsUpgrade(true).isInCluster(true).isTerminating(true), - newTestPod("masters-0").isMaster(true).isData(false).isHealthy(true).needsUpgrade(true).isInCluster(true), + newTestPod("masters-2").inStatefulset("masters").isMaster(true).isData(false).isHealthy(true).needsUpgrade(true).isInCluster(true), + newTestPod("masters-1").inStatefulset("masters").isMaster(true).isData(false).isHealthy(true).needsUpgrade(true).isInCluster(true).isTerminating(true), + newTestPod("masters-0").inStatefulset("masters").isMaster(true).isData(false).isHealthy(true).needsUpgrade(true).isInCluster(true), ), statefulSets: sset.StatefulSetList{ - sset.TestSset{Name: "masters", Replicas: 3}.Build(), + sset.TestSset{ + Name: "masters", + Namespace: TestEsNamespace, + Replicas: 3, + }.Build(), }, }, }, @@ -167,9 +174,8 @@ func Test_healthyPods(t *testing.T) { return } want := tt.args.pods.toHealthyPods() - if !reflect.DeepEqual(got, want) { - t.Errorf("healthyPods() = %v, want %v", got, want) - } + assert.Equal(t, len(want), len(got)) + assert.Equal(t, want, got) }) } } diff --git a/pkg/controller/elasticsearch/elasticsearch_controller.go b/pkg/controller/elasticsearch/elasticsearch_controller.go index e5834129c5..c5fe6a3c47 100644 --- a/pkg/controller/elasticsearch/elasticsearch_controller.go +++ b/pkg/controller/elasticsearch/elasticsearch_controller.go @@ -28,10 +28,10 @@ import ( "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/validation" esversion "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/version" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" @@ -49,6 +49,7 @@ var log = logf.Log.WithName(name) // Add creates a new Elasticsearch Controller and adds it to the Manager with default RBAC. The Manager will set fields // on the Controller and Start it when the Manager is Started. +// this is also called by cmd/main.go func Add(mgr manager.Manager, params operator.Parameters) error { reconciler := newReconciler(mgr, params) c, err := add(mgr, reconciler) @@ -64,7 +65,7 @@ func newReconciler(mgr manager.Manager, params operator.Parameters) *ReconcileEl return &ReconcileElasticsearch{ Client: client, scheme: mgr.GetScheme(), - recorder: mgr.GetRecorder(name), + recorder: mgr.GetEventRecorderFor(name), esObservers: observer.NewManager(observer.DefaultSettings), @@ -198,7 +199,7 @@ func (r *ReconcileElasticsearch) Reconcile(request reconcile.Request) (reconcile return common.PauseRequeue, nil } - selector := labels.Set(map[string]string{label.ClusterNameLabelName: es.Name}).AsSelector() + selector := map[string]string{label.ClusterNameLabelName: es.Name} compat, err := annotation.ReconcileCompatibility(r.Client, &es, selector, r.OperatorInfo.BuildInfo.Version) if err != nil { k8s.EmitErrorEvent(r.recorder, err, &es, events.EventCompatCheckError, "Error during compatibility check: %v", err) diff --git a/pkg/controller/elasticsearch/label/label.go b/pkg/controller/elasticsearch/label/label.go index fa033aa5c1..da16b769ea 100644 --- a/pkg/controller/elasticsearch/label/label.go +++ b/pkg/controller/elasticsearch/label/label.go @@ -10,13 +10,12 @@ import ( "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/version" - "github.com/pkg/errors" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" ) @@ -142,14 +141,14 @@ func NewStatefulSetLabels(es types.NamespacedName, ssetName string) map[string]s } // NewLabelSelectorForElasticsearch returns a labels.Selector that matches the labels as constructed by NewLabels -func NewLabelSelectorForElasticsearch(es v1alpha1.Elasticsearch) labels.Selector { +func NewLabelSelectorForElasticsearch(es v1alpha1.Elasticsearch) client.MatchingLabels { return NewLabelSelectorForElasticsearchClusterName(es.Name) } // NewLabelSelectorForElasticsearchClusterName returns a labels.Selector that matches the labels as constructed by // NewLabels for the provided cluster name. -func NewLabelSelectorForElasticsearchClusterName(clusterName string) labels.Selector { - return labels.SelectorFromSet(map[string]string{ClusterNameLabelName: clusterName}) +func NewLabelSelectorForElasticsearchClusterName(clusterName string) client.MatchingLabels { + return client.MatchingLabels(map[string]string{ClusterNameLabelName: clusterName}) } // ClusterFromResourceLabels returns the NamespacedName of the Elasticsearch associated diff --git a/pkg/controller/elasticsearch/label/label_test.go b/pkg/controller/elasticsearch/label/label_test.go index e8b670e2f8..110b351441 100644 --- a/pkg/controller/elasticsearch/label/label_test.go +++ b/pkg/controller/elasticsearch/label/label_test.go @@ -8,15 +8,11 @@ import ( "reflect" "testing" - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/version" - "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" ) @@ -43,32 +39,6 @@ func TestClusterFromResourceLabels(t *testing.T) { }, cluster) } -func TestNewLabelSelectorForElasticsearch(t *testing.T) { - type args struct { - es v1alpha1.Elasticsearch - } - tests := []struct { - name string - args args - assertions func(*testing.T, args, labels.Selector) - }{ - { - name: "should match labels from NewLabels", - args: args{es: v1alpha1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Name: "foo"}}}, - assertions: func(t *testing.T, a args, sel labels.Selector) { - esLabels := NewLabels(k8s.ExtractNamespacedName(&a.es)) - assert.True(t, sel.Matches(labels.Set(esLabels))) - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got := NewLabelSelectorForElasticsearch(tt.args.es) - tt.assertions(t, tt.args, got) - }) - } -} - func TestExtractVersion(t *testing.T) { tests := []struct { name string diff --git a/pkg/controller/elasticsearch/pdb/reconcile_test.go b/pkg/controller/elasticsearch/pdb/reconcile_test.go index 06fc9da742..14eb510932 100644 --- a/pkg/controller/elasticsearch/pdb/reconcile_test.go +++ b/pkg/controller/elasticsearch/pdb/reconcile_test.go @@ -18,7 +18,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/client-go/kubernetes/scheme" - "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" ) @@ -160,7 +159,7 @@ func TestReconcile(t *testing.T) { if err == nil { var pdbs v1beta1.PodDisruptionBudgetList - require.NoError(t, tt.args.c.List(&client.ListOptions{}, &pdbs)) + require.NoError(t, tt.args.c.List(&pdbs)) for _, pdb := range pdbs.Items { if tt.want != nil { diff --git a/pkg/controller/elasticsearch/reconcile/resources_state.go b/pkg/controller/elasticsearch/reconcile/resources_state.go index ba62c91af2..c0d1c0c285 100644 --- a/pkg/controller/elasticsearch/reconcile/resources_state.go +++ b/pkg/controller/elasticsearch/reconcile/resources_state.go @@ -6,8 +6,6 @@ package reconcile import ( corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/fields" - "k8s.io/apimachinery/pkg/labels" "sigs.k8s.io/controller-runtime/pkg/client" "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" @@ -35,7 +33,7 @@ type ResourcesState struct { func NewResourcesStateFromAPI(c k8s.Client, es v1alpha1.Elasticsearch) (*ResourcesState, error) { labelSelector := label.NewLabelSelectorForElasticsearch(es) - allPods, err := getPods(c, es, labelSelector, nil) + allPods, err := getPods(c, es, labelSelector) if err != nil { return nil, err } @@ -81,18 +79,12 @@ func NewResourcesStateFromAPI(c k8s.Client, es v1alpha1.Elasticsearch) (*Resourc func getPods( c k8s.Client, es v1alpha1.Elasticsearch, - labelSelectors labels.Selector, - fieldSelectors fields.Selector, + labelSelector client.MatchingLabels, ) ([]corev1.Pod, error) { var podList corev1.PodList + ns := client.InNamespace(es.Namespace) - listOpts := client.ListOptions{ - Namespace: es.Namespace, - LabelSelector: labelSelectors, - FieldSelector: fieldSelectors, - } - - if err := c.List(&listOpts, &podList); err != nil { + if err := c.List(&podList, ns, labelSelector); err != nil { return nil, err } diff --git a/pkg/controller/elasticsearch/settings/masters.go b/pkg/controller/elasticsearch/settings/masters.go index be3ce8e303..e63be40d64 100644 --- a/pkg/controller/elasticsearch/settings/masters.go +++ b/pkg/controller/elasticsearch/settings/masters.go @@ -93,10 +93,8 @@ func UpdateSeedHostsConfigMap( PostUpdate: func() { log.Info("Seed hosts updated", "namespace", es.Namespace, "es_name", es.Name, "hosts", seedHosts) annotation.MarkPodsAsUpdated(c, - client.ListOptions{ - Namespace: es.Namespace, - LabelSelector: label.NewLabelSelectorForElasticsearch(es), - }) + client.InNamespace(es.Namespace), + label.NewLabelSelectorForElasticsearch(es)) }, }) } diff --git a/pkg/controller/elasticsearch/sset/list.go b/pkg/controller/elasticsearch/sset/list.go index 3dc3f17c8f..f18cba7a3b 100644 --- a/pkg/controller/elasticsearch/sset/list.go +++ b/pkg/controller/elasticsearch/sset/list.go @@ -26,10 +26,9 @@ type StatefulSetList []appsv1.StatefulSet // RetrieveActualStatefulSets returns the list of existing StatefulSets labeled for the given es cluster. func RetrieveActualStatefulSets(c k8s.Client, es types.NamespacedName) (StatefulSetList, error) { var ssets appsv1.StatefulSetList - err := c.List(&client.ListOptions{ - Namespace: es.Namespace, - LabelSelector: label.NewLabelSelectorForElasticsearchClusterName(es.Name), - }, &ssets) + ns := client.InNamespace(es.Namespace) + matchLabels := label.NewLabelSelectorForElasticsearchClusterName(es.Name) + err := c.List(&ssets, ns, matchLabels) return StatefulSetList(ssets.Items), err } diff --git a/pkg/controller/elasticsearch/sset/list_test.go b/pkg/controller/elasticsearch/sset/list_test.go index c61ba138d5..2798fada78 100644 --- a/pkg/controller/elasticsearch/sset/list_test.go +++ b/pkg/controller/elasticsearch/sset/list_test.go @@ -8,6 +8,7 @@ import ( "reflect" "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -119,11 +120,13 @@ func TestStatefulSetList_PodReconciliationDone(t *testing.T) { { name: "sset has its pods", l: StatefulSetList{ - TestSset{Name: "sset1", Replicas: 2, Status: appsv1.StatefulSetStatus{CurrentRevision: "current-rev"}}.Build(), + TestSset{Name: "sset1", Namespace: "ns", Replicas: 2, Status: appsv1.StatefulSetStatus{CurrentRevision: "current-rev"}}.Build(), }, c: k8s.WrapClient(fake.NewFakeClient( - TestPod{Namespace: "ns", Name: "sset1-0", StatefulSetName: "sset2", Revision: "current-rev"}.BuildPtr(), - TestPod{Namespace: "ns", Name: "sset1-1", StatefulSetName: "sset2", Revision: "current-rev"}.BuildPtr(), + TestPod{Namespace: "ns", Name: "sset1-0", StatefulSetName: "sset1", Revision: "current-rev"}.BuildPtr(), + TestPod{Namespace: "ns", Name: "sset1-1", StatefulSetName: "sset1", Revision: "current-rev"}.BuildPtr(), + TestPod{Namespace: "ns", Name: "sset2-0", StatefulSetName: "sset2", Revision: "current-rev"}.BuildPtr(), + TestPod{Namespace: "ns0", Name: "sset1-0", StatefulSetName: "sset1", Revision: "current-rev"}.BuildPtr(), )), want: true, }, @@ -143,7 +146,7 @@ func TestStatefulSetList_PodReconciliationDone(t *testing.T) { t.Run(tt.name, func(t *testing.T) { got, err := tt.l.PodReconciliationDone(tt.c) require.NoError(t, err) - require.Equal(t, tt.want, got) + assert.Equal(t, tt.want, got) }) } } diff --git a/pkg/controller/elasticsearch/sset/pod.go b/pkg/controller/elasticsearch/sset/pod.go index 002cc561a0..9d7c6cbda2 100644 --- a/pkg/controller/elasticsearch/sset/pod.go +++ b/pkg/controller/elasticsearch/sset/pod.go @@ -15,7 +15,6 @@ import ( "github.com/elastic/cloud-on-k8s/pkg/utils/stringsutil" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/labels" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -42,12 +41,11 @@ func PodRevision(pod corev1.Pod) string { // The returned pods may not match the expected StatefulSet replicas in a transient situation. func GetActualPodsForStatefulSet(c k8s.Client, sset appsv1.StatefulSet) ([]corev1.Pod, error) { var pods corev1.PodList - if err := c.List(&client.ListOptions{ - Namespace: sset.Namespace, - LabelSelector: labels.SelectorFromSet(map[string]string{ - label.StatefulSetNameLabelName: sset.Name, - }), - }, &pods); err != nil { + ns := client.InNamespace(sset.Namespace) + matchLabels := client.MatchingLabels(map[string]string{ + label.StatefulSetNameLabelName: sset.Name, + }) + if err := c.List(&pods, matchLabels, ns); err != nil { return nil, err } return pods.Items, nil @@ -56,12 +54,12 @@ func GetActualPodsForStatefulSet(c k8s.Client, sset appsv1.StatefulSet) ([]corev // GetActualPodsForCluster return the existing pods associated to this cluster. func GetActualPodsForCluster(c k8s.Client, es v1alpha1.Elasticsearch) ([]corev1.Pod, error) { var pods corev1.PodList - if err := c.List(&client.ListOptions{ - Namespace: es.Namespace, - LabelSelector: labels.SelectorFromSet(map[string]string{ - label.ClusterNameLabelName: es.Name, - }), - }, &pods); err != nil { + + ns := client.InNamespace(es.Namespace) + matchLabels := client.MatchingLabels(map[string]string{ + label.ClusterNameLabelName: es.Name, + }) + if err := c.List(&pods, ns, matchLabels); err != nil { return nil, err } return pods.Items, nil diff --git a/pkg/controller/elasticsearch/sset/pod_test.go b/pkg/controller/elasticsearch/sset/pod_test.go index 7dcf360902..69bfeb6f8c 100644 --- a/pkg/controller/elasticsearch/sset/pod_test.go +++ b/pkg/controller/elasticsearch/sset/pod_test.go @@ -8,9 +8,14 @@ import ( "testing" "github.com/elastic/cloud-on-k8s/pkg/controller/common" + "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/controller-runtime/pkg/client/fake" ) func TestPodName(t *testing.T) { @@ -67,3 +72,42 @@ func TestStatefulSetName(t *testing.T) { }) } } + +// Test that we actually filter on the sset name and the namespace +func TestGetActualPodsForStatefulSet(t *testing.T) { + objs := []runtime.Object{ + getPodSample("pod0", "ns0", "sset0", "clus0", "0"), + getPodSample("pod1", "ns1", "sset0", "clus0", "0"), + getPodSample("pod2", "ns0", "sset1", "clus1", "0"), + getPodSample("pod3", "ns0", "sset1", "clus0", "0"), + } + c := k8s.WrapClient(fake.NewFakeClient(objs...)) + sset0 := getSsetSample("sset0", "ns0", "clus0") + pods, err := GetActualPodsForStatefulSet(c, sset0) + require.NoError(t, err) + // only one pod is in the same stateful set and namespace + assert.Equal(t, 1, len(pods)) +} + +func getSsetSample(name, namespace, clusterName string) appsv1.StatefulSet { + return TestSset{ + Name: name, + Namespace: namespace, + ClusterName: clusterName, + Replicas: 3, + Status: appsv1.StatefulSetStatus{ + CurrentRevision: "1", + UpdateRevision: "1", + }, + }.Build() +} + +func getPodSample(name, namespace, ssetName, clusterName, revision string) *corev1.Pod { + return TestPod{ + Namespace: namespace, + Name: name, + ClusterName: clusterName, + StatefulSetName: ssetName, + Revision: revision, + }.BuildPtr() +} diff --git a/pkg/controller/elasticsearch/user/reconciler.go b/pkg/controller/elasticsearch/user/reconciler.go index 73941d78ed..eb4c990625 100644 --- a/pkg/controller/elasticsearch/user/reconciler.go +++ b/pkg/controller/elasticsearch/user/reconciler.go @@ -89,10 +89,9 @@ func ReconcileUsers( } var customUsers corev1.SecretList - if err := c.List(&client.ListOptions{ - LabelSelector: user.NewLabelSelectorForElasticsearch(es), - Namespace: es.Namespace, - }, &customUsers); err != nil { + ns := client.InNamespace(es.Namespace) + matchLabels := user.NewLabelSelectorForElasticsearch(es) + if err := c.List(&customUsers, ns, matchLabels); err != nil { return nil, err } diff --git a/pkg/controller/elasticsearch/version/zen1/minimum_masters_test.go b/pkg/controller/elasticsearch/version/zen1/minimum_masters_test.go index be860200d7..ab52bb08a0 100644 --- a/pkg/controller/elasticsearch/version/zen1/minimum_masters_test.go +++ b/pkg/controller/elasticsearch/version/zen1/minimum_masters_test.go @@ -102,11 +102,14 @@ func (f *fakeESClient) SetMinimumMasterNodes(ctx context.Context, count int) err } func TestUpdateMinimumMasterNodes(t *testing.T) { - ssetSample := sset.TestSset{Name: "nodes", Version: "6.8.0", Replicas: 3, Master: true, Data: true}.Build() + esName := "es" + ns := "ns" + ssetSample := sset.TestSset{Name: "nodes", Namespace: ns, ClusterName: esName, Version: "6.8.0", Replicas: 3, Master: true, Data: true}.Build() // simulate 3/3 pods ready labels := map[string]string{ label.StatefulSetNameLabelName: ssetSample.Name, label.VersionLabelName: "6.8.0", + label.ClusterNameLabelName: esName, } label.NodeTypesMasterLabelName.Set(true, labels) label.NodeTypesDataLabelName.Set(true, labels) @@ -151,7 +154,7 @@ func TestUpdateMinimumMasterNodes(t *testing.T) { }{ { name: "no v6 nodes", - actualStatefulSets: sset.StatefulSetList{sset.TestSset{Name: "nodes", Version: "7.1.0", Replicas: 3, Master: true, Data: true}.Build()}, + actualStatefulSets: sset.StatefulSetList{sset.TestSset{Name: "nodes", Namespace: ns, Version: "7.1.0", Replicas: 3, Master: true, Data: true}.Build()}, wantCalled: false, c: k8s.WrapClient(fake.NewFakeClient(createMasterPodsWithVersion("nodes", "7.1.0", 3)...)), }, @@ -190,7 +193,7 @@ func TestUpdateMinimumMasterNodes(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { esClient := &fakeESClient{} - requeue, err := UpdateMinimumMasterNodes(tt.c, v1alpha1.Elasticsearch{}, esClient, tt.actualStatefulSets, tt.reconcileState) + requeue, err := UpdateMinimumMasterNodes(tt.c, v1alpha1.Elasticsearch{ObjectMeta: metav1.ObjectMeta{Name: esName, Namespace: ns}}, esClient, tt.actualStatefulSets, tt.reconcileState) require.NoError(t, err) require.Equal(t, tt.wantRequeue, requeue) require.Equal(t, tt.wantCalled, esClient.called) diff --git a/pkg/controller/elasticsearch/version/zen2/compatibility_test.go b/pkg/controller/elasticsearch/version/zen2/compatibility_test.go index b03b5cea36..4e3858a08e 100644 --- a/pkg/controller/elasticsearch/version/zen2/compatibility_test.go +++ b/pkg/controller/elasticsearch/version/zen2/compatibility_test.go @@ -166,6 +166,10 @@ func TestIsInitialZen2Upgrade(t *testing.T) { Master: true, }.BuildPtr())), es: v1alpha1.Elasticsearch{ + ObjectMeta: metav1.ObjectMeta{ + Name: "es", + Namespace: "default", + }, Spec: v1alpha1.ElasticsearchSpec{Version: "7.3.0"}, }, }, diff --git a/pkg/controller/kibana/config/reconciler_test.go b/pkg/controller/kibana/config/reconciler_test.go index ebde9c6e2d..2b8e18f6a2 100644 --- a/pkg/controller/kibana/config/reconciler_test.go +++ b/pkg/controller/kibana/config/reconciler_test.go @@ -13,9 +13,9 @@ import ( "github.com/elastic/cloud-on-k8s/pkg/controller/kibana/label" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernetes/scheme" "sigs.k8s.io/controller-runtime/pkg/client" @@ -51,7 +51,7 @@ func TestReconcileConfigSecret(t *testing.T) { }}, }, assertions: func(secrets corev1.SecretList) error { - assert.Equal(t, 1, len(secrets.Items)) + require.Equal(t, 1, len(secrets.Items)) assert.NotNil(t, secrets.Items[0].Data[SettingsFilename]) return nil }, @@ -65,13 +65,14 @@ func TestReconcileConfigSecret(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "test-kb-config", Namespace: "test-ns", + Labels: map[string]string{label.KibanaNameLabelName: defaultKibana.Name}, }, Data: map[string][]byte{}, }}, }, assertions: func(secrets corev1.SecretList) error { - assert.Equal(t, 1, len(secrets.Items)) + require.Equal(t, 1, len(secrets.Items)) assert.NotNil(t, secrets.Items[0].Data[SettingsFilename]) return nil }, @@ -85,6 +86,7 @@ func TestReconcileConfigSecret(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "test-kb-config", Namespace: "test-ns", + Labels: map[string]string{label.KibanaNameLabelName: defaultKibana.Name}, }, Data: map[string][]byte{ SettingsFilename: []byte("eW8h"), @@ -93,7 +95,7 @@ func TestReconcileConfigSecret(t *testing.T) { }, assertions: func(secrets corev1.SecretList) error { - assert.Equal(t, 1, len(secrets.Items)) + require.Equal(t, 1, len(secrets.Items)) assert.NotNil(t, secrets.Items[0].Data[SettingsFilename]) assert.NotEqual(t, "eW8h", secrets.Items[0].Data[SettingsFilename]) return nil @@ -112,10 +114,9 @@ func TestReconcileConfigSecret(t *testing.T) { assert.NoError(t, err) var secrets corev1.SecretList - labelSelector := labels.Set(map[string]string{label.KibanaNameLabelName: defaultKibana.Name}).AsSelector() - err = k8sClient.List(&client.ListOptions{LabelSelector: labelSelector}, &secrets) + labelSelector := client.MatchingLabels(map[string]string{label.KibanaNameLabelName: tt.args.kb.Name}) + err = k8sClient.List(&secrets, labelSelector) assert.NoError(t, err) - err = tt.assertions(secrets) assert.NoError(t, err) }) diff --git a/pkg/controller/kibana/kibana_controller.go b/pkg/controller/kibana/kibana_controller.go index c9253a3cf9..22f0fde5ca 100644 --- a/pkg/controller/kibana/kibana_controller.go +++ b/pkg/controller/kibana/kibana_controller.go @@ -23,7 +23,6 @@ import ( appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/controller" @@ -58,7 +57,7 @@ func newReconciler(mgr manager.Manager, params operator.Parameters) *ReconcileKi return &ReconcileKibana{ Client: client, scheme: mgr.GetScheme(), - recorder: mgr.GetRecorder(name), + recorder: mgr.GetEventRecorderFor(name), dynamicWatches: watches.NewDynamicWatches(), finalizers: finalizer.NewHandler(client), params: params, @@ -175,7 +174,7 @@ func (r *ReconcileKibana) Reconcile(request reconcile.Request) (reconcile.Result } func (r *ReconcileKibana) isCompatible(kb *kibanav1alpha1.Kibana) (bool, error) { - selector := labels.Set(map[string]string{label.KibanaNameLabelName: kb.Name}).AsSelector() + selector := map[string]string{label.KibanaNameLabelName: kb.Name} compat, err := annotation.ReconcileCompatibility(r.Client, kb, selector, r.params.OperatorInfo.BuildInfo.Version) if err != nil { k8s.EmitErrorEvent(r.recorder, err, kb, events.EventCompatCheckError, "Error during compatibility check: %v", err) diff --git a/pkg/controller/kibanaassociation/association_controller.go b/pkg/controller/kibanaassociation/association_controller.go index d800feffe4..037d7314ef 100644 --- a/pkg/controller/kibanaassociation/association_controller.go +++ b/pkg/controller/kibanaassociation/association_controller.go @@ -30,7 +30,6 @@ import ( "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" @@ -89,7 +88,7 @@ func newReconciler(mgr manager.Manager, params operator.Parameters) *ReconcileAs Client: client, scheme: mgr.GetScheme(), watches: watches.NewDynamicWatches(), - recorder: mgr.GetRecorder(name), + recorder: mgr.GetEventRecorderFor(name), Parameters: params, } } @@ -133,7 +132,7 @@ func (r *ReconcileAssociation) Reconcile(request reconcile.Request) (reconcile.R err := h.Handle( &kibana, watchFinalizer(kbName, r.watches), - user.UserFinalizer(r.Client, NewUserLabelSelector(kbName), kibana.Kind()), + user.UserFinalizer(r.Client, kibana.Kind(), NewUserLabelSelector(kbName)), ) if err != nil { if apierrors.IsConflict(err) { @@ -197,7 +196,7 @@ func resultFromStatus(status commonv1alpha1.AssociationStatus) reconcile.Result } func (r *ReconcileAssociation) isCompatible(kibana *kbtype.Kibana) (bool, error) { - selector := labels.Set(map[string]string{label.KibanaNameLabelName: kibana.Name}).AsSelector() + selector := map[string]string{label.KibanaNameLabelName: kibana.Name} compat, err := annotation.ReconcileCompatibility(r.Client, kibana, selector, r.OperatorInfo.BuildInfo.Version) if err != nil { k8s.EmitErrorEvent(r.recorder, err, kibana, events.EventCompatCheckError, "Error during compatibility check: %v", err) @@ -340,8 +339,9 @@ func (r *ReconcileAssociation) reconcileElasticsearchCA(kibana *kbtype.Kibana, e // attempts. Common use case is an Elasticsearch reference in Kibana spec that was removed. func deleteOrphanedResources(c k8s.Client, kibana *kbtype.Kibana) error { var secrets corev1.SecretList - selector := NewResourceSelector(kibana.Name) - if err := c.List(&client.ListOptions{LabelSelector: selector, Namespace: kibana.Namespace}, &secrets); err != nil { + ns := client.InNamespace(kibana.Namespace) + matchLabels := NewResourceSelector(kibana.Name) + if err := c.List(&secrets, ns, matchLabels); err != nil { return err } diff --git a/pkg/controller/kibanaassociation/labels.go b/pkg/controller/kibanaassociation/labels.go index 8bfef8b9f5..bc4b5433ae 100644 --- a/pkg/controller/kibanaassociation/labels.go +++ b/pkg/controller/kibanaassociation/labels.go @@ -9,8 +9,8 @@ import ( "github.com/elastic/cloud-on-k8s/pkg/controller/common" "github.com/elastic/cloud-on-k8s/pkg/controller/common/user" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" ) const ( @@ -21,10 +21,10 @@ const ( ) // NewResourceSelector selects resources labeled as related to the named association. -func NewResourceSelector(name string) labels.Selector { - return labels.Set(map[string]string{ +func NewResourceSelector(name string) client.MatchingLabels { + return client.MatchingLabels(map[string]string{ AssociationLabelName: name, - }).AsSelector() + }) } func hasBeenCreatedBy(object metav1.Object, kibana *v1alpha1.Kibana) bool { @@ -40,8 +40,8 @@ func hasBeenCreatedBy(object metav1.Object, kibana *v1alpha1.Kibana) bool { func NewUserLabelSelector( namespacedName types.NamespacedName, -) labels.Selector { - return labels.SelectorFromSet( +) client.MatchingLabels { + return client.MatchingLabels( map[string]string{ AssociationLabelName: namespacedName.Name, AssociationLabelNamespace: namespacedName.Namespace, diff --git a/pkg/controller/license/license_controller.go b/pkg/controller/license/license_controller.go index acce19f467..7ab5e05c97 100644 --- a/pkg/controller/license/license_controller.go +++ b/pkg/controller/license/license_controller.go @@ -54,16 +54,16 @@ func (r *ReconcileLicenses) Reconcile(request reconcile.Request) (reconcile.Resu // Add creates a new EnterpriseLicense Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller // and Start it when the Manager is Started. func Add(mgr manager.Manager, p operator.Parameters) error { - return add(mgr, newReconciler(mgr, p.OperatorNamespace)) + return add(mgr, newReconciler(mgr, p)) } // newReconciler returns a new reconcile.Reconciler -func newReconciler(mgr manager.Manager, ns string) reconcile.Reconciler { +func newReconciler(mgr manager.Manager, params operator.Parameters) *ReconcileLicenses { c := k8s.WrapClient(mgr.GetClient()) return &ReconcileLicenses{ Client: c, scheme: mgr.GetScheme(), - checker: license.NewLicenseChecker(c, ns), + checker: license.NewLicenseChecker(c, params.OperatorNamespace), } } diff --git a/pkg/controller/license/license_controller_integration_test.go b/pkg/controller/license/license_controller_integration_test.go index 75b0e86963..8ceef6993e 100644 --- a/pkg/controller/license/license_controller_integration_test.go +++ b/pkg/controller/license/license_controller_integration_test.go @@ -29,7 +29,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/workqueue" - "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" ) @@ -79,7 +78,7 @@ func TestReconcile(t *testing.T) { // give the client some time to sync up test.RetryUntilSuccess(t, func() error { var secs corev1.SecretList - err := c.List(&client.ListOptions{}, &secs) + err := c.List(&secs) if err != nil { return err } diff --git a/pkg/controller/license/license_controller_test.go b/pkg/controller/license/license_controller_test.go index 3c7219466f..eb1b3bdf71 100644 --- a/pkg/controller/license/license_controller_test.go +++ b/pkg/controller/license/license_controller_test.go @@ -105,6 +105,9 @@ func enterpriseLicense(t *testing.T, licenseType commonlicense.ElasticsearchLice bytes, err := json.Marshal(license) require.NoError(t, err) return &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Labels: commonlicense.LabelsForType(commonlicense.LicenseLabelEnterprise), + }, Data: map[string][]byte{ commonlicense.FileName: bytes, }, diff --git a/pkg/controller/license/list.go b/pkg/controller/license/list.go index eed9bfaecf..6e04e27b97 100644 --- a/pkg/controller/license/list.go +++ b/pkg/controller/license/list.go @@ -9,16 +9,14 @@ import ( "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" ) func listAffectedLicenses(c k8s.Client, licenseName string) ([]reconcile.Request, error) { var list = corev1.SecretList{} // list all cluster licenses referencing the given enterprise license - err := c.List(&client.ListOptions{ - LabelSelector: license.NewLicenseByNameSelector(licenseName), - }, &list) + matchLabels := license.NewLicenseByNameSelector(licenseName) + err := c.List(&list, matchLabels) if err != nil { return nil, err } diff --git a/pkg/controller/license/list_test.go b/pkg/controller/license/list_test.go index 680bae1fe2..e11bcdf4ff 100644 --- a/pkg/controller/license/list_test.go +++ b/pkg/controller/license/list_test.go @@ -28,7 +28,7 @@ type failingClient struct { Error error } -func (f *failingClient) List(opts *client.ListOptions, list runtime.Object) error { +func (f *failingClient) List(list runtime.Object, opts ...client.ListOption) error { return f.Error } diff --git a/pkg/controller/license/trial/trial_controller.go b/pkg/controller/license/trial/trial_controller.go index 1d1fd2d2dd..e672af6a10 100644 --- a/pkg/controller/license/trial/trial_controller.go +++ b/pkg/controller/license/trial/trial_controller.go @@ -16,7 +16,6 @@ import ( "github.com/elastic/cloud-on-k8s/pkg/controller/common/operator" "github.com/elastic/cloud-on-k8s/pkg/controller/license/validation" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" - license_validation "github.com/elastic/cloud-on-k8s/pkg/webhook/license" pkgerrors "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -71,8 +70,9 @@ func (r *ReconcileTrials) Reconcile(request reconcile.Request) (reconcile.Result if secret.Annotations == nil { secret.Annotations = map[string]string{} } - res := license_validation.Aggregate(violations) - secret.Annotations[licensing.LicenseInvalidAnnotation] = string(res.Response.Result.Reason) + // TODO (sabo): this is the only dependency on the license_validation, which was removed as part of removing the webhook package + // res := license_validation.Aggregate(violations) + // secret.Annotations[licensing.LicenseInvalidAnnotation] = string(res.Response.Result.Reason) return reconcile.Result{}, licensing.UpdateEnterpriseLicense(r, secret, license) } @@ -136,7 +136,7 @@ func newReconciler(mgr manager.Manager, _ operator.Parameters) *ReconcileTrials return &ReconcileTrials{ Client: k8s.WrapClient(mgr.GetClient()), scheme: mgr.GetScheme(), - recorder: mgr.GetRecorder(name), + recorder: mgr.GetEventRecorderFor(name), } } @@ -185,8 +185,8 @@ func add(mgr manager.Manager, r *ReconcileTrials) error { // Add creates a new Trial Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller // and Start it when the Manager is Started. -func Add(mgr manager.Manager, p operator.Parameters) error { - r := newReconciler(mgr, p) +func Add(mgr manager.Manager, params operator.Parameters) error { + r := newReconciler(mgr, params) return add(mgr, r) } diff --git a/pkg/utils/k8s/client.go b/pkg/utils/k8s/client.go index 787ade40a1..fd6ad76f83 100644 --- a/pkg/utils/k8s/client.go +++ b/pkg/utils/k8s/client.go @@ -36,15 +36,20 @@ type Client interface { // Get wraps a controller-runtime client.Get call with a context. Get(key client.ObjectKey, obj runtime.Object) error // List wraps a controller-runtime client.List call with a context. - List(opts *client.ListOptions, list runtime.Object) error + List(list runtime.Object, opts ...client.ListOption) error // Create wraps a controller-runtime client.Create call with a context. - Create(obj runtime.Object) error + Create(obj runtime.Object, opts ...client.CreateOption) error // Delete wraps a controller-runtime client.Delete call with a context. - Delete(obj runtime.Object, opts ...client.DeleteOptionFunc) error + Delete(obj runtime.Object, opts ...client.DeleteOption) error // Update wraps a controller-runtime client.Update call with a context. - Update(obj runtime.Object) error + Update(obj runtime.Object, opts ...client.UpdateOption) error // Status wraps a controller-runtime client.Status call. Status() StatusWriter + // Patch patches the given obj in the Kubernetes cluster. obj must be a + // struct pointer so that obj can be updated with the content returned by the Server. + Patch(obj runtime.Object, patch client.Patch, opts ...client.PatchOption) error + // DeleteAllOf deletes all objects of the given type matching the given options. + DeleteAllOf(obj runtime.Object, opts ...client.DeleteAllOfOption) error } type clientWrapper struct { @@ -95,33 +100,47 @@ func (w *clientWrapper) Get(key client.ObjectKey, obj runtime.Object) error { } // List wraps a controller-runtime client.List call with a context. -func (w *clientWrapper) List(opts *client.ListOptions, list runtime.Object) error { +func (w *clientWrapper) List(list runtime.Object, opts ...client.ListOption) error { return w.callWithContext(func(ctx context.Context) error { - return w.crClient.List(ctx, opts, list) + return w.crClient.List(ctx, list, opts...) }) } // Create wraps a controller-runtime client.Create call with a context. -func (w *clientWrapper) Create(obj runtime.Object) error { +func (w *clientWrapper) Create(obj runtime.Object, opts ...client.CreateOption) error { return w.callWithContext(func(ctx context.Context) error { - return w.crClient.Create(ctx, obj) + return w.crClient.Create(ctx, obj, opts...) }) } // Update wraps a controller-runtime client.Update call with a context. -func (w *clientWrapper) Update(obj runtime.Object) error { +func (w *clientWrapper) Update(obj runtime.Object, opts ...client.UpdateOption) error { return w.callWithContext(func(ctx context.Context) error { - return w.crClient.Update(ctx, obj) + return w.crClient.Update(ctx, obj, opts...) + }) +} + +// Patch wraps a controller-runtime client.Patch call with a context. +func (w *clientWrapper) Patch(obj runtime.Object, patch client.Patch, opts ...client.PatchOption) error { + return w.callWithContext(func(ctx context.Context) error { + return w.crClient.Patch(ctx, obj, patch, opts...) }) } // Delete wraps a controller-runtime client.Delete call with a context. -func (w *clientWrapper) Delete(obj runtime.Object, opts ...client.DeleteOptionFunc) error { +func (w *clientWrapper) Delete(obj runtime.Object, opts ...client.DeleteOption) error { return w.callWithContext(func(ctx context.Context) error { return w.crClient.Delete(ctx, obj, opts...) }) } +// DeleteAllOf wraps a controller-runtime client.DeleteAllOf call with a context. +func (w *clientWrapper) DeleteAllOf(obj runtime.Object, opts ...client.DeleteAllOfOption) error { + return w.callWithContext(func(ctx context.Context) error { + return w.crClient.DeleteAllOf(ctx, obj, opts...) + }) +} + // StatusWriter wraps a client.StatusWrapper with a context. type StatusWriter struct { client.StatusWriter @@ -142,3 +161,10 @@ func (s StatusWriter) Update(obj runtime.Object) error { return s.StatusWriter.Update(ctx, obj) }) } + +// Patch wraps a controller-runtime client.Status().Patch call with a context. +func (s StatusWriter) Patch(obj runtime.Object, patch client.Patch, opts ...client.PatchOption) error { + return s.w.callWithContext(func(ctx context.Context) error { + return s.StatusWriter.Patch(ctx, obj, patch, opts...) + }) +} diff --git a/pkg/utils/k8s/client_test.go b/pkg/utils/k8s/client_test.go index f2c149d66a..420c96698a 100644 --- a/pkg/utils/k8s/client_test.go +++ b/pkg/utils/k8s/client_test.go @@ -97,19 +97,23 @@ func (m mockedClient) Get(ctx context.Context, key client.ObjectKey, obj runtime return m.checkCtx(ctx) } -func (m mockedClient) List(ctx context.Context, opts *client.ListOptions, list runtime.Object) error { +func (m mockedClient) List(ctx context.Context, list runtime.Object, opts ...client.ListOption) error { return m.checkCtx(ctx) } -func (m mockedClient) Create(ctx context.Context, obj runtime.Object) error { +func (m mockedClient) Create(ctx context.Context, obj runtime.Object, opts ...client.CreateOption) error { return m.checkCtx(ctx) } -func (m mockedClient) Delete(ctx context.Context, obj runtime.Object, opts ...client.DeleteOptionFunc) error { +func (m mockedClient) Delete(ctx context.Context, obj runtime.Object, opts ...client.DeleteOption) error { return m.checkCtx(ctx) } -func (m mockedClient) Update(ctx context.Context, obj runtime.Object) error { +func (m mockedClient) Update(ctx context.Context, obj runtime.Object, opts ...client.UpdateOption) error { + return m.checkCtx(ctx) +} + +func (m mockedClient) Patch(ctx context.Context, obj runtime.Object, patch client.Patch, opts ...client.PatchOption) error { return m.checkCtx(ctx) } @@ -117,10 +121,18 @@ func (m mockedClient) Status() client.StatusWriter { return mockedStatusWriter{c: m} } +func (m mockedClient) DeleteAllOf(ctx context.Context, obj runtime.Object, opts ...client.DeleteAllOfOption) error { + return m.checkCtx(ctx) +} + type mockedStatusWriter struct { c mockedClient } -func (m mockedStatusWriter) Update(ctx context.Context, obj runtime.Object) error { +func (m mockedStatusWriter) Update(ctx context.Context, obj runtime.Object, opts ...client.UpdateOption) error { + return m.c.checkCtx(ctx) +} + +func (m mockedStatusWriter) Patch(ctx context.Context, obj runtime.Object, patch client.Patch, opts ...client.PatchOption) error { return m.c.checkCtx(ctx) } diff --git a/pkg/utils/k8s/k8sutils.go b/pkg/utils/k8s/k8sutils.go index 9f50b9b995..f3463e7ee4 100644 --- a/pkg/utils/k8s/k8sutils.go +++ b/pkg/utils/k8s/k8sutils.go @@ -10,12 +10,9 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/fields" - "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" - "sigs.k8s.io/controller-runtime/pkg/client" ) // ToObjectMeta returns an ObjectMeta based on the given NamespacedName. @@ -45,28 +42,6 @@ func IsPodReady(pod corev1.Pod) bool { return conditionsTrue == 2 } -// GetPods returns the list of pods given a NamespacedName and a field selector. -func GetPods( - c Client, - namespace string, - labelSelector labels.Selector, - fieldSelector fields.Selector, -) ([]corev1.Pod, error) { - var podList corev1.PodList - - listOpts := client.ListOptions{ - Namespace: namespace, - LabelSelector: labelSelector, - FieldSelector: fieldSelector, - } - - if err := c.List(&listOpts, &podList); err != nil { - return nil, err - } - - return podList.Items, nil -} - // PodsByName returns a map of pod names to pods func PodsByName(pods []corev1.Pod) map[string]corev1.Pod { podMap := make(map[string]corev1.Pod, len(pods)) diff --git a/pkg/utils/log/log.go b/pkg/utils/log/log.go index 2c7966de46..90aed92891 100644 --- a/pkg/utils/log/log.go +++ b/pkg/utils/log/log.go @@ -18,6 +18,7 @@ import ( "go.uber.org/zap" "go.uber.org/zap/zapcore" "k8s.io/klog" + crzap "sigs.k8s.io/controller-runtime/pkg/log/zap" crlog "sigs.k8s.io/controller-runtime/pkg/runtime/log" ) @@ -86,7 +87,7 @@ func setLogger(v *int, debug *bool) { sink := zapcore.AddSync(os.Stderr) opts = append(opts, zap.AddCallerSkip(1), zap.ErrorOutput(sink)) - log := zap.New(zapcore.NewCore(&crlog.KubeAwareEncoder{Encoder: encoder, Verbose: dev.Enabled}, sink, zapLevel)) + log := zap.New(zapcore.NewCore(&crzap.KubeAwareEncoder{Encoder: encoder, Verbose: dev.Enabled}, sink, zapLevel)) log = log.WithOptions(opts...) log = log.With(zap.String("ver", getVersionString())) diff --git a/pkg/utils/test/integration.go b/pkg/utils/test/integration.go index 02d6f614ec..bda3ace708 100644 --- a/pkg/utils/test/integration.go +++ b/pkg/utils/test/integration.go @@ -10,11 +10,10 @@ import ( "testing" "time" - "github.com/elastic/cloud-on-k8s/pkg/apis" "github.com/elastic/cloud-on-k8s/pkg/controller/common/operator" + controllerscheme "github.com/elastic/cloud-on-k8s/pkg/controller/common/scheme" "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/stretchr/testify/require" - "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/controller-runtime/pkg/manager" @@ -33,11 +32,7 @@ var Config *rest.Config // RunWithK8s starts a local Kubernetes server and runs tests in m. func RunWithK8s(m *testing.M, crdPath string) { - if err := apis.AddToScheme(scheme.Scheme); err != nil { - fmt.Println("fail to add scheme") - panic(err) - } - + _ = controllerscheme.SetupScheme() logf.SetLogger(logf.ZapLogger(true)) t := &envtest.Environment{ CRDDirectoryPaths: []string{crdPath}, diff --git a/pkg/webhook/add_validations.go b/pkg/webhook/add_validations.go deleted file mode 100644 index 2ec5dac4ce..0000000000 --- a/pkg/webhook/add_validations.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package webhook - -import ( - "github.com/elastic/cloud-on-k8s/pkg/controller/common/operator" -) - -func init() { - Register(operator.WebhookServer, RegisterValidations) -} diff --git a/pkg/webhook/elasticsearch/handler.go b/pkg/webhook/elasticsearch/handler.go deleted file mode 100644 index 3ac45a1aa4..0000000000 --- a/pkg/webhook/elasticsearch/handler.go +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package elasticsearch - -import ( - "context" - "net/http" - - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - commonvalidation "github.com/elastic/cloud-on-k8s/pkg/controller/common/validation" - "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/validation" - "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" - "k8s.io/api/admission/v1beta1" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" - logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission/types" -) - -var log = logf.Log.WithName("es-validation") - -// ValidationHandler exposes Elasticsearch validations as an admission.Handler. -type ValidationHandler struct { - client client.Client - decoder types.Decoder -} - -var _ inject.Client = &ValidationHandler{} - -// Handle processes AdmissionRequests. -func (v *ValidationHandler) Handle(ctx context.Context, r types.Request) types.Response { - if r.AdmissionRequest.Operation == v1beta1.Delete { - return admission.ValidationResponse(true, "allowing all deletes") - } - esCluster := estype.Elasticsearch{} - log.Info("ValidationHandler handler called", - "operation", r.AdmissionRequest.Operation, - "name", r.AdmissionRequest.Name, - "namespace", r.AdmissionRequest.Namespace, - ) - err := v.decoder.Decode(r, &esCluster) - if err != nil { - log.Error(err, "Failed to decode request") - return admission.ErrorResponse(http.StatusBadRequest, err) - } - var onServer estype.Elasticsearch - err = v.client.Get(ctx, k8s.ExtractNamespacedName(&esCluster), &onServer) - if err != nil && !apierrors.IsNotFound(err) { - log.Error(err, "Failed to retrieve existing cluster") - return admission.ErrorResponse(http.StatusInternalServerError, err) - } - var current *estype.Elasticsearch - if err == nil { - current = &onServer - } - validationCtx, err := validation.NewValidationContext(current, esCluster) - if err != nil { - log.Error(err, "while creating validation context") - return admission.ValidationResponse(false, err.Error()) - } - - results := make([]commonvalidation.Result, len(validation.Validations)) - for i, v := range validation.Validations { - results[i] = v(*validationCtx) - } - return aggregate(results) -} - -func aggregate(results []commonvalidation.Result) types.Response { - response := commonvalidation.Result{Allowed: true} - for _, r := range results { - if !r.Allowed { - response.Allowed = false - if r.Error != nil { - log.Error(r.Error, r.Reason) - } - if response.Reason == "" { - response.Reason = r.Reason - continue - } - response.Reason = response.Reason + ". " + r.Reason - } - } - log.V(1).Info("Admission validation response", "allowed", response.Allowed, "reason", response.Reason) - return admission.ValidationResponse(response.Allowed, response.Reason) -} - -var _ admission.Handler = &ValidationHandler{} - -func (v *ValidationHandler) InjectDecoder(d types.Decoder) error { - v.decoder = d - return nil -} - -var _ inject.Decoder = &ValidationHandler{} - -func (v *ValidationHandler) InjectClient(c client.Client) error { - v.client = c - return nil -} diff --git a/pkg/webhook/elasticsearch/handler_test.go b/pkg/webhook/elasticsearch/handler_test.go deleted file mode 100644 index 5fff67d54d..0000000000 --- a/pkg/webhook/elasticsearch/handler_test.go +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package elasticsearch - -import ( - "context" - "reflect" - "testing" - - estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - "github.com/stretchr/testify/assert" - "k8s.io/api/admission/v1beta1" - admissionv1beta1 "k8s.io/api/admission/v1beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/client-go/kubernetes/scheme" - "sigs.k8s.io/controller-runtime/pkg/client/fake" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission/types" -) - -func setupScheme(t *testing.T) *runtime.Scheme { - sc := scheme.Scheme - if err := estype.SchemeBuilder.AddToScheme(sc); err != nil { - assert.Fail(t, "failed to add Es types") - } - return sc -} - -type mockDecoder struct { - err error - obj runtime.Object -} - -func (m mockDecoder) Decode(_ types.Request, o runtime.Object) error { - if m.obj != nil { - reflect.ValueOf(o).Elem().Set(reflect.ValueOf(m.obj).Elem()) - } - return m.err -} - -func TestValidationHandler_Handle(t *testing.T) { - sc := setupScheme(t) - type fields struct { - initialObjects []runtime.Object - decoder types.Decoder - } - type args struct { - ctx context.Context - r types.Request - } - tests := []struct { - name string - fields fields - args args - want types.Response - }{ - { - name: "6.0.0 is not allowed", - args: args{ - ctx: nil, - r: types.Request{ - AdmissionRequest: &v1beta1.AdmissionRequest{ - Name: "foo", - Namespace: "default", - }, - }, - }, - fields: fields{ - decoder: mockDecoder{ - obj: &estype.Elasticsearch{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{ - Name: "foo", - Namespace: "default", - }, - Spec: estype.ElasticsearchSpec{ - Version: "6.0.0", - Nodes: []estype.NodeSpec{ - { - Name: "foo", - NodeCount: 3, - }, - }, - }, - Status: estype.ElasticsearchStatus{}, - }, - }, - initialObjects: []runtime.Object{}, - }, - want: types.Response{ - Response: &admissionv1beta1.AdmissionResponse{ - Allowed: false, - Result: &v1.Status{ - Reason: "unsupported version: 6.0.0", - }, - }, - }, - }, - { - name: "long names not allowed", - args: args{ - ctx: nil, - r: types.Request{ - AdmissionRequest: &v1beta1.AdmissionRequest{ - Name: "extremely-long-winded-unnecessarily-complicated-elasticsearch-name", - Namespace: "default", - }, - }, - }, - fields: fields{ - decoder: mockDecoder{ - obj: &estype.Elasticsearch{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{ - Name: "extremely-long-winded-unnecessarily-complicated-elasticsearch-name", - Namespace: "default", - }, - Spec: estype.ElasticsearchSpec{ - Version: "7.0.0", - Nodes: []estype.NodeSpec{ - { - Name: "foo", - NodeCount: 3, - }, - }, - }, - Status: estype.ElasticsearchStatus{}, - }, - }, - initialObjects: []runtime.Object{}, - }, - want: types.Response{ - Response: &admissionv1beta1.AdmissionResponse{ - Allowed: false, - Result: &v1.Status{ - Reason: "Elasticsearch configuration would generate resources with invalid names: name exceeds maximum allowed length of 36", - }, - }, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - client := fake.NewFakeClientWithScheme(sc, tt.fields.initialObjects...) - v := &ValidationHandler{ - client: client, - decoder: tt.fields.decoder, - } - if got := v.Handle(tt.args.ctx, tt.args.r); !reflect.DeepEqual(got, tt.want) { - t.Errorf("ValidationHandler.Handle() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/pkg/webhook/license/handler.go b/pkg/webhook/license/handler.go deleted file mode 100644 index 068f03db83..0000000000 --- a/pkg/webhook/license/handler.go +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package license - -import ( - "context" - "net/http" - - commonvalidation "github.com/elastic/cloud-on-k8s/pkg/controller/common/validation" - "github.com/elastic/cloud-on-k8s/pkg/controller/license/validation" - "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" - "k8s.io/api/admission/v1beta1" - corev1 "k8s.io/api/core/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" - logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission/types" -) - -var log = logf.Log.WithName("license-validation") - -// ValidationHandler exposes License validations as an admission.Handler. -type ValidationHandler struct { - client client.Client - decoder types.Decoder -} - -var _ inject.Client = &ValidationHandler{} - -// TODO explore potential for generalisation here - -// Handle processes AdmissionRequests. -func (v *ValidationHandler) Handle(ctx context.Context, r types.Request) types.Response { - if r.AdmissionRequest.Operation == v1beta1.Delete { - return admission.ValidationResponse(true, "allowing all deletes") - } - license := corev1.Secret{} - log.V(1).Info("ValidationHandler handler called", - "operation", r.AdmissionRequest.Operation, - "name", r.AdmissionRequest.Name, - "namespace", r.AdmissionRequest.Namespace, - ) - err := v.decoder.Decode(r, &license) - if err != nil { - log.Error(err, "Failed to decode request") - return admission.ErrorResponse(http.StatusBadRequest, err) - } - var onServer corev1.Secret - err = v.client.Get(ctx, k8s.ExtractNamespacedName(&license), &onServer) - if err != nil && !apierrors.IsNotFound(err) { - log.Error(err, "Failed to retrieve existing license") - return admission.ErrorResponse(http.StatusInternalServerError, err) - } - var current *corev1.Secret - if err == nil { - current = &onServer - } - results := make([]commonvalidation.Result, len(validation.Validations)) - validationCtx := &validation.Context{Current: current, Proposed: license} - for i, v := range validation.Validations { - results[i] = v(*validationCtx) - } - return Aggregate(results) -} - -func Aggregate(results []commonvalidation.Result) types.Response { - response := commonvalidation.Result{Allowed: true} - for _, r := range results { - if !r.Allowed { - response.Allowed = false - if r.Error != nil { - log.Error(r.Error, r.Reason) - } - if response.Reason == "" { - response.Reason = r.Reason - continue - } - response.Reason = response.Reason + ". " + r.Reason - } - } - log.V(1).Info("Admission validation response", "allowed", response.Allowed, "reason", response.Reason) - return admission.ValidationResponse(response.Allowed, response.Reason) -} - -var _ admission.Handler = &ValidationHandler{} - -func (v *ValidationHandler) InjectDecoder(d types.Decoder) error { - v.decoder = d - return nil -} - -var _ inject.Decoder = &ValidationHandler{} - -func (v *ValidationHandler) InjectClient(c client.Client) error { - v.client = c - return nil -} diff --git a/pkg/webhook/license/handler_test.go b/pkg/webhook/license/handler_test.go deleted file mode 100644 index 841cb6a67f..0000000000 --- a/pkg/webhook/license/handler_test.go +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package license - -import ( - "context" - "net/http" - "reflect" - "testing" - - "github.com/elastic/cloud-on-k8s/pkg/apis" - "github.com/elastic/cloud-on-k8s/pkg/controller/common/license" - "github.com/elastic/cloud-on-k8s/pkg/controller/license/validation" - "github.com/pkg/errors" - "github.com/stretchr/testify/require" - "k8s.io/api/admission/v1beta1" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/client-go/kubernetes/scheme" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/client/fake" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission/types" -) - -type mockDecoder struct { - err error - obj *corev1.Secret -} - -func (m mockDecoder) Decode(_ types.Request, o runtime.Object) error { - if m.obj != nil { - reflect.ValueOf(o).Elem().Set(reflect.ValueOf(m.obj).Elem()) - } - return m.err -} - -func TestValidationHandler_Handle(t *testing.T) { - type fields struct { - client client.Client - decoder types.Decoder - } - type args struct { - ctx context.Context - r types.Request - } - tests := []struct { - name string - fields fields - args args - want types.Response - }{ - { - name: "not-found: OK", - fields: fields{ - client: fake.NewFakeClient(), - decoder: mockDecoder{ - obj: &corev1.Secret{}, - }, - }, - args: args{ - ctx: context.TODO(), - r: types.Request{ - AdmissionRequest: &v1beta1.AdmissionRequest{ - Operation: v1beta1.Create, - }, - }, - }, - want: admission.ValidationResponse(true, ""), - }, - { - name: "fail-on-decode: FAIL", - fields: fields{ - client: fake.NewFakeClient(), - decoder: mockDecoder{ - err: errors.New("failed to decode"), - }, - }, - args: args{ - ctx: nil, - r: types.Request{ - AdmissionRequest: &v1beta1.AdmissionRequest{ - Operation: v1beta1.Create, - }, - }, - }, - want: admission.ErrorResponse(http.StatusBadRequest, errors.New("failed to decode")), - }, - { - name: "invalid request: REJECT", - fields: fields{ - client: fake.NewFakeClient(), - decoder: mockDecoder{ - obj: &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Labels: map[string]string{ - license.LicenseLabelType: string(license.LicenseTypeEnterpriseTrial), - }, - }, - }, - }, - }, - args: args{ - ctx: context.TODO(), - r: types.Request{ - AdmissionRequest: &v1beta1.AdmissionRequest{ - Operation: v1beta1.Update, - }, - }, - }, - want: admission.ValidationResponse(false, validation.EULAValidationMsg), - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require.NoError(t, apis.AddToScheme(scheme.Scheme)) - v := &ValidationHandler{ - client: tt.fields.client, - decoder: tt.fields.decoder, - } - if got := v.Handle(tt.args.ctx, tt.args.r); !reflect.DeepEqual(got, tt.want) { - t.Errorf("ValidationHandler.Handle() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/pkg/webhook/params.go b/pkg/webhook/params.go deleted file mode 100644 index fc7694dedf..0000000000 --- a/pkg/webhook/params.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package webhook - -import ( - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/webhook" -) - -// Parameters are params for the webhook server. -type Parameters struct { - // Bootstrap are bootstrap options for the webhook. - Bootstrap webhook.BootstrapOptions - // AutoInstall controls whether the operator will try to install the webhook and supporting resources itself. - AutoInstall bool -} - -// BootstrapOptionsParams are params to create webhook BootstrapOptions. -type BootstrapOptionsParams struct { - Namespace string - ManagedNamespace string - SecretName string - ServiceSelector string -} - -// NewBootstrapOptions are options for the webhook bootstrap process. -func NewBootstrapOptions(params BootstrapOptionsParams) webhook.BootstrapOptions { - var secret *types.NamespacedName - ns := params.Namespace - if params.ManagedNamespace != "" { - // if we are restricting the operator to a single namespace we have to create the webhook resources in the - // managed namespace due to restrictions in the controller runtime (would not be able to list the resources) - ns = params.ManagedNamespace - } - if params.SecretName != "" { - secret = &types.NamespacedName{ - Namespace: ns, - Name: params.SecretName, - } - } - var svc *webhook.Service - if params.ServiceSelector != "" { - svc = &webhook.Service{ - Namespace: ns, - Name: svcName, - Selectors: map[string]string{ - controlPlane: params.ServiceSelector, - }, - } - } - return webhook.BootstrapOptions{ - Secret: secret, - Service: svc, - } -} diff --git a/pkg/webhook/server.go b/pkg/webhook/server.go deleted file mode 100644 index 863d2b156e..0000000000 --- a/pkg/webhook/server.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package webhook - -import ( - "context" - - "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" - "github.com/elastic/cloud-on-k8s/pkg/webhook/elasticsearch" - "github.com/elastic/cloud-on-k8s/pkg/webhook/license" - admission "k8s.io/api/admissionregistration/v1beta1" - corev1 "k8s.io/api/core/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/manager" - "sigs.k8s.io/controller-runtime/pkg/webhook" - - "sigs.k8s.io/controller-runtime/pkg/webhook/admission/builder" -) - -const ( - admissionServerName = "elastic-admission-server" - svcName = "elastic-webhook-service" - controlPlane = "control-plane" - - serverPort int32 = 9443 -) - -// RegisterValidations registers validating webhooks and a new webhook server with the given manager. -func RegisterValidations(mgr manager.Manager, params Parameters) error { - esWh, err := builder.NewWebhookBuilder(). - Name("validation.elasticsearch.elastic.co"). - Validating(). - FailurePolicy(admission.Ignore). - ForType(&v1alpha1.Elasticsearch{}). - Handlers(&elasticsearch.ValidationHandler{}). - WithManager(mgr). - Build() - if err != nil { - return err - } - - licWh, err := builder.NewWebhookBuilder(). - Name("validation.license.elastic.co"). - Validating(). - FailurePolicy(admission.Ignore). - ForType(&corev1.Secret{}). - Handlers(&license.ValidationHandler{}). - WithManager(mgr). - Build() - if err != nil { - return err - } - - disabled := !params.AutoInstall - if params.AutoInstall { - // nasty side effect in register function - webhookSvc := corev1.Service{ - ObjectMeta: v1.ObjectMeta{ - Name: params.Bootstrap.Service.Name, - Namespace: params.Bootstrap.Service.Namespace, - }, - } - // best effort deletion attempt to handle incompatible services from previous versions - _ = mgr.GetClient().Delete(context.Background(), &webhookSvc) - } - svr, err := webhook.NewServer(admissionServerName, mgr, webhook.ServerOptions{ - Port: serverPort, - CertDir: "/tmp/cert", - DisableWebhookConfigInstaller: &disabled, - BootstrapOptions: ¶ms.Bootstrap, - }) - if err != nil { - return err - } - - return svr.Register(esWh, licWh) -} diff --git a/pkg/webhook/webhook.go b/pkg/webhook/webhook.go deleted file mode 100644 index 90a2c0bc4c..0000000000 --- a/pkg/webhook/webhook.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package webhook - -import ( - "github.com/elastic/cloud-on-k8s/pkg/controller/common/operator" - "github.com/elastic/cloud-on-k8s/pkg/utils/stringsutil" - "sigs.k8s.io/controller-runtime/pkg/manager" -) - -// AddToManagerFuncs is a list of functions to add all webhooks to the Manager -var AddToManagerFuncs = make(map[string][]func(manager.Manager, Parameters) error) - -// Register a webhook for a specific manager role. -func Register(role string, add func(manager.Manager, Parameters) error) { - fns := AddToManagerFuncs[role] - AddToManagerFuncs[role] = append(fns, add) - -} - -// AddToManager adds all webhooks to the Manager -func AddToManager(m manager.Manager, roles []string, paramsFn func() (*Parameters, error)) error { - var params *Parameters - var err error - for k, fs := range AddToManagerFuncs { - if stringsutil.StringInSlice(operator.All, roles) || stringsutil.StringInSlice(k, roles) { - if params == nil { - // lazily initialize params so that errors happen only if we actually want to use a webhook - params, err = paramsFn() - if err != nil { - return err - } - } - for _, f := range fs { - if err := f(m, *params); err != nil { - return err - } - } - } - } - return nil -} diff --git a/test/e2e/Dockerfile b/test/e2e/Dockerfile index b3e9214f28..7b9c3313ae 100644 --- a/test/e2e/Dockerfile +++ b/test/e2e/Dockerfile @@ -1,5 +1,5 @@ # Run e2e tests -FROM golang:1.11 +FROM golang:1.13 # Create the go test cache directory RUN mkdir -p /.cache && chmod 777 /.cache diff --git a/test/e2e/apm/association_test.go b/test/e2e/apm/association_test.go index 98ade73f83..597278014e 100644 --- a/test/e2e/apm/association_test.go +++ b/test/e2e/apm/association_test.go @@ -65,7 +65,7 @@ func TestAPMAssociationWithNonExistentES(t *testing.T) { steps = steps.WithStep(test.Step{ Name: "Non existent backend should generate event", Test: test.Eventually(func() error { - eventList, err := k.GetEvents(test.EventListOptions(apmBuilder.ApmServer.Namespace, apmBuilder.ApmServer.Name)) + eventList, err := k.GetEvents(test.EventListOptions(apmBuilder.ApmServer.Namespace, apmBuilder.ApmServer.Name)...) if err != nil { return err } @@ -106,7 +106,7 @@ func TestAPMAssociationWhenReferencedESDisappears(t *testing.T) { test.Step{ Name: "Lost Elasticsearch association should generate events", Test: test.Eventually(func() error { - eventList, err := k.GetEvents(test.EventListOptions(apmBuilder.ApmServer.Namespace, apmBuilder.ApmServer.Name)) + eventList, err := k.GetEvents(test.EventListOptions(apmBuilder.ApmServer.Namespace, apmBuilder.ApmServer.Name)...) if err != nil { return err } diff --git a/test/e2e/apm/configuration_test.go b/test/e2e/apm/configuration_test.go index 4db22c5ebd..0fc4716b22 100644 --- a/test/e2e/apm/configuration_test.go +++ b/test/e2e/apm/configuration_test.go @@ -83,7 +83,7 @@ func TestUpdateConfiguration(t *testing.T) { }, }, // Keystore should be empty - test.CheckKeystoreEntries(k, apmPodListOpts, APMKeystoreCmd, nil), + test.CheckKeystoreEntries(k, APMKeystoreCmd, nil, apmPodListOpts...), } } @@ -105,7 +105,7 @@ func TestUpdateConfiguration(t *testing.T) { Name: "Add a Keystore to the APM server", Test: func(t *testing.T) { // get current pod id - pods, err := k.GetPods(apmPodListOpts) + pods, err := k.GetPods(apmPodListOpts...) require.NoError(t, err) require.True(t, len(pods) == 1) previousPodUID = &pods[0].UID @@ -122,7 +122,7 @@ func TestUpdateConfiguration(t *testing.T) { Name: "APM Pod should be recreated", Test: test.Eventually(func() error { // get current pod id - pods, err := k.GetPods(apmPodListOpts) + pods, err := k.GetPods(apmPodListOpts...) if err != nil { return err } @@ -136,13 +136,13 @@ func TestUpdateConfiguration(t *testing.T) { }), }, - test.CheckKeystoreEntries(k, apmPodListOpts, APMKeystoreCmd, []string{"logging.verbose"}), + test.CheckKeystoreEntries(k, APMKeystoreCmd, []string{"logging.verbose"}, apmPodListOpts...), test.Step{ Name: "Customize configuration of the APM server", Test: func(t *testing.T) { // get current pod id - pods, err := k.GetPods(apmPodListOpts) + pods, err := k.GetPods(apmPodListOpts...) require.NoError(t, err) require.True(t, len(pods) == 1) previousPodUID = &pods[0].UID @@ -160,7 +160,7 @@ func TestUpdateConfiguration(t *testing.T) { Name: "APM Pod should be recreated", Test: test.Eventually(func() error { // get current pod id - pods, err := k.GetPods(apmPodListOpts) + pods, err := k.GetPods(apmPodListOpts...) if err != nil { return err } @@ -201,7 +201,7 @@ func TestUpdateConfiguration(t *testing.T) { func partialAPMConfiguration(k *test.K8sClient, namespace, name string) (PartialApmConfiguration, error) { var config PartialApmConfiguration // get current pods - pods, err := k.GetPods(test.ApmServerPodListOptions(namespace, name)) + pods, err := k.GetPods(test.ApmServerPodListOptions(namespace, name)...) if err != nil { return config, err } diff --git a/test/e2e/cmd/run/eventlog.go b/test/e2e/cmd/run/eventlog.go index 612ade55ca..bff462cbc4 100644 --- a/test/e2e/cmd/run/eventlog.go +++ b/test/e2e/cmd/run/eventlog.go @@ -19,7 +19,6 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" "k8s.io/client-go/util/workqueue" - "k8s.io/kubernetes/pkg/controller/volume/events" ) type eventLogEntry struct { @@ -136,7 +135,11 @@ func (el *eventLogger) runEventProcessor() { // isInterestingEvent determines whether an event is worthy of logging. func (el *eventLogger) isInterestingEvent(evt *corev1.Event) bool { // special case for event generated when attempting to reuse a deleted PV - if evt.Reason == events.VolumeDelete { + // This constant is defined in "k8s.io/kubernetes/pkg/controller/volume/events".VolumeDelete + // but importing that with go modules is painful, see here: + // https://github.com/golang/go/issues/32776#issuecomment-505607726 + // I did not see this defined anywhere else and nothing else in our code base uses the package, so seemed reasonable to copy/paste + if evt.Reason == "VolumeDelete" { return true } diff --git a/test/e2e/es/certs_test.go b/test/e2e/es/certs_test.go index 0db4094a3d..75572fe922 100644 --- a/test/e2e/es/certs_test.go +++ b/test/e2e/es/certs_test.go @@ -109,7 +109,7 @@ func getCert(k *test.K8sClient, ns string, esName string) ([]byte, error) { func getPodIP(k *test.K8sClient, ns string, esName string) (string, error) { - pods, err := k.GetPods(test.ESPodListOptions(ns, esName)) + pods, err := k.GetPods(test.ESPodListOptions(ns, esName)...) if err != nil { return "", err } diff --git a/test/e2e/es/failure_test.go b/test/e2e/es/failure_test.go index 0b69ea86db..d0b296a849 100644 --- a/test/e2e/es/failure_test.go +++ b/test/e2e/es/failure_test.go @@ -27,7 +27,7 @@ func TestKillOneDataNode(t *testing.T) { } test.RunRecoverableFailureScenario(t, - test.KillNodeSteps(test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name), matchDataNode), + test.KillNodeSteps(matchDataNode, test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name)...), b) } @@ -42,7 +42,7 @@ func TestKillOneMasterNode(t *testing.T) { } test.RunRecoverableFailureScenario(t, - test.KillNodeSteps(test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name), matchMasterNode), + test.KillNodeSteps(matchMasterNode, test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name)...), b) } @@ -55,7 +55,7 @@ func TestKillSingleNodeReusePV(t *testing.T) { } test.RunRecoverableFailureScenario(t, - test.KillNodeSteps(test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name), matchNode), + test.KillNodeSteps(matchNode, test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name)...), b) } diff --git a/test/e2e/kb/association_test.go b/test/e2e/kb/association_test.go index 291a89d9d4..1c081aaf49 100644 --- a/test/e2e/kb/association_test.go +++ b/test/e2e/kb/association_test.go @@ -58,7 +58,7 @@ func TestKibanaAssociationWithNonExistentES(t *testing.T) { steps = steps.WithStep(test.Step{ Name: "Non existent backend should generate event", Test: test.Eventually(func() error { - eventList, err := k.GetEvents(test.EventListOptions(kbBuilder.Kibana.Namespace, kbBuilder.Kibana.Name)) + eventList, err := k.GetEvents(test.EventListOptions(kbBuilder.Kibana.Namespace, kbBuilder.Kibana.Name)...) if err != nil { return err } @@ -99,7 +99,7 @@ func TestKibanaAssociationWhenReferencedESDisappears(t *testing.T) { test.Step{ Name: "Lost Elasticsearch association should generate events", Test: test.Eventually(func() error { - eventList, err := k.GetEvents(test.EventListOptions(kbBuilder.Kibana.Namespace, kbBuilder.Kibana.Name)) + eventList, err := k.GetEvents(test.EventListOptions(kbBuilder.Kibana.Namespace, kbBuilder.Kibana.Name)...) if err != nil { return err } diff --git a/test/e2e/kb/failure_test.go b/test/e2e/kb/failure_test.go index ff8426ba0d..439da351b6 100644 --- a/test/e2e/kb/failure_test.go +++ b/test/e2e/kb/failure_test.go @@ -29,7 +29,7 @@ func TestKillKibanaPod(t *testing.T) { return true } test.RunRecoverableFailureScenario(t, - test.KillNodeSteps(test.KibanaPodListOptions(kbBuilder.Kibana.Namespace, kbBuilder.Kibana.Name), matchFirst), + test.KillNodeSteps(matchFirst, test.KibanaPodListOptions(kbBuilder.Kibana.Namespace, kbBuilder.Kibana.Name)...), esBuilder, kbBuilder) } diff --git a/test/e2e/kb/keystore_test.go b/test/e2e/kb/keystore_test.go index fb05c1b6a6..fc4f48e374 100644 --- a/test/e2e/kb/keystore_test.go +++ b/test/e2e/kb/keystore_test.go @@ -65,7 +65,7 @@ func TestUpdateKibanaSecureSettings(t *testing.T) { stepsFn := func(k *test.K8sClient) test.StepList { return test.StepList{ - test.CheckKeystoreEntries(k, kbPodListOpts, KibanaKeystoreCmd, []string{"logging.verbose"}), + test.CheckKeystoreEntries(k, KibanaKeystoreCmd, []string{"logging.verbose"}, kbPodListOpts...), // modify the secure settings secret test.Step{ Name: "Modify secure settings secret", @@ -81,7 +81,7 @@ func TestUpdateKibanaSecureSettings(t *testing.T) { }, // keystore should be updated accordingly - test.CheckKeystoreEntries(k, kbPodListOpts, KibanaKeystoreCmd, []string{"logging.json", "logging.verbose"}), + test.CheckKeystoreEntries(k, KibanaKeystoreCmd, []string{"logging.json", "logging.verbose"}, kbPodListOpts...), // remove the secure settings reference test.Step{ @@ -99,7 +99,7 @@ func TestUpdateKibanaSecureSettings(t *testing.T) { }, // keystore should be updated accordingly - test.CheckKeystoreEntries(k, kbPodListOpts, KibanaKeystoreCmd, nil), + test.CheckKeystoreEntries(k, KibanaKeystoreCmd, nil, kbPodListOpts...), // cleanup extra resources test.Step{ diff --git a/test/e2e/kb/resource_test.go b/test/e2e/kb/resource_test.go index 0cc0af720e..432694bda0 100644 --- a/test/e2e/kb/resource_test.go +++ b/test/e2e/kb/resource_test.go @@ -39,7 +39,7 @@ func TestUpdateKibanaResources(t *testing.T) { test.Step{ Name: "Check resources are propagated to the pod spec", Test: func(t *testing.T) { - pods, err := k.GetPods(test.KibanaPodListOptions(kbBuilder.Kibana.Namespace, kbBuilder.Kibana.Name)) + pods, err := k.GetPods(test.KibanaPodListOptions(kbBuilder.Kibana.Namespace, kbBuilder.Kibana.Name)...) require.NoError(t, err) for _, p := range pods { require.Equal(t, resources, p.Spec.Containers[0].Resources) diff --git a/test/e2e/test/apmserver/checks_k8s.go b/test/e2e/test/apmserver/checks_k8s.go index ff4476e6cb..18ab855fbf 100644 --- a/test/e2e/test/apmserver/checks_k8s.go +++ b/test/e2e/test/apmserver/checks_k8s.go @@ -53,7 +53,7 @@ func CheckApmServerPodsCount(b Builder, k *test.K8sClient) test.Step { return test.Step{ Name: "ApmServer pods count should match the expected one", Test: test.Eventually(func() error { - return k.CheckPodCount(test.ApmServerPodListOptions(b.ApmServer.Namespace, b.ApmServer.Name), int(b.ApmServer.Spec.NodeCount)) + return k.CheckPodCount(int(b.ApmServer.Spec.NodeCount), test.ApmServerPodListOptions(b.ApmServer.Namespace, b.ApmServer.Name)...) }), } } @@ -63,7 +63,7 @@ func CheckApmServerPodsRunning(b Builder, k *test.K8sClient) test.Step { return test.Step{ Name: "ApmServer pods should eventually be running", Test: test.Eventually(func() error { - pods, err := k.GetPods(test.ApmServerPodListOptions(b.ApmServer.Namespace, b.ApmServer.Name)) + pods, err := k.GetPods(test.ApmServerPodListOptions(b.ApmServer.Namespace, b.ApmServer.Name)...) if err != nil { return err } diff --git a/test/e2e/test/apmserver/steps_deletion.go b/test/e2e/test/apmserver/steps_deletion.go index 08a86b490b..8d52c56703 100644 --- a/test/e2e/test/apmserver/steps_deletion.go +++ b/test/e2e/test/apmserver/steps_deletion.go @@ -50,7 +50,7 @@ func (b Builder) DeletionTestSteps(k *test.K8sClient) test.StepList { { Name: "APM Server pods should be eventually be removed", Test: test.Eventually(func() error { - return k.CheckPodCount(test.ApmServerPodListOptions(b.ApmServer.Namespace, b.ApmServer.Name), 0) + return k.CheckPodCount(0, test.ApmServerPodListOptions(b.ApmServer.Namespace, b.ApmServer.Name)...) }), }, } diff --git a/test/e2e/test/apmserver/steps_init.go b/test/e2e/test/apmserver/steps_init.go index a3afa949e3..ae22fbf60b 100644 --- a/test/e2e/test/apmserver/steps_init.go +++ b/test/e2e/test/apmserver/steps_init.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" - "sigs.k8s.io/controller-runtime/pkg/client" ) func (b Builder) InitTestSteps(k *test.K8sClient) test.StepList { @@ -21,7 +20,7 @@ func (b Builder) InitTestSteps(k *test.K8sClient) test.StepList { Name: "K8S should be accessible", Test: func(t *testing.T) { pods := corev1.PodList{} - err := k.Client.List(&client.ListOptions{}, &pods) + err := k.Client.List(&pods) require.NoError(t, err) }, }, @@ -29,7 +28,7 @@ func (b Builder) InitTestSteps(k *test.K8sClient) test.StepList { { Name: "APM Server CRDs should exist", Test: func(t *testing.T) { - err := k.Client.List(&client.ListOptions{}, &apmtype.ApmServerList{}) + err := k.Client.List(&apmtype.ApmServerList{}) require.NoError(t, err) }, }, @@ -46,7 +45,7 @@ func (b Builder) InitTestSteps(k *test.K8sClient) test.StepList { } // wait for ES pods to disappear test.Eventually(func() error { - return k.CheckPodCount(test.ApmServerPodListOptions(b.ApmServer.Namespace, b.ApmServer.Name), 0) + return k.CheckPodCount(0, test.ApmServerPodListOptions(b.ApmServer.Namespace, b.ApmServer.Name)...) })(t) }, }, diff --git a/test/e2e/test/elasticsearch/checks_k8s.go b/test/e2e/test/elasticsearch/checks_k8s.go index 4c00c25839..86eb19e55f 100644 --- a/test/e2e/test/elasticsearch/checks_k8s.go +++ b/test/e2e/test/elasticsearch/checks_k8s.go @@ -59,7 +59,7 @@ func CheckPodCertificates(b Builder, k *test.K8sClient) test.Step { return test.Step{ Name: "ES pods should eventually have a certificate", Test: test.Eventually(func() error { - pods, err := k.GetPods(test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name)) + pods, err := k.GetPods(test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name)...) if err != nil { return err } @@ -79,7 +79,7 @@ func CheckESPodsRunning(b Builder, k *test.K8sClient) test.Step { return test.Step{ Name: "ES pods should eventually be running", Test: test.Eventually(func() error { - pods, err := k.GetPods(test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name)) + pods, err := k.GetPods(test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name)...) if err != nil { return err } @@ -99,7 +99,7 @@ func CheckESVersion(b Builder, k *test.K8sClient) test.Step { return test.Step{ Name: "ES version should be the expected one", Test: test.Eventually(func() error { - pods, err := k.GetPods(test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name)) + pods, err := k.GetPods(test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name)...) if err != nil { return err } @@ -125,7 +125,7 @@ func CheckESPodsReady(b Builder, k *test.K8sClient) test.Step { return test.Step{ Name: "ES pods should eventually be ready", Test: test.Eventually(func() error { - pods, err := k.GetPods(test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name)) + pods, err := k.GetPods(test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name)...) if err != nil { return err } diff --git a/test/e2e/test/elasticsearch/checks_keystore.go b/test/e2e/test/elasticsearch/checks_keystore.go index 5f035115f0..30d1ee2ed0 100644 --- a/test/e2e/test/elasticsearch/checks_keystore.go +++ b/test/e2e/test/elasticsearch/checks_keystore.go @@ -21,7 +21,7 @@ func CheckESKeystoreEntries(k *test.K8sClient, es v1alpha1.Elasticsearch, expect return test.Step{ Name: "Elasticsearch secure settings should eventually be set in all nodes keystore", Test: test.Eventually(func() error { - pods, err := k.GetPods(test.ESPodListOptions(es.Namespace, es.Name)) + pods, err := k.GetPods(test.ESPodListOptions(es.Namespace, es.Name)...) if err != nil { return err } diff --git a/test/e2e/test/elasticsearch/checks_volume.go b/test/e2e/test/elasticsearch/checks_volume.go index c497a0d025..1134d69105 100644 --- a/test/e2e/test/elasticsearch/checks_volume.go +++ b/test/e2e/test/elasticsearch/checks_volume.go @@ -30,7 +30,7 @@ func CheckESDataVolumeType(es estype.Elasticsearch, k *test.K8sClient) test.Step Name: "Elasticsearch data volumes should be of the specified type", Test: func(t *testing.T) { checkForEmptyDir := usesEmptyDir(es) - pods, err := k.GetPods(test.ESPodListOptions(es.Namespace, es.Name)) + pods, err := k.GetPods(test.ESPodListOptions(es.Namespace, es.Name)...) require.NoError(t, err) for _, p := range pods { for _, v := range p.Spec.Volumes { diff --git a/test/e2e/test/elasticsearch/steps_deletion.go b/test/e2e/test/elasticsearch/steps_deletion.go index 09dd9cfd91..4ec5b64ff8 100644 --- a/test/e2e/test/elasticsearch/steps_deletion.go +++ b/test/e2e/test/elasticsearch/steps_deletion.go @@ -13,7 +13,6 @@ import ( corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" - "k8s.io/apimachinery/pkg/labels" "sigs.k8s.io/controller-runtime/pkg/client" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/label" @@ -56,19 +55,18 @@ func (b Builder) DeletionTestSteps(k *test.K8sClient) test.StepList { { Name: "Elasticsearch pods should be eventually be removed", Test: test.Eventually(func() error { - return k.CheckPodCount(test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name), 0) + return k.CheckPodCount(0, test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name)...) }), }, { Name: "PVCs should eventually be removed", Test: test.Eventually(func() error { var pvcs corev1.PersistentVolumeClaimList - err := k.Client.List(&client.ListOptions{ - Namespace: b.Elasticsearch.Namespace, - LabelSelector: labels.SelectorFromSet(map[string]string{ - label.ClusterNameLabelName: b.Elasticsearch.Name, - }), - }, &pvcs) + ns := client.InNamespace(b.Elasticsearch.Namespace) + matchLabels := client.MatchingLabels(map[string]string{ + label.ClusterNameLabelName: b.Elasticsearch.Name, + }) + err := k.Client.List(&pvcs, ns, matchLabels) if err != nil { return err } diff --git a/test/e2e/test/elasticsearch/steps_init.go b/test/e2e/test/elasticsearch/steps_init.go index 2048ccb46b..384d9ed101 100644 --- a/test/e2e/test/elasticsearch/steps_init.go +++ b/test/e2e/test/elasticsearch/steps_init.go @@ -15,7 +15,6 @@ import ( corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" - "sigs.k8s.io/controller-runtime/pkg/client" ) // InitTestSteps includes pre-requisite tests (eg. is k8s accessible), @@ -26,7 +25,7 @@ func (b Builder) InitTestSteps(k *test.K8sClient) test.StepList { Name: "K8S should be accessible", Test: func(t *testing.T) { pods := corev1.PodList{} - err := k.Client.List(&client.ListOptions{}, &pods) + err := k.Client.List(&pods) require.NoError(t, err) }, }, @@ -38,7 +37,7 @@ func (b Builder) InitTestSteps(k *test.K8sClient) test.StepList { &estype.ElasticsearchList{}, } for _, crd := range crds { - err := k.Client.List(&client.ListOptions{}, crd) + err := k.Client.List(crd) require.NoError(t, err) } }, @@ -56,7 +55,7 @@ func (b Builder) InitTestSteps(k *test.K8sClient) test.StepList { } // wait for ES pods to disappear test.Eventually(func() error { - return k.CheckPodCount(test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name), 0) + return k.CheckPodCount(0, test.ESPodListOptions(b.Elasticsearch.Namespace, b.Elasticsearch.Name)...) })(t) // it may take some extra time for Elasticsearch to be fully deleted diff --git a/test/e2e/test/k8s_client.go b/test/e2e/test/k8s_client.go index 3377316946..eabc6bb3e2 100644 --- a/test/e2e/test/k8s_client.go +++ b/test/e2e/test/k8s_client.go @@ -11,7 +11,6 @@ import ( "os" apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1alpha1" - assoctype "github.com/elastic/cloud-on-k8s/pkg/apis/associations/v1alpha1" estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1alpha1" kbtype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1alpha1" apmlabels "github.com/elastic/cloud-on-k8s/pkg/controller/apmserver/labels" @@ -26,8 +25,6 @@ import ( "github.com/elastic/cloud-on-k8s/pkg/utils/k8s" "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/fields" - "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/version" @@ -74,9 +71,6 @@ func CreateClient() (k8s.Client, error) { if err := kbtype.AddToScheme(scheme.Scheme); err != nil { return nil, err } - if err := assoctype.AddToScheme(scheme.Scheme); err != nil { - return nil, err - } if err := apmtype.AddToScheme(scheme.Scheme); err != nil { return nil, err } @@ -99,9 +93,9 @@ func ServerVersion() (*version.Info, error) { return dc.ServerVersion() } -func (k *K8sClient) GetPods(listOpts k8sclient.ListOptions) ([]corev1.Pod, error) { +func (k *K8sClient) GetPods(opts ...k8sclient.ListOption) ([]corev1.Pod, error) { var podList corev1.PodList - if err := k.Client.List(&listOpts, &podList); err != nil { + if err := k.Client.List(&podList, opts...); err != nil { return nil, err } return podList.Items, nil @@ -119,8 +113,8 @@ func (k *K8sClient) DeletePod(pod corev1.Pod) error { return k.Client.Delete(&pod) } -func (k *K8sClient) CheckPodCount(listOpts k8sclient.ListOptions, expectedCount int) error { - pods, err := k.GetPods(listOpts) +func (k *K8sClient) CheckPodCount(expectedCount int, opts ...k8sclient.ListOption) error { + pods, err := k.GetPods(opts...) if err != nil { return err } @@ -155,9 +149,9 @@ func (k *K8sClient) GetEndpoints(namespace, name string) (*corev1.Endpoints, err return &endpoints, nil } -func (k *K8sClient) GetEvents(listOpts k8sclient.ListOptions) ([]corev1.Event, error) { +func (k *K8sClient) GetEvents(opts ...k8sclient.ListOption) ([]corev1.Event, error) { var eventList corev1.EventList - if err := k.Client.List(&listOpts, &eventList); err != nil { + if err := k.Client.List(&eventList, opts...); err != nil { return nil, err } return eventList.Items, nil @@ -312,40 +306,40 @@ func (k *K8sClient) Exec(pod types.NamespacedName, cmd []string) (string, string return stdout.String(), stderr.String(), err } -func ESPodListOptions(esNamespace, esName string) k8sclient.ListOptions { - return k8sclient.ListOptions{ - Namespace: esNamespace, - LabelSelector: labels.SelectorFromSet(labels.Set(map[string]string{ - common.TypeLabelName: label.Type, - label.ClusterNameLabelName: esName, - }))} +func ESPodListOptions(esNamespace, esName string) []k8sclient.ListOption { + ns := k8sclient.InNamespace(esNamespace) + matchLabels := k8sclient.MatchingLabels(map[string]string{ + common.TypeLabelName: label.Type, + label.ClusterNameLabelName: esName, + }) + return []k8sclient.ListOption{ns, matchLabels} } -func KibanaPodListOptions(kbNamespace, kbName string) k8sclient.ListOptions { - return k8sclient.ListOptions{ - Namespace: kbNamespace, - LabelSelector: labels.SelectorFromSet(labels.Set(map[string]string{ - kblabel.KibanaNameLabelName: kbName, - }))} +func KibanaPodListOptions(kbNamespace, kbName string) []k8sclient.ListOption { + ns := k8sclient.InNamespace(kbNamespace) + matchLabels := k8sclient.MatchingLabels(map[string]string{ + kblabel.KibanaNameLabelName: kbName, + }) + return []k8sclient.ListOption{ns, matchLabels} } -func ApmServerPodListOptions(apmNamespace, apmName string) k8sclient.ListOptions { - return k8sclient.ListOptions{ - Namespace: apmNamespace, - LabelSelector: labels.SelectorFromSet(labels.Set(map[string]string{ - common.TypeLabelName: apmlabels.Type, - apmlabels.ApmServerNameLabelName: apmName, - }))} +func ApmServerPodListOptions(apmNamespace, apmName string) []k8sclient.ListOption { + ns := k8sclient.InNamespace(apmNamespace) + matchLabels := k8sclient.MatchingLabels(map[string]string{ + common.TypeLabelName: apmlabels.Type, + apmlabels.ApmServerNameLabelName: apmName, + }) + return []k8sclient.ListOption{ns, matchLabels} + } -func EventListOptions(namespace, name string) k8sclient.ListOptions { - return k8sclient.ListOptions{ - Namespace: namespace, - FieldSelector: fields.SelectorFromSet(fields.Set(map[string]string{ - "involvedObject.name": name, - "involvedObject.namespace": namespace, - })), - } +func EventListOptions(namespace, name string) []k8sclient.ListOption { + ns := k8sclient.InNamespace(namespace) + matchFields := k8sclient.MatchingFields(map[string]string{ + "involvedObject.name": name, + "involvedObject.namespace": namespace, + }) + return []k8sclient.ListOption{ns, matchFields} } func GetFirstPodMatching(pods []corev1.Pod, predicate func(pod corev1.Pod) bool) (corev1.Pod, bool) { diff --git a/test/e2e/test/kibana/checks_k8s.go b/test/e2e/test/kibana/checks_k8s.go index 2c4611d601..e33665bef2 100644 --- a/test/e2e/test/kibana/checks_k8s.go +++ b/test/e2e/test/kibana/checks_k8s.go @@ -54,7 +54,7 @@ func CheckKibanaPodsCount(b Builder, k *test.K8sClient) test.Step { return test.Step{ Name: "Kibana pods count should match the expected one", Test: test.Eventually(func() error { - return k.CheckPodCount(test.KibanaPodListOptions(b.Kibana.Namespace, b.Kibana.Name), int(b.Kibana.Spec.NodeCount)) + return k.CheckPodCount(int(b.Kibana.Spec.NodeCount), test.KibanaPodListOptions(b.Kibana.Namespace, b.Kibana.Name)...) }), } } @@ -64,7 +64,7 @@ func CheckKibanaPodsRunning(b Builder, k *test.K8sClient) test.Step { return test.Step{ Name: "Kibana pods should eventually be running", Test: test.Eventually(func() error { - pods, err := k.GetPods(test.KibanaPodListOptions(b.Kibana.Namespace, b.Kibana.Name)) + pods, err := k.GetPods(test.KibanaPodListOptions(b.Kibana.Namespace, b.Kibana.Name)...) if err != nil { return err } diff --git a/test/e2e/test/kibana/steps_deletion.go b/test/e2e/test/kibana/steps_deletion.go index c1b8185ebe..c632a3d96b 100644 --- a/test/e2e/test/kibana/steps_deletion.go +++ b/test/e2e/test/kibana/steps_deletion.go @@ -51,7 +51,7 @@ func (b Builder) DeletionTestSteps(k *test.K8sClient) test.StepList { { Name: "Kibana pods should be eventually be removed", Test: test.Eventually(func() error { - return k.CheckPodCount(test.KibanaPodListOptions(b.Kibana.Namespace, b.Kibana.Name), 0) + return k.CheckPodCount(0, test.KibanaPodListOptions(b.Kibana.Namespace, b.Kibana.Name)...) }), }, } diff --git a/test/e2e/test/kibana/steps_init.go b/test/e2e/test/kibana/steps_init.go index 6a7442da83..4162c647d1 100644 --- a/test/e2e/test/kibana/steps_init.go +++ b/test/e2e/test/kibana/steps_init.go @@ -13,7 +13,6 @@ import ( corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" - "sigs.k8s.io/controller-runtime/pkg/client" ) func (b Builder) InitTestSteps(k *test.K8sClient) test.StepList { @@ -22,7 +21,7 @@ func (b Builder) InitTestSteps(k *test.K8sClient) test.StepList { Name: "K8S should be accessible", Test: func(t *testing.T) { pods := corev1.PodList{} - err := k.Client.List(&client.ListOptions{}, &pods) + err := k.Client.List(&pods) require.NoError(t, err) }, }, @@ -33,7 +32,7 @@ func (b Builder) InitTestSteps(k *test.K8sClient) test.StepList { &kbtype.KibanaList{}, } for _, crd := range crds { - err := k.Client.List(&client.ListOptions{}, crd) + err := k.Client.List(crd) require.NoError(t, err) } }, @@ -50,7 +49,7 @@ func (b Builder) InitTestSteps(k *test.K8sClient) test.StepList { } // wait for Kibana pods to disappear test.Eventually(func() error { - return k.CheckPodCount(test.KibanaPodListOptions(b.Kibana.Namespace, b.Kibana.Name), 0) + return k.CheckPodCount(0, test.KibanaPodListOptions(b.Kibana.Namespace, b.Kibana.Name)...) })(t) }, }, diff --git a/test/e2e/test/run_failure.go b/test/e2e/test/run_failure.go index c193ab5e06..6698a1c0ae 100644 --- a/test/e2e/test/run_failure.go +++ b/test/e2e/test/run_failure.go @@ -56,14 +56,14 @@ func runFailureScenario(t *testing.T, recoverable bool, failureSteps StepsFunc, steps.RunSequential(t) } -func KillNodeSteps(listOptions client.ListOptions, podMatch func(p corev1.Pod) bool) StepsFunc { +func KillNodeSteps(podMatch func(p corev1.Pod) bool, opts ...client.ListOption) StepsFunc { var killedPod corev1.Pod return func(k *K8sClient) StepList { return StepList{ { Name: "Kill a node", Test: func(t *testing.T) { - pods, err := k.GetPods(listOptions) + pods, err := k.GetPods(opts...) require.NoError(t, err) var found bool killedPod, found = GetFirstPodMatching(pods, podMatch) diff --git a/test/e2e/test/utils.go b/test/e2e/test/utils.go index 0f6bf856e4..9f709b9a99 100644 --- a/test/e2e/test/utils.go +++ b/test/e2e/test/utils.go @@ -25,11 +25,11 @@ const ( defaultTimeout = 5 * time.Minute ) -func CheckKeystoreEntries(k *K8sClient, listOption client.ListOptions, keystoreCmd []string, expectedKeys []string) Step { +func CheckKeystoreEntries(k *K8sClient, keystoreCmd []string, expectedKeys []string, opts ...client.ListOption) Step { return Step{ Name: "secure settings should eventually be set in all nodes keystore", Test: Eventually(func() error { - pods, err := k.GetPods(listOption) + pods, err := k.GetPods(opts...) if err != nil { return err }