From 87bf0956ebec8d0c0fe45b8908ff8f8a3ace262d Mon Sep 17 00:00:00 2001 From: Shivam Rathore Date: Fri, 24 Apr 2020 12:39:20 +0530 Subject: [PATCH] Add custom resource label for AppDeployment instead of directly in BlueGreen --- ...ttermost.com_clusterinstallations_crd.yaml | 16 +- .../mattermost-operator.yaml | 16 +- go.mod | 2 +- go.sum | 2 + .../v1alpha1/clusterinstallation_types.go | 6 +- .../v1alpha1/clusterinstallation_utils.go | 17 +- .../v1alpha1/zz_generated.deepcopy.go | 22 +- .../versioned/fake/clientset_generated.go | 69 --- pkg/client/clientset/versioned/fake/doc.go | 7 - .../clientset/versioned/fake/register.go | 43 -- .../listers/clientset/versioned/clientset.go | 84 --- pkg/client/listers/clientset/versioned/doc.go | 7 - .../versioned/fake/clientset_generated.go | 69 --- .../listers/clientset/versioned/fake/doc.go | 7 - .../clientset/versioned/fake/register.go | 43 -- .../listers/clientset/versioned/scheme/doc.go | 7 - .../clientset/versioned/scheme/register.go | 43 -- .../v1alpha1/clusterinstallation.go | 178 ------ .../typed/mattermost/v1alpha1/doc.go | 7 - .../typed/mattermost/v1alpha1/fake/doc.go | 7 - .../v1alpha1/fake/fake_clusterinstallation.go | 127 ---- .../v1alpha1/fake/fake_mattermost_client.go | 27 - .../v1alpha1/generated_expansion.go | 8 - .../mattermost/v1alpha1/mattermost_client.go | 76 --- .../informers/externalversions/factory.go | 167 ------ .../informers/externalversions/generic.go | 49 -- .../internalinterfaces/factory_interfaces.go | 27 - .../externalversions/mattermost/interface.go | 33 - .../v1alpha1/clusterinstallation.go | 76 --- .../mattermost/v1alpha1/interface.go | 32 - .../v1alpha1/clusterinstallation.go | 81 --- .../v1alpha1/expansion_generated.go | 14 - .../x/tools/internal/event/core/event.go | 106 ++++ .../{telemetry/event => event/core}/export.go | 20 +- .../x/tools/internal/event/core/fast.go | 57 ++ .../golang.org/x/tools/internal/event/doc.go | 7 + .../x/tools/internal/event/event.go | 69 +++ .../x/tools/internal/event/keys/keys.go | 542 +++++++++++++++++ .../x/tools/internal/event/keys/standard.go | 14 + .../x/tools/internal/event/label/label.go | 213 +++++++ .../x/tools/internal/gocommand/invoke.go | 7 +- .../x/tools/internal/imports/zstdlib.go | 87 +++ .../x/tools/internal/telemetry/event/event.go | 113 ---- .../x/tools/internal/telemetry/event/key.go | 565 ------------------ .../x/tools/internal/telemetry/event/label.go | 29 - .../x/tools/internal/telemetry/event/log.go | 59 -- .../tools/internal/telemetry/event/metric.go | 29 - .../x/tools/internal/telemetry/event/tag.go | 188 ------ .../x/tools/internal/telemetry/event/trace.go | 42 -- .../client-go/discovery/fake/discovery.go | 160 ----- vendor/modules.txt | 8 +- 51 files changed, 1168 insertions(+), 2516 deletions(-) delete mode 100644 pkg/client/clientset/versioned/fake/clientset_generated.go delete mode 100644 pkg/client/clientset/versioned/fake/doc.go delete mode 100644 pkg/client/clientset/versioned/fake/register.go delete mode 100644 pkg/client/listers/clientset/versioned/clientset.go delete mode 100644 pkg/client/listers/clientset/versioned/doc.go delete mode 100644 pkg/client/listers/clientset/versioned/fake/clientset_generated.go delete mode 100644 pkg/client/listers/clientset/versioned/fake/doc.go delete mode 100644 pkg/client/listers/clientset/versioned/fake/register.go delete mode 100644 pkg/client/listers/clientset/versioned/scheme/doc.go delete mode 100644 pkg/client/listers/clientset/versioned/scheme/register.go delete mode 100644 pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/clusterinstallation.go delete mode 100644 pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/doc.go delete mode 100644 pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/fake/doc.go delete mode 100644 pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/fake/fake_clusterinstallation.go delete mode 100644 pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/fake/fake_mattermost_client.go delete mode 100644 pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/generated_expansion.go delete mode 100644 pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/mattermost_client.go delete mode 100644 pkg/client/listers/informers/externalversions/factory.go delete mode 100644 pkg/client/listers/informers/externalversions/generic.go delete mode 100644 pkg/client/listers/informers/externalversions/internalinterfaces/factory_interfaces.go delete mode 100644 pkg/client/listers/informers/externalversions/mattermost/interface.go delete mode 100644 pkg/client/listers/informers/externalversions/mattermost/v1alpha1/clusterinstallation.go delete mode 100644 pkg/client/listers/informers/externalversions/mattermost/v1alpha1/interface.go delete mode 100644 pkg/client/listers/listers/mattermost/v1alpha1/clusterinstallation.go delete mode 100644 pkg/client/listers/listers/mattermost/v1alpha1/expansion_generated.go create mode 100644 vendor/golang.org/x/tools/internal/event/core/event.go rename vendor/golang.org/x/tools/internal/{telemetry/event => event/core}/export.go (76%) create mode 100644 vendor/golang.org/x/tools/internal/event/core/fast.go create mode 100644 vendor/golang.org/x/tools/internal/event/doc.go create mode 100644 vendor/golang.org/x/tools/internal/event/event.go create mode 100644 vendor/golang.org/x/tools/internal/event/keys/keys.go create mode 100644 vendor/golang.org/x/tools/internal/event/keys/standard.go create mode 100644 vendor/golang.org/x/tools/internal/event/label/label.go delete mode 100644 vendor/golang.org/x/tools/internal/telemetry/event/event.go delete mode 100644 vendor/golang.org/x/tools/internal/telemetry/event/key.go delete mode 100644 vendor/golang.org/x/tools/internal/telemetry/event/label.go delete mode 100644 vendor/golang.org/x/tools/internal/telemetry/event/log.go delete mode 100644 vendor/golang.org/x/tools/internal/telemetry/event/metric.go delete mode 100644 vendor/golang.org/x/tools/internal/telemetry/event/tag.go delete mode 100644 vendor/golang.org/x/tools/internal/telemetry/event/trace.go delete mode 100644 vendor/k8s.io/client-go/discovery/fake/discovery.go diff --git a/deploy/crds/mattermost.com_clusterinstallations_crd.yaml b/deploy/crds/mattermost.com_clusterinstallations_crd.yaml index 91db13e43..69359b19f 100644 --- a/deploy/crds/mattermost.com_clusterinstallations_crd.yaml +++ b/deploy/crds/mattermost.com_clusterinstallations_crd.yaml @@ -643,6 +643,10 @@ spec: name: description: Name defines the name of the deployment type: string + resourceLabels: + additionalProperties: + type: string + type: object version: description: Version defines the Docker image version that will be used for the deployment. Required when BlueGreen or Canary @@ -668,6 +672,10 @@ spec: name: description: Name defines the name of the deployment type: string + resourceLabels: + additionalProperties: + type: string + type: object version: description: Version defines the Docker image version that will be used for the deployment. Required when BlueGreen or Canary @@ -678,10 +686,6 @@ spec: description: ProductionDeployment defines if the current production is blue or green. type: string - resourceLabels: - additionalProperties: - type: string - type: object type: object canary: description: Canary defines the configuration of Canary deployment for @@ -703,6 +707,10 @@ spec: name: description: Name defines the name of the deployment type: string + resourceLabels: + additionalProperties: + type: string + type: object version: description: Version defines the Docker image version that will be used for the deployment. Required when BlueGreen or Canary diff --git a/docs/mattermost-operator/mattermost-operator.yaml b/docs/mattermost-operator/mattermost-operator.yaml index cf992b1c3..088a42352 100644 --- a/docs/mattermost-operator/mattermost-operator.yaml +++ b/docs/mattermost-operator/mattermost-operator.yaml @@ -648,6 +648,10 @@ spec: name: description: Name defines the name of the deployment type: string + resourceLabels: + additionalProperties: + type: string + type: object version: description: Version defines the Docker image version that will be used for the deployment. Required when BlueGreen or Canary @@ -673,6 +677,10 @@ spec: name: description: Name defines the name of the deployment type: string + resourceLabels: + additionalProperties: + type: string + type: object version: description: Version defines the Docker image version that will be used for the deployment. Required when BlueGreen or Canary @@ -683,10 +691,6 @@ spec: description: ProductionDeployment defines if the current production is blue or green. type: string - resourceLabels: - additionalProperties: - type: string - type: object type: object canary: description: Canary defines the configuration of Canary deployment for @@ -708,6 +712,10 @@ spec: name: description: Name defines the name of the deployment type: string + resourceLabels: + additionalProperties: + type: string + type: object version: description: Version defines the Docker image version that will be used for the deployment. Required when BlueGreen or Canary diff --git a/go.mod b/go.mod index 80c7a2aa5..f4a688986 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( golang.org/x/crypto v0.0.0-20200117160349-530e935923ad // indirect golang.org/x/net v0.0.0-20200226121028-0de0cce0169b golang.org/x/sys v0.0.0-20200122134326-e047566fdf82 // indirect - golang.org/x/tools v0.0.0-20200417140056-c07e33ef3290 // indirect + golang.org/x/tools v0.0.0-20200423205358-59e73619c742 // indirect k8s.io/api v0.17.2 k8s.io/apimachinery v0.17.2 k8s.io/client-go v12.0.0+incompatible diff --git a/go.sum b/go.sum index 268bd065d..e3205ab5f 100644 --- a/go.sum +++ b/go.sum @@ -1009,6 +1009,8 @@ golang.org/x/tools v0.0.0-20200327172716-42235f63843a h1:nZPvz874FG8d8iARpJWCyVt golang.org/x/tools v0.0.0-20200327172716-42235f63843a/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200417140056-c07e33ef3290 h1:NXNmtp0ToD36cui5IqWy95LC4Y6vT/4y3RnPxlQPinU= golang.org/x/tools v0.0.0-20200417140056-c07e33ef3290/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200423205358-59e73619c742 h1:9OGWpORUXvk8AsaBJlpzzDx7Srv/rSK6rvjcsJq4rJo= +golang.org/x/tools v0.0.0-20200423205358-59e73619c742/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/pkg/apis/mattermost/v1alpha1/clusterinstallation_types.go b/pkg/apis/mattermost/v1alpha1/clusterinstallation_types.go index 806d4c55a..e76112249 100644 --- a/pkg/apis/mattermost/v1alpha1/clusterinstallation_types.go +++ b/pkg/apis/mattermost/v1alpha1/clusterinstallation_types.go @@ -111,9 +111,6 @@ type BlueGreen struct { // Green defines the green deployment. // +optional Green AppDeployment `json:"green,omitempty"` - - // +optional - ResourceLabels map[string]string `json:"resourceLabels,omitempty"` } // AppDeployment defines the configuration of deployment for a ClusterInstallation. @@ -133,6 +130,9 @@ type AppDeployment struct { // Required when BlueGreen or Canary is enabled. // +optional Version string `json:"version,omitempty"` + + // +optional + ResourceLabels map[string]string `json:"resourceLabels,omitempty"` } // Minio defines the configuration of Minio for a ClusterInstallation. diff --git a/pkg/apis/mattermost/v1alpha1/clusterinstallation_utils.go b/pkg/apis/mattermost/v1alpha1/clusterinstallation_utils.go index 7a3db09ea..fbb7c9ca5 100644 --- a/pkg/apis/mattermost/v1alpha1/clusterinstallation_utils.go +++ b/pkg/apis/mattermost/v1alpha1/clusterinstallation_utils.go @@ -698,13 +698,20 @@ func (mattermost *ClusterInstallation) ClusterInstallationLabels(name string) ma l := ClusterInstallationResourceLabels(name) l[ClusterLabel] = name l["app"] = "mattermost" - if mattermost.Spec.BlueGreen.Enable && len(mattermost.Spec.BlueGreen.ResourceLabels) != 0 { - for k, v := range mattermost.Spec.BlueGreen.ResourceLabels { - l[k] = v + + labels := map[string]string{} + if mattermost.Spec.BlueGreen.Enable { + if mattermost.Spec.BlueGreen.ProductionDeployment == BlueName { + labels = mattermost.Spec.BlueGreen.Blue.ResourceLabels } - return l + if mattermost.Spec.BlueGreen.ProductionDeployment == GreenName { + labels = mattermost.Spec.BlueGreen.Green.ResourceLabels + } + } else { + labels = mattermost.Spec.ResourceLabels } - for k, v := range mattermost.Spec.ResourceLabels { + + for k, v := range labels { l[k] = v } return l diff --git a/pkg/apis/mattermost/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/mattermost/v1alpha1/zz_generated.deepcopy.go index 3692c552c..6acbbd786 100644 --- a/pkg/apis/mattermost/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/mattermost/v1alpha1/zz_generated.deepcopy.go @@ -15,6 +15,13 @@ import ( // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AppDeployment) DeepCopyInto(out *AppDeployment) { *out = *in + if in.ResourceLabels != nil { + in, out := &in.ResourceLabels, &out.ResourceLabels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } return } @@ -31,15 +38,8 @@ func (in *AppDeployment) DeepCopy() *AppDeployment { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BlueGreen) DeepCopyInto(out *BlueGreen) { *out = *in - out.Blue = in.Blue - out.Green = in.Green - if in.ResourceLabels != nil { - in, out := &in.ResourceLabels, &out.ResourceLabels - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } + in.Blue.DeepCopyInto(&out.Blue) + in.Green.DeepCopyInto(&out.Green) return } @@ -56,7 +56,7 @@ func (in *BlueGreen) DeepCopy() *BlueGreen { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Canary) DeepCopyInto(out *Canary) { *out = *in - out.Deployment = in.Deployment + in.Deployment.DeepCopyInto(&out.Deployment) return } @@ -169,7 +169,7 @@ func (in *ClusterInstallationSpec) DeepCopyInto(out *ClusterInstallationSpec) { in.Minio.DeepCopyInto(&out.Minio) in.Database.DeepCopyInto(&out.Database) in.BlueGreen.DeepCopyInto(&out.BlueGreen) - out.Canary = in.Canary + in.Canary.DeepCopyInto(&out.Canary) out.ElasticSearch = in.ElasticSearch if in.ServiceAnnotations != nil { in, out := &in.ServiceAnnotations, &out.ServiceAnnotations diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go deleted file mode 100644 index 11a17119c..000000000 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - clientset "github.com/mattermost/mattermost-operator/pkg/client/clientset/versioned" - mattermostv1alpha1 "github.com/mattermost/mattermost-operator/pkg/client/clientset/versioned/typed/mattermost/v1alpha1" - fakemattermostv1alpha1 "github.com/mattermost/mattermost-operator/pkg/client/clientset/versioned/typed/mattermost/v1alpha1/fake" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/client-go/discovery" - fakediscovery "k8s.io/client-go/discovery/fake" - "k8s.io/client-go/testing" -) - -// NewSimpleClientset returns a clientset that will respond with the provided objects. -// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, -// without applying any validations and/or defaults. It shouldn't be considered a replacement -// for a real clientset and is mostly useful in simple unit tests. -func NewSimpleClientset(objects ...runtime.Object) *Clientset { - o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) - for _, obj := range objects { - if err := o.Add(obj); err != nil { - panic(err) - } - } - - cs := &Clientset{tracker: o} - cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} - cs.AddReactor("*", "*", testing.ObjectReaction(o)) - cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { - gvr := action.GetResource() - ns := action.GetNamespace() - watch, err := o.Watch(gvr, ns) - if err != nil { - return false, nil, err - } - return true, watch, nil - }) - - return cs -} - -// Clientset implements clientset.Interface. Meant to be embedded into a -// struct to get a default implementation. This makes faking out just the method -// you want to test easier. -type Clientset struct { - testing.Fake - discovery *fakediscovery.FakeDiscovery - tracker testing.ObjectTracker -} - -func (c *Clientset) Discovery() discovery.DiscoveryInterface { - return c.discovery -} - -func (c *Clientset) Tracker() testing.ObjectTracker { - return c.tracker -} - -var _ clientset.Interface = &Clientset{} - -// MattermostV1alpha1 retrieves the MattermostV1alpha1Client -func (c *Clientset) MattermostV1alpha1() mattermostv1alpha1.MattermostV1alpha1Interface { - return &fakemattermostv1alpha1.FakeMattermostV1alpha1{Fake: &c.Fake} -} diff --git a/pkg/client/clientset/versioned/fake/doc.go b/pkg/client/clientset/versioned/fake/doc.go deleted file mode 100644 index a103f7fd1..000000000 --- a/pkg/client/clientset/versioned/fake/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated fake clientset. -package fake diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go deleted file mode 100644 index 438dc7d07..000000000 --- a/pkg/client/clientset/versioned/fake/register.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - mattermostv1alpha1 "github.com/mattermost/mattermost-operator/pkg/apis/mattermost/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" -) - -var scheme = runtime.NewScheme() -var codecs = serializer.NewCodecFactory(scheme) -var parameterCodec = runtime.NewParameterCodec(scheme) -var localSchemeBuilder = runtime.SchemeBuilder{ - mattermostv1alpha1.AddToScheme, -} - -// AddToScheme adds all types of this clientset into the given scheme. This allows composition -// of clientsets, like in: -// -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) -// -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) -// -// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types -// correctly. -var AddToScheme = localSchemeBuilder.AddToScheme - -func init() { - v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) - utilruntime.Must(AddToScheme(scheme)) -} diff --git a/pkg/client/listers/clientset/versioned/clientset.go b/pkg/client/listers/clientset/versioned/clientset.go deleted file mode 100644 index 5fbea59bf..000000000 --- a/pkg/client/listers/clientset/versioned/clientset.go +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -package versioned - -import ( - "fmt" - - mattermostv1alpha1 "github.com/mattermost/mattermost-operator/pkg/client/clientset/versioned/typed/mattermost/v1alpha1" - discovery "k8s.io/client-go/discovery" - rest "k8s.io/client-go/rest" - flowcontrol "k8s.io/client-go/util/flowcontrol" -) - -type Interface interface { - Discovery() discovery.DiscoveryInterface - MattermostV1alpha1() mattermostv1alpha1.MattermostV1alpha1Interface -} - -// Clientset contains the clients for groups. Each group has exactly one -// version included in a Clientset. -type Clientset struct { - *discovery.DiscoveryClient - mattermostV1alpha1 *mattermostv1alpha1.MattermostV1alpha1Client -} - -// MattermostV1alpha1 retrieves the MattermostV1alpha1Client -func (c *Clientset) MattermostV1alpha1() mattermostv1alpha1.MattermostV1alpha1Interface { - return c.mattermostV1alpha1 -} - -// Discovery retrieves the DiscoveryClient -func (c *Clientset) Discovery() discovery.DiscoveryInterface { - if c == nil { - return nil - } - return c.DiscoveryClient -} - -// NewForConfig creates a new Clientset for the given config. -// If config's RateLimiter is not set and QPS and Burst are acceptable, -// NewForConfig will generate a rate-limiter in configShallowCopy. -func NewForConfig(c *rest.Config) (*Clientset, error) { - configShallowCopy := *c - if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { - if configShallowCopy.Burst <= 0 { - return nil, fmt.Errorf("Burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") - } - configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) - } - var cs Clientset - var err error - cs.mattermostV1alpha1, err = mattermostv1alpha1.NewForConfig(&configShallowCopy) - if err != nil { - return nil, err - } - - cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) - if err != nil { - return nil, err - } - return &cs, nil -} - -// NewForConfigOrDie creates a new Clientset for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *Clientset { - var cs Clientset - cs.mattermostV1alpha1 = mattermostv1alpha1.NewForConfigOrDie(c) - - cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) - return &cs -} - -// New creates a new Clientset for the given RESTClient. -func New(c rest.Interface) *Clientset { - var cs Clientset - cs.mattermostV1alpha1 = mattermostv1alpha1.New(c) - - cs.DiscoveryClient = discovery.NewDiscoveryClient(c) - return &cs -} diff --git a/pkg/client/listers/clientset/versioned/doc.go b/pkg/client/listers/clientset/versioned/doc.go deleted file mode 100644 index a5ba96799..000000000 --- a/pkg/client/listers/clientset/versioned/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated clientset. -package versioned diff --git a/pkg/client/listers/clientset/versioned/fake/clientset_generated.go b/pkg/client/listers/clientset/versioned/fake/clientset_generated.go deleted file mode 100644 index 11a17119c..000000000 --- a/pkg/client/listers/clientset/versioned/fake/clientset_generated.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - clientset "github.com/mattermost/mattermost-operator/pkg/client/clientset/versioned" - mattermostv1alpha1 "github.com/mattermost/mattermost-operator/pkg/client/clientset/versioned/typed/mattermost/v1alpha1" - fakemattermostv1alpha1 "github.com/mattermost/mattermost-operator/pkg/client/clientset/versioned/typed/mattermost/v1alpha1/fake" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/client-go/discovery" - fakediscovery "k8s.io/client-go/discovery/fake" - "k8s.io/client-go/testing" -) - -// NewSimpleClientset returns a clientset that will respond with the provided objects. -// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, -// without applying any validations and/or defaults. It shouldn't be considered a replacement -// for a real clientset and is mostly useful in simple unit tests. -func NewSimpleClientset(objects ...runtime.Object) *Clientset { - o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) - for _, obj := range objects { - if err := o.Add(obj); err != nil { - panic(err) - } - } - - cs := &Clientset{tracker: o} - cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} - cs.AddReactor("*", "*", testing.ObjectReaction(o)) - cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { - gvr := action.GetResource() - ns := action.GetNamespace() - watch, err := o.Watch(gvr, ns) - if err != nil { - return false, nil, err - } - return true, watch, nil - }) - - return cs -} - -// Clientset implements clientset.Interface. Meant to be embedded into a -// struct to get a default implementation. This makes faking out just the method -// you want to test easier. -type Clientset struct { - testing.Fake - discovery *fakediscovery.FakeDiscovery - tracker testing.ObjectTracker -} - -func (c *Clientset) Discovery() discovery.DiscoveryInterface { - return c.discovery -} - -func (c *Clientset) Tracker() testing.ObjectTracker { - return c.tracker -} - -var _ clientset.Interface = &Clientset{} - -// MattermostV1alpha1 retrieves the MattermostV1alpha1Client -func (c *Clientset) MattermostV1alpha1() mattermostv1alpha1.MattermostV1alpha1Interface { - return &fakemattermostv1alpha1.FakeMattermostV1alpha1{Fake: &c.Fake} -} diff --git a/pkg/client/listers/clientset/versioned/fake/doc.go b/pkg/client/listers/clientset/versioned/fake/doc.go deleted file mode 100644 index a103f7fd1..000000000 --- a/pkg/client/listers/clientset/versioned/fake/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated fake clientset. -package fake diff --git a/pkg/client/listers/clientset/versioned/fake/register.go b/pkg/client/listers/clientset/versioned/fake/register.go deleted file mode 100644 index 438dc7d07..000000000 --- a/pkg/client/listers/clientset/versioned/fake/register.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - mattermostv1alpha1 "github.com/mattermost/mattermost-operator/pkg/apis/mattermost/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" -) - -var scheme = runtime.NewScheme() -var codecs = serializer.NewCodecFactory(scheme) -var parameterCodec = runtime.NewParameterCodec(scheme) -var localSchemeBuilder = runtime.SchemeBuilder{ - mattermostv1alpha1.AddToScheme, -} - -// AddToScheme adds all types of this clientset into the given scheme. This allows composition -// of clientsets, like in: -// -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) -// -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) -// -// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types -// correctly. -var AddToScheme = localSchemeBuilder.AddToScheme - -func init() { - v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) - utilruntime.Must(AddToScheme(scheme)) -} diff --git a/pkg/client/listers/clientset/versioned/scheme/doc.go b/pkg/client/listers/clientset/versioned/scheme/doc.go deleted file mode 100644 index 34763c113..000000000 --- a/pkg/client/listers/clientset/versioned/scheme/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -// This package contains the scheme of the automatically generated clientset. -package scheme diff --git a/pkg/client/listers/clientset/versioned/scheme/register.go b/pkg/client/listers/clientset/versioned/scheme/register.go deleted file mode 100644 index 9ca7a378b..000000000 --- a/pkg/client/listers/clientset/versioned/scheme/register.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -package scheme - -import ( - mattermostv1alpha1 "github.com/mattermost/mattermost-operator/pkg/apis/mattermost/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" -) - -var Scheme = runtime.NewScheme() -var Codecs = serializer.NewCodecFactory(Scheme) -var ParameterCodec = runtime.NewParameterCodec(Scheme) -var localSchemeBuilder = runtime.SchemeBuilder{ - mattermostv1alpha1.AddToScheme, -} - -// AddToScheme adds all types of this clientset into the given scheme. This allows composition -// of clientsets, like in: -// -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) -// -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) -// -// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types -// correctly. -var AddToScheme = localSchemeBuilder.AddToScheme - -func init() { - v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) - utilruntime.Must(AddToScheme(Scheme)) -} diff --git a/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/clusterinstallation.go b/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/clusterinstallation.go deleted file mode 100644 index c4345d120..000000000 --- a/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/clusterinstallation.go +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "time" - - v1alpha1 "github.com/mattermost/mattermost-operator/pkg/apis/mattermost/v1alpha1" - scheme "github.com/mattermost/mattermost-operator/pkg/client/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// ClusterInstallationsGetter has a method to return a ClusterInstallationInterface. -// A group's client should implement this interface. -type ClusterInstallationsGetter interface { - ClusterInstallations(namespace string) ClusterInstallationInterface -} - -// ClusterInstallationInterface has methods to work with ClusterInstallation resources. -type ClusterInstallationInterface interface { - Create(*v1alpha1.ClusterInstallation) (*v1alpha1.ClusterInstallation, error) - Update(*v1alpha1.ClusterInstallation) (*v1alpha1.ClusterInstallation, error) - UpdateStatus(*v1alpha1.ClusterInstallation) (*v1alpha1.ClusterInstallation, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha1.ClusterInstallation, error) - List(opts v1.ListOptions) (*v1alpha1.ClusterInstallationList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ClusterInstallation, err error) - ClusterInstallationExpansion -} - -// clusterInstallations implements ClusterInstallationInterface -type clusterInstallations struct { - client rest.Interface - ns string -} - -// newClusterInstallations returns a ClusterInstallations -func newClusterInstallations(c *MattermostV1alpha1Client, namespace string) *clusterInstallations { - return &clusterInstallations{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the clusterInstallation, and returns the corresponding clusterInstallation object, and an error if there is any. -func (c *clusterInstallations) Get(name string, options v1.GetOptions) (result *v1alpha1.ClusterInstallation, err error) { - result = &v1alpha1.ClusterInstallation{} - err = c.client.Get(). - Namespace(c.ns). - Resource("clusterinstallations"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ClusterInstallations that match those selectors. -func (c *clusterInstallations) List(opts v1.ListOptions) (result *v1alpha1.ClusterInstallationList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.ClusterInstallationList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("clusterinstallations"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested clusterInstallations. -func (c *clusterInstallations) Watch(opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("clusterinstallations"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch() -} - -// Create takes the representation of a clusterInstallation and creates it. Returns the server's representation of the clusterInstallation, and an error, if there is any. -func (c *clusterInstallations) Create(clusterInstallation *v1alpha1.ClusterInstallation) (result *v1alpha1.ClusterInstallation, err error) { - result = &v1alpha1.ClusterInstallation{} - err = c.client.Post(). - Namespace(c.ns). - Resource("clusterinstallations"). - Body(clusterInstallation). - Do(). - Into(result) - return -} - -// Update takes the representation of a clusterInstallation and updates it. Returns the server's representation of the clusterInstallation, and an error, if there is any. -func (c *clusterInstallations) Update(clusterInstallation *v1alpha1.ClusterInstallation) (result *v1alpha1.ClusterInstallation, err error) { - result = &v1alpha1.ClusterInstallation{} - err = c.client.Put(). - Namespace(c.ns). - Resource("clusterinstallations"). - Name(clusterInstallation.Name). - Body(clusterInstallation). - Do(). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *clusterInstallations) UpdateStatus(clusterInstallation *v1alpha1.ClusterInstallation) (result *v1alpha1.ClusterInstallation, err error) { - result = &v1alpha1.ClusterInstallation{} - err = c.client.Put(). - Namespace(c.ns). - Resource("clusterinstallations"). - Name(clusterInstallation.Name). - SubResource("status"). - Body(clusterInstallation). - Do(). - Into(result) - return -} - -// Delete takes name of the clusterInstallation and deletes it. Returns an error if one occurs. -func (c *clusterInstallations) Delete(name string, options *v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("clusterinstallations"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *clusterInstallations) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("clusterinstallations"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Timeout(timeout). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched clusterInstallation. -func (c *clusterInstallations) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ClusterInstallation, err error) { - result = &v1alpha1.ClusterInstallation{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("clusterinstallations"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/doc.go b/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/doc.go deleted file mode 100644 index 232390cd5..000000000 --- a/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated typed clients. -package v1alpha1 diff --git a/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/fake/doc.go b/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/fake/doc.go deleted file mode 100644 index 04f8da1cf..000000000 --- a/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/fake/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -// Package fake has the automatically generated clients. -package fake diff --git a/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/fake/fake_clusterinstallation.go b/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/fake/fake_clusterinstallation.go deleted file mode 100644 index ceb169bab..000000000 --- a/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/fake/fake_clusterinstallation.go +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - v1alpha1 "github.com/mattermost/mattermost-operator/pkg/apis/mattermost/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeClusterInstallations implements ClusterInstallationInterface -type FakeClusterInstallations struct { - Fake *FakeMattermostV1alpha1 - ns string -} - -var clusterinstallationsResource = schema.GroupVersionResource{Group: "mattermost.com", Version: "v1alpha1", Resource: "clusterinstallations"} - -var clusterinstallationsKind = schema.GroupVersionKind{Group: "mattermost.com", Version: "v1alpha1", Kind: "ClusterInstallation"} - -// Get takes name of the clusterInstallation, and returns the corresponding clusterInstallation object, and an error if there is any. -func (c *FakeClusterInstallations) Get(name string, options v1.GetOptions) (result *v1alpha1.ClusterInstallation, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(clusterinstallationsResource, c.ns, name), &v1alpha1.ClusterInstallation{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ClusterInstallation), err -} - -// List takes label and field selectors, and returns the list of ClusterInstallations that match those selectors. -func (c *FakeClusterInstallations) List(opts v1.ListOptions) (result *v1alpha1.ClusterInstallationList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(clusterinstallationsResource, clusterinstallationsKind, c.ns, opts), &v1alpha1.ClusterInstallationList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha1.ClusterInstallationList{ListMeta: obj.(*v1alpha1.ClusterInstallationList).ListMeta} - for _, item := range obj.(*v1alpha1.ClusterInstallationList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested clusterInstallations. -func (c *FakeClusterInstallations) Watch(opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(clusterinstallationsResource, c.ns, opts)) - -} - -// Create takes the representation of a clusterInstallation and creates it. Returns the server's representation of the clusterInstallation, and an error, if there is any. -func (c *FakeClusterInstallations) Create(clusterInstallation *v1alpha1.ClusterInstallation) (result *v1alpha1.ClusterInstallation, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(clusterinstallationsResource, c.ns, clusterInstallation), &v1alpha1.ClusterInstallation{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ClusterInstallation), err -} - -// Update takes the representation of a clusterInstallation and updates it. Returns the server's representation of the clusterInstallation, and an error, if there is any. -func (c *FakeClusterInstallations) Update(clusterInstallation *v1alpha1.ClusterInstallation) (result *v1alpha1.ClusterInstallation, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(clusterinstallationsResource, c.ns, clusterInstallation), &v1alpha1.ClusterInstallation{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ClusterInstallation), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeClusterInstallations) UpdateStatus(clusterInstallation *v1alpha1.ClusterInstallation) (*v1alpha1.ClusterInstallation, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(clusterinstallationsResource, "status", c.ns, clusterInstallation), &v1alpha1.ClusterInstallation{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ClusterInstallation), err -} - -// Delete takes name of the clusterInstallation and deletes it. Returns an error if one occurs. -func (c *FakeClusterInstallations) Delete(name string, options *v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(clusterinstallationsResource, c.ns, name), &v1alpha1.ClusterInstallation{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeClusterInstallations) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(clusterinstallationsResource, c.ns, listOptions) - - _, err := c.Fake.Invokes(action, &v1alpha1.ClusterInstallationList{}) - return err -} - -// Patch applies the patch and returns the patched clusterInstallation. -func (c *FakeClusterInstallations) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ClusterInstallation, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(clusterinstallationsResource, c.ns, name, pt, data, subresources...), &v1alpha1.ClusterInstallation{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ClusterInstallation), err -} diff --git a/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/fake/fake_mattermost_client.go b/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/fake/fake_mattermost_client.go deleted file mode 100644 index 844fb47e8..000000000 --- a/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/fake/fake_mattermost_client.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - v1alpha1 "github.com/mattermost/mattermost-operator/pkg/client/clientset/versioned/typed/mattermost/v1alpha1" - rest "k8s.io/client-go/rest" - testing "k8s.io/client-go/testing" -) - -type FakeMattermostV1alpha1 struct { - *testing.Fake -} - -func (c *FakeMattermostV1alpha1) ClusterInstallations(namespace string) v1alpha1.ClusterInstallationInterface { - return &FakeClusterInstallations{c, namespace} -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *FakeMattermostV1alpha1) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} diff --git a/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/generated_expansion.go b/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/generated_expansion.go deleted file mode 100644 index b5c1c35dd..000000000 --- a/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/generated_expansion.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -type ClusterInstallationExpansion interface{} diff --git a/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/mattermost_client.go b/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/mattermost_client.go deleted file mode 100644 index b93d4c478..000000000 --- a/pkg/client/listers/clientset/versioned/typed/mattermost/v1alpha1/mattermost_client.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - v1alpha1 "github.com/mattermost/mattermost-operator/pkg/apis/mattermost/v1alpha1" - "github.com/mattermost/mattermost-operator/pkg/client/clientset/versioned/scheme" - rest "k8s.io/client-go/rest" -) - -type MattermostV1alpha1Interface interface { - RESTClient() rest.Interface - ClusterInstallationsGetter -} - -// MattermostV1alpha1Client is used to interact with features provided by the mattermost.com group. -type MattermostV1alpha1Client struct { - restClient rest.Interface -} - -func (c *MattermostV1alpha1Client) ClusterInstallations(namespace string) ClusterInstallationInterface { - return newClusterInstallations(c, namespace) -} - -// NewForConfig creates a new MattermostV1alpha1Client for the given config. -func NewForConfig(c *rest.Config) (*MattermostV1alpha1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &MattermostV1alpha1Client{client}, nil -} - -// NewForConfigOrDie creates a new MattermostV1alpha1Client for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *MattermostV1alpha1Client { - client, err := NewForConfig(c) - if err != nil { - panic(err) - } - return client -} - -// New creates a new MattermostV1alpha1Client for the given RESTClient. -func New(c rest.Interface) *MattermostV1alpha1Client { - return &MattermostV1alpha1Client{c} -} - -func setConfigDefaults(config *rest.Config) error { - gv := v1alpha1.SchemeGroupVersion - config.GroupVersion = &gv - config.APIPath = "/apis" - config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() - - if config.UserAgent == "" { - config.UserAgent = rest.DefaultKubernetesUserAgent() - } - - return nil -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *MattermostV1alpha1Client) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/pkg/client/listers/informers/externalversions/factory.go b/pkg/client/listers/informers/externalversions/factory.go deleted file mode 100644 index 40b2a9236..000000000 --- a/pkg/client/listers/informers/externalversions/factory.go +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by informer-gen. DO NOT EDIT. - -package externalversions - -import ( - reflect "reflect" - sync "sync" - time "time" - - versioned "github.com/mattermost/mattermost-operator/pkg/client/clientset/versioned" - internalinterfaces "github.com/mattermost/mattermost-operator/pkg/client/informers/externalversions/internalinterfaces" - mattermost "github.com/mattermost/mattermost-operator/pkg/client/informers/externalversions/mattermost" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - cache "k8s.io/client-go/tools/cache" -) - -// SharedInformerOption defines the functional option type for SharedInformerFactory. -type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory - -type sharedInformerFactory struct { - client versioned.Interface - namespace string - tweakListOptions internalinterfaces.TweakListOptionsFunc - lock sync.Mutex - defaultResync time.Duration - customResync map[reflect.Type]time.Duration - - informers map[reflect.Type]cache.SharedIndexInformer - // startedInformers is used for tracking which informers have been started. - // This allows Start() to be called multiple times safely. - startedInformers map[reflect.Type]bool -} - -// WithCustomResyncConfig sets a custom resync period for the specified informer types. -func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - for k, v := range resyncConfig { - factory.customResync[reflect.TypeOf(k)] = v - } - return factory - } -} - -// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. -func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - factory.tweakListOptions = tweakListOptions - return factory - } -} - -// WithNamespace limits the SharedInformerFactory to the specified namespace. -func WithNamespace(namespace string) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - factory.namespace = namespace - return factory - } -} - -// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. -func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { - return NewSharedInformerFactoryWithOptions(client, defaultResync) -} - -// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. -// Listers obtained via this SharedInformerFactory will be subject to the same filters -// as specified here. -// Deprecated: Please use NewSharedInformerFactoryWithOptions instead -func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { - return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) -} - -// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. -func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { - factory := &sharedInformerFactory{ - client: client, - namespace: v1.NamespaceAll, - defaultResync: defaultResync, - informers: make(map[reflect.Type]cache.SharedIndexInformer), - startedInformers: make(map[reflect.Type]bool), - customResync: make(map[reflect.Type]time.Duration), - } - - // Apply all options - for _, opt := range options { - factory = opt(factory) - } - - return factory -} - -// Start initializes all requested informers. -func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { - f.lock.Lock() - defer f.lock.Unlock() - - for informerType, informer := range f.informers { - if !f.startedInformers[informerType] { - go informer.Run(stopCh) - f.startedInformers[informerType] = true - } - } -} - -// WaitForCacheSync waits for all started informers' cache were synced. -func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { - informers := func() map[reflect.Type]cache.SharedIndexInformer { - f.lock.Lock() - defer f.lock.Unlock() - - informers := map[reflect.Type]cache.SharedIndexInformer{} - for informerType, informer := range f.informers { - if f.startedInformers[informerType] { - informers[informerType] = informer - } - } - return informers - }() - - res := map[reflect.Type]bool{} - for informType, informer := range informers { - res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) - } - return res -} - -// InternalInformerFor returns the SharedIndexInformer for obj using an internal -// client. -func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { - f.lock.Lock() - defer f.lock.Unlock() - - informerType := reflect.TypeOf(obj) - informer, exists := f.informers[informerType] - if exists { - return informer - } - - resyncPeriod, exists := f.customResync[informerType] - if !exists { - resyncPeriod = f.defaultResync - } - - informer = newFunc(f.client, resyncPeriod) - f.informers[informerType] = informer - - return informer -} - -// SharedInformerFactory provides shared informers for resources in all known -// API group versions. -type SharedInformerFactory interface { - internalinterfaces.SharedInformerFactory - ForResource(resource schema.GroupVersionResource) (GenericInformer, error) - WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool - - Mattermost() mattermost.Interface -} - -func (f *sharedInformerFactory) Mattermost() mattermost.Interface { - return mattermost.New(f, f.namespace, f.tweakListOptions) -} diff --git a/pkg/client/listers/informers/externalversions/generic.go b/pkg/client/listers/informers/externalversions/generic.go deleted file mode 100644 index 9f49b0bae..000000000 --- a/pkg/client/listers/informers/externalversions/generic.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by informer-gen. DO NOT EDIT. - -package externalversions - -import ( - "fmt" - - v1alpha1 "github.com/mattermost/mattermost-operator/pkg/apis/mattermost/v1alpha1" - schema "k8s.io/apimachinery/pkg/runtime/schema" - cache "k8s.io/client-go/tools/cache" -) - -// GenericInformer is type of SharedIndexInformer which will locate and delegate to other -// sharedInformers based on type -type GenericInformer interface { - Informer() cache.SharedIndexInformer - Lister() cache.GenericLister -} - -type genericInformer struct { - informer cache.SharedIndexInformer - resource schema.GroupResource -} - -// Informer returns the SharedIndexInformer. -func (f *genericInformer) Informer() cache.SharedIndexInformer { - return f.informer -} - -// Lister returns the GenericLister. -func (f *genericInformer) Lister() cache.GenericLister { - return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) -} - -// ForResource gives generic access to a shared informer of the matching type -// TODO extend this to unknown resources with a client pool -func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { - switch resource { - // Group=mattermost.com, Version=v1alpha1 - case v1alpha1.SchemeGroupVersion.WithResource("clusterinstallations"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Mattermost().V1alpha1().ClusterInstallations().Informer()}, nil - - } - - return nil, fmt.Errorf("no informer found for %v", resource) -} diff --git a/pkg/client/listers/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/client/listers/informers/externalversions/internalinterfaces/factory_interfaces.go deleted file mode 100644 index 4dd009cab..000000000 --- a/pkg/client/listers/informers/externalversions/internalinterfaces/factory_interfaces.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by informer-gen. DO NOT EDIT. - -package internalinterfaces - -import ( - time "time" - - versioned "github.com/mattermost/mattermost-operator/pkg/client/clientset/versioned" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - cache "k8s.io/client-go/tools/cache" -) - -// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. -type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer - -// SharedInformerFactory a small interface to allow for adding an informer without an import cycle -type SharedInformerFactory interface { - Start(stopCh <-chan struct{}) - InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer -} - -// TweakListOptionsFunc is a function that transforms a v1.ListOptions. -type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/pkg/client/listers/informers/externalversions/mattermost/interface.go b/pkg/client/listers/informers/externalversions/mattermost/interface.go deleted file mode 100644 index c52ed02b3..000000000 --- a/pkg/client/listers/informers/externalversions/mattermost/interface.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by informer-gen. DO NOT EDIT. - -package mattermost - -import ( - internalinterfaces "github.com/mattermost/mattermost-operator/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/mattermost/mattermost-operator/pkg/client/informers/externalversions/mattermost/v1alpha1" -) - -// Interface provides access to each of this group's versions. -type Interface interface { - // V1alpha1 provides access to shared informers for resources in V1alpha1. - V1alpha1() v1alpha1.Interface -} - -type group struct { - factory internalinterfaces.SharedInformerFactory - namespace string - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// New returns a new Interface. -func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { - return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} -} - -// V1alpha1 returns a new v1alpha1.Interface. -func (g *group) V1alpha1() v1alpha1.Interface { - return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) -} diff --git a/pkg/client/listers/informers/externalversions/mattermost/v1alpha1/clusterinstallation.go b/pkg/client/listers/informers/externalversions/mattermost/v1alpha1/clusterinstallation.go deleted file mode 100644 index 1dcc8dda4..000000000 --- a/pkg/client/listers/informers/externalversions/mattermost/v1alpha1/clusterinstallation.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by informer-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - time "time" - - mattermostv1alpha1 "github.com/mattermost/mattermost-operator/pkg/apis/mattermost/v1alpha1" - versioned "github.com/mattermost/mattermost-operator/pkg/client/clientset/versioned" - internalinterfaces "github.com/mattermost/mattermost-operator/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/mattermost/mattermost-operator/pkg/client/listers/mattermost/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - watch "k8s.io/apimachinery/pkg/watch" - cache "k8s.io/client-go/tools/cache" -) - -// ClusterInstallationInformer provides access to a shared informer and lister for -// ClusterInstallations. -type ClusterInstallationInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1alpha1.ClusterInstallationLister -} - -type clusterInstallationInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string -} - -// NewClusterInstallationInformer constructs a new informer for ClusterInstallation type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewClusterInstallationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredClusterInstallationInformer(client, namespace, resyncPeriod, indexers, nil) -} - -// NewFilteredClusterInstallationInformer constructs a new informer for ClusterInstallation type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFilteredClusterInstallationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { - return cache.NewSharedIndexInformer( - &cache.ListWatch{ - ListFunc: func(options v1.ListOptions) (runtime.Object, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.MattermostV1alpha1().ClusterInstallations(namespace).List(options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.MattermostV1alpha1().ClusterInstallations(namespace).Watch(options) - }, - }, - &mattermostv1alpha1.ClusterInstallation{}, - resyncPeriod, - indexers, - ) -} - -func (f *clusterInstallationInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredClusterInstallationInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *clusterInstallationInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&mattermostv1alpha1.ClusterInstallation{}, f.defaultInformer) -} - -func (f *clusterInstallationInformer) Lister() v1alpha1.ClusterInstallationLister { - return v1alpha1.NewClusterInstallationLister(f.Informer().GetIndexer()) -} diff --git a/pkg/client/listers/informers/externalversions/mattermost/v1alpha1/interface.go b/pkg/client/listers/informers/externalversions/mattermost/v1alpha1/interface.go deleted file mode 100644 index 6ebaf0a36..000000000 --- a/pkg/client/listers/informers/externalversions/mattermost/v1alpha1/interface.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by informer-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - internalinterfaces "github.com/mattermost/mattermost-operator/pkg/client/informers/externalversions/internalinterfaces" -) - -// Interface provides access to all the informers in this group version. -type Interface interface { - // ClusterInstallations returns a ClusterInstallationInformer. - ClusterInstallations() ClusterInstallationInformer -} - -type version struct { - factory internalinterfaces.SharedInformerFactory - namespace string - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// New returns a new Interface. -func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { - return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} -} - -// ClusterInstallations returns a ClusterInstallationInformer. -func (v *version) ClusterInstallations() ClusterInstallationInformer { - return &clusterInstallationInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} -} diff --git a/pkg/client/listers/listers/mattermost/v1alpha1/clusterinstallation.go b/pkg/client/listers/listers/mattermost/v1alpha1/clusterinstallation.go deleted file mode 100644 index 175e02d48..000000000 --- a/pkg/client/listers/listers/mattermost/v1alpha1/clusterinstallation.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by lister-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - v1alpha1 "github.com/mattermost/mattermost-operator/pkg/apis/mattermost/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// ClusterInstallationLister helps list ClusterInstallations. -type ClusterInstallationLister interface { - // List lists all ClusterInstallations in the indexer. - List(selector labels.Selector) (ret []*v1alpha1.ClusterInstallation, err error) - // ClusterInstallations returns an object that can list and get ClusterInstallations. - ClusterInstallations(namespace string) ClusterInstallationNamespaceLister - ClusterInstallationListerExpansion -} - -// clusterInstallationLister implements the ClusterInstallationLister interface. -type clusterInstallationLister struct { - indexer cache.Indexer -} - -// NewClusterInstallationLister returns a new ClusterInstallationLister. -func NewClusterInstallationLister(indexer cache.Indexer) ClusterInstallationLister { - return &clusterInstallationLister{indexer: indexer} -} - -// List lists all ClusterInstallations in the indexer. -func (s *clusterInstallationLister) List(selector labels.Selector) (ret []*v1alpha1.ClusterInstallation, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.ClusterInstallation)) - }) - return ret, err -} - -// ClusterInstallations returns an object that can list and get ClusterInstallations. -func (s *clusterInstallationLister) ClusterInstallations(namespace string) ClusterInstallationNamespaceLister { - return clusterInstallationNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// ClusterInstallationNamespaceLister helps list and get ClusterInstallations. -type ClusterInstallationNamespaceLister interface { - // List lists all ClusterInstallations in the indexer for a given namespace. - List(selector labels.Selector) (ret []*v1alpha1.ClusterInstallation, err error) - // Get retrieves the ClusterInstallation from the indexer for a given namespace and name. - Get(name string) (*v1alpha1.ClusterInstallation, error) - ClusterInstallationNamespaceListerExpansion -} - -// clusterInstallationNamespaceLister implements the ClusterInstallationNamespaceLister -// interface. -type clusterInstallationNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all ClusterInstallations in the indexer for a given namespace. -func (s clusterInstallationNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ClusterInstallation, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.ClusterInstallation)) - }) - return ret, err -} - -// Get retrieves the ClusterInstallation from the indexer for a given namespace and name. -func (s clusterInstallationNamespaceLister) Get(name string) (*v1alpha1.ClusterInstallation, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("clusterinstallation"), name) - } - return obj.(*v1alpha1.ClusterInstallation), nil -} diff --git a/pkg/client/listers/listers/mattermost/v1alpha1/expansion_generated.go b/pkg/client/listers/listers/mattermost/v1alpha1/expansion_generated.go deleted file mode 100644 index 0e8459641..000000000 --- a/pkg/client/listers/listers/mattermost/v1alpha1/expansion_generated.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -// Code generated by lister-gen. DO NOT EDIT. - -package v1alpha1 - -// ClusterInstallationListerExpansion allows custom methods to be added to -// ClusterInstallationLister. -type ClusterInstallationListerExpansion interface{} - -// ClusterInstallationNamespaceListerExpansion allows custom methods to be added to -// ClusterInstallationNamespaceLister. -type ClusterInstallationNamespaceListerExpansion interface{} diff --git a/vendor/golang.org/x/tools/internal/event/core/event.go b/vendor/golang.org/x/tools/internal/event/core/event.go new file mode 100644 index 000000000..29f293e62 --- /dev/null +++ b/vendor/golang.org/x/tools/internal/event/core/event.go @@ -0,0 +1,106 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package core provides support for event based telemetry. +package core + +import ( + "fmt" + "time" + + "golang.org/x/tools/internal/event/label" +) + +type eventType uint8 + +const ( + invalidType = eventType(iota) + LogType // an event that should be recorded in a log + StartSpanType // the start of a span of time + EndSpanType // the end of a span of time + LabelType // some values that should be noted for later events + DetachType // an event that causes a context to detach + RecordType // a value that should be tracked +) + +// Event holds the information about an event of note that ocurred. +type Event struct { + at time.Time + + typ eventType + + // As events are often on the stack, storing the first few labels directly + // in the event can avoid an allocation at all for the very common cases of + // simple events. + // The length needs to be large enough to cope with the majority of events + // but no so large as to cause undue stack pressure. + // A log message with two values will use 3 labels (one for each value and + // one for the message itself). + + static [3]label.Label // inline storage for the first few labels + dynamic []label.Label // dynamically sized storage for remaining labels +} + +// eventLabelMap implements label.Map for a the labels of an Event. +type eventLabelMap struct { + event Event +} + +func (ev Event) At() time.Time { return ev.at } + +func (ev Event) IsLog() bool { return ev.typ == LogType } +func (ev Event) IsEndSpan() bool { return ev.typ == EndSpanType } +func (ev Event) IsStartSpan() bool { return ev.typ == StartSpanType } +func (ev Event) IsLabel() bool { return ev.typ == LabelType } +func (ev Event) IsDetach() bool { return ev.typ == DetachType } +func (ev Event) IsRecord() bool { return ev.typ == RecordType } + +func (ev Event) Format(f fmt.State, r rune) { + if !ev.at.IsZero() { + fmt.Fprint(f, ev.at.Format("2006/01/02 15:04:05 ")) + } + for index := 0; ev.Valid(index); index++ { + l := ev.Label(index) + fmt.Fprintf(f, "\n\t%v", l) + } +} + +func (ev Event) Valid(index int) bool { + return index >= 0 && index < len(ev.static)+len(ev.dynamic) +} + +func (ev Event) Label(index int) label.Label { + if index < len(ev.static) { + return ev.static[index] + } + return ev.dynamic[index-len(ev.static)] +} + +func (ev Event) Find(key label.Key) label.Label { + for _, l := range ev.static { + if l.Key() == key { + return l + } + } + for _, l := range ev.dynamic { + if l.Key() == key { + return l + } + } + return label.Label{} +} + +func MakeEvent(typ eventType, static [3]label.Label, labels []label.Label) Event { + return Event{ + typ: typ, + static: static, + dynamic: labels, + } +} + +// CloneEvent event returns a copy of the event with the time adjusted to at. +func CloneEvent(ev Event, at time.Time) Event { + ev.at = at + return ev +} diff --git a/vendor/golang.org/x/tools/internal/telemetry/event/export.go b/vendor/golang.org/x/tools/internal/event/core/export.go similarity index 76% rename from vendor/golang.org/x/tools/internal/telemetry/event/export.go rename to vendor/golang.org/x/tools/internal/event/core/export.go index a2633b602..05f3a9a57 100644 --- a/vendor/golang.org/x/tools/internal/telemetry/event/export.go +++ b/vendor/golang.org/x/tools/internal/event/core/export.go @@ -2,18 +2,20 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package event +package core import ( "context" "sync/atomic" "time" "unsafe" + + "golang.org/x/tools/internal/event/label" ) // Exporter is a function that handles events. // It may return a modified context and event. -type Exporter func(context.Context, Event, TagMap) context.Context +type Exporter func(context.Context, Event, label.Map) context.Context var ( exporter unsafe.Pointer @@ -35,16 +37,16 @@ func SetExporter(e Exporter) { } // deliver is called to deliver an event to the supplied exporter. -// it will fill in the time and generate the basic tag source. +// it will fill in the time. func deliver(ctx context.Context, exporter Exporter, ev Event) context.Context { // add the current time to the event - ev.At = time.Now() + ev.at = time.Now() // hand the event off to the current exporter return exporter(ctx, ev, ev) } -// dispatch is called to deliver an event to the global exporter if set. -func dispatch(ctx context.Context, ev Event) context.Context { +// Export is called to deliver an event to the global exporter if set. +func Export(ctx context.Context, ev Event) context.Context { // get the global exporter and abort early if there is not one exporterPtr := (*Exporter)(atomic.LoadPointer(&exporter)) if exporterPtr == nil { @@ -53,11 +55,11 @@ func dispatch(ctx context.Context, ev Event) context.Context { return deliver(ctx, *exporterPtr, ev) } -// dispatchPair is called to deliver a start event to the supplied exporter. +// ExportPair is called to deliver a start event to the supplied exporter. // It also returns a function that will deliver the end event to the same // exporter. -// it will fill in the time and generate the basic tag source. -func dispatchPair(ctx context.Context, begin, end Event) (context.Context, func()) { +// It will fill in the time. +func ExportPair(ctx context.Context, begin, end Event) (context.Context, func()) { // get the global exporter and abort early if there is not one exporterPtr := (*Exporter)(atomic.LoadPointer(&exporter)) if exporterPtr == nil { diff --git a/vendor/golang.org/x/tools/internal/event/core/fast.go b/vendor/golang.org/x/tools/internal/event/core/fast.go new file mode 100644 index 000000000..e61f2cf79 --- /dev/null +++ b/vendor/golang.org/x/tools/internal/event/core/fast.go @@ -0,0 +1,57 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package core + +import ( + "context" + + "golang.org/x/tools/internal/event/keys" + "golang.org/x/tools/internal/event/label" +) + +// Log1 takes a message and one label delivers a log event to the exporter. +// It is a customized version of Print that is faster and does no allocation. +func Log1(ctx context.Context, message string, t1 label.Label) { + Export(ctx, MakeEvent(LogType, [3]label.Label{keys.Msg.Of(message), t1}, nil)) +} + +// Log2 takes a message and two labels and delivers a log event to the exporter. +// It is a customized version of Print that is faster and does no allocation. +func Log2(ctx context.Context, message string, t1 label.Label, t2 label.Label) { + Export(ctx, MakeEvent(LogType, [3]label.Label{keys.Msg.Of(message), t1, t2}, nil)) +} + +// Metric1 sends a label event to the exporter with the supplied labels. +func Metric1(ctx context.Context, t1 label.Label) context.Context { + return Export(ctx, MakeEvent(RecordType, [3]label.Label{t1}, nil)) +} + +// Metric2 sends a label event to the exporter with the supplied labels. +func Metric2(ctx context.Context, t1, t2 label.Label) context.Context { + return Export(ctx, MakeEvent(RecordType, [3]label.Label{t1, t2}, nil)) +} + +// Metric3 sends a label event to the exporter with the supplied labels. +func Metric3(ctx context.Context, t1, t2, t3 label.Label) context.Context { + return Export(ctx, MakeEvent(RecordType, [3]label.Label{t1, t2, t3}, nil)) +} + +// Start1 sends a span start event with the supplied label list to the exporter. +// It also returns a function that will end the span, which should normally be +// deferred. +func Start1(ctx context.Context, name string, t1 label.Label) (context.Context, func()) { + return ExportPair(ctx, + MakeEvent(StartSpanType, [3]label.Label{keys.Name.Of(name), t1}, nil), + MakeEvent(EndSpanType, [3]label.Label{}, nil)) +} + +// Start2 sends a span start event with the supplied label list to the exporter. +// It also returns a function that will end the span, which should normally be +// deferred. +func Start2(ctx context.Context, name string, t1, t2 label.Label) (context.Context, func()) { + return ExportPair(ctx, + MakeEvent(StartSpanType, [3]label.Label{keys.Name.Of(name), t1, t2}, nil), + MakeEvent(EndSpanType, [3]label.Label{}, nil)) +} diff --git a/vendor/golang.org/x/tools/internal/event/doc.go b/vendor/golang.org/x/tools/internal/event/doc.go new file mode 100644 index 000000000..5dc6e6bab --- /dev/null +++ b/vendor/golang.org/x/tools/internal/event/doc.go @@ -0,0 +1,7 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package event provides a set of packages that cover the main +// concepts of telemetry in an implementation agnostic way. +package event diff --git a/vendor/golang.org/x/tools/internal/event/event.go b/vendor/golang.org/x/tools/internal/event/event.go new file mode 100644 index 000000000..730313b8b --- /dev/null +++ b/vendor/golang.org/x/tools/internal/event/event.go @@ -0,0 +1,69 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package event + +import ( + "context" + + "golang.org/x/tools/internal/event/core" + "golang.org/x/tools/internal/event/keys" + "golang.org/x/tools/internal/event/label" +) + +// Exporter is a function that handles events. +// It may return a modified context and event. +type Exporter func(context.Context, core.Event, label.Map) context.Context + +// SetExporter sets the global exporter function that handles all events. +// The exporter is called synchronously from the event call site, so it should +// return quickly so as not to hold up user code. +func SetExporter(e Exporter) { + core.SetExporter(core.Exporter(e)) +} + +// Log takes a message and a label list and combines them into a single event +// before delivering them to the exporter. +func Log(ctx context.Context, message string, labels ...label.Label) { + core.Export(ctx, core.MakeEvent(core.LogType, [3]label.Label{ + keys.Msg.Of(message), + }, labels)) +} + +// Error takes a message and a label list and combines them into a single event +// before delivering them to the exporter. It captures the error in the +// delivered event. +func Error(ctx context.Context, message string, err error, labels ...label.Label) { + core.Export(ctx, core.MakeEvent(core.LogType, [3]label.Label{ + keys.Msg.Of(message), + keys.Err.Of(err), + }, labels)) +} + +// Metric sends a label event to the exporter with the supplied labels. +func Metric(ctx context.Context, labels ...label.Label) { + core.Export(ctx, core.MakeEvent(core.RecordType, [3]label.Label{}, labels)) +} + +// Label sends a label event to the exporter with the supplied labels. +func Label(ctx context.Context, labels ...label.Label) context.Context { + return core.Export(ctx, core.MakeEvent(core.LabelType, [3]label.Label{}, labels)) +} + +// Start sends a span start event with the supplied label list to the exporter. +// It also returns a function that will end the span, which should normally be +// deferred. +func Start(ctx context.Context, name string, labels ...label.Label) (context.Context, func()) { + return core.ExportPair(ctx, + core.MakeEvent(core.StartSpanType, [3]label.Label{ + keys.Name.Of(name), + }, labels), + core.MakeEvent(core.EndSpanType, [3]label.Label{}, nil)) +} + +// Detach returns a context without an associated span. +// This allows the creation of spans that are not children of the current span. +func Detach(ctx context.Context) context.Context { + return core.Export(ctx, core.MakeEvent(core.DetachType, [3]label.Label{}, nil)) +} diff --git a/vendor/golang.org/x/tools/internal/event/keys/keys.go b/vendor/golang.org/x/tools/internal/event/keys/keys.go new file mode 100644 index 000000000..5814f71a0 --- /dev/null +++ b/vendor/golang.org/x/tools/internal/event/keys/keys.go @@ -0,0 +1,542 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package keys + +import ( + "fmt" + "io" + "math" + "strconv" + + "golang.org/x/tools/internal/event/label" +) + +// Value represents a key for untyped values. +type Value struct { + name string + description string +} + +// New creates a new Key for untyped values. +func New(name, description string) *Value { + return &Value{name: name, description: description} +} + +func (k *Value) Name() string { return k.name } +func (k *Value) Description() string { return k.description } + +func (k *Value) Format(w io.Writer, buf []byte, l label.Label) { + fmt.Fprint(w, k.From(l)) +} + +// Get can be used to get a label for the key from a label.Map. +func (k *Value) Get(lm label.Map) interface{} { + if t := lm.Find(k); t.Valid() { + return k.From(t) + } + return nil +} + +// From can be used to get a value from a Label. +func (k *Value) From(t label.Label) interface{} { return t.UnpackValue() } + +// Of creates a new Label with this key and the supplied value. +func (k *Value) Of(value interface{}) label.Label { return label.OfValue(k, value) } + +// Int represents a key +type Int struct { + name string + description string +} + +// NewInt creates a new Key for int values. +func NewInt(name, description string) *Int { + return &Int{name: name, description: description} +} + +func (k *Int) Name() string { return k.name } +func (k *Int) Description() string { return k.description } + +func (k *Int) Format(w io.Writer, buf []byte, l label.Label) { + w.Write(strconv.AppendInt(buf, int64(k.From(l)), 10)) +} + +// Of creates a new Label with this key and the supplied value. +func (k *Int) Of(v int) label.Label { return label.Of64(k, uint64(v)) } + +// Get can be used to get a label for the key from a label.Map. +func (k *Int) Get(lm label.Map) int { + if t := lm.Find(k); t.Valid() { + return k.From(t) + } + return 0 +} + +// From can be used to get a value from a Label. +func (k *Int) From(t label.Label) int { return int(t.Unpack64()) } + +// Int8 represents a key +type Int8 struct { + name string + description string +} + +// NewInt8 creates a new Key for int8 values. +func NewInt8(name, description string) *Int8 { + return &Int8{name: name, description: description} +} + +func (k *Int8) Name() string { return k.name } +func (k *Int8) Description() string { return k.description } + +func (k *Int8) Format(w io.Writer, buf []byte, l label.Label) { + w.Write(strconv.AppendInt(buf, int64(k.From(l)), 10)) +} + +// Of creates a new Label with this key and the supplied value. +func (k *Int8) Of(v int8) label.Label { return label.Of64(k, uint64(v)) } + +// Get can be used to get a label for the key from a label.Map. +func (k *Int8) Get(lm label.Map) int8 { + if t := lm.Find(k); t.Valid() { + return k.From(t) + } + return 0 +} + +// From can be used to get a value from a Label. +func (k *Int8) From(t label.Label) int8 { return int8(t.Unpack64()) } + +// Int16 represents a key +type Int16 struct { + name string + description string +} + +// NewInt16 creates a new Key for int16 values. +func NewInt16(name, description string) *Int16 { + return &Int16{name: name, description: description} +} + +func (k *Int16) Name() string { return k.name } +func (k *Int16) Description() string { return k.description } + +func (k *Int16) Format(w io.Writer, buf []byte, l label.Label) { + w.Write(strconv.AppendInt(buf, int64(k.From(l)), 10)) +} + +// Of creates a new Label with this key and the supplied value. +func (k *Int16) Of(v int16) label.Label { return label.Of64(k, uint64(v)) } + +// Get can be used to get a label for the key from a label.Map. +func (k *Int16) Get(lm label.Map) int16 { + if t := lm.Find(k); t.Valid() { + return k.From(t) + } + return 0 +} + +// From can be used to get a value from a Label. +func (k *Int16) From(t label.Label) int16 { return int16(t.Unpack64()) } + +// Int32 represents a key +type Int32 struct { + name string + description string +} + +// NewInt32 creates a new Key for int32 values. +func NewInt32(name, description string) *Int32 { + return &Int32{name: name, description: description} +} + +func (k *Int32) Name() string { return k.name } +func (k *Int32) Description() string { return k.description } + +func (k *Int32) Format(w io.Writer, buf []byte, l label.Label) { + w.Write(strconv.AppendInt(buf, int64(k.From(l)), 10)) +} + +// Of creates a new Label with this key and the supplied value. +func (k *Int32) Of(v int32) label.Label { return label.Of64(k, uint64(v)) } + +// Get can be used to get a label for the key from a label.Map. +func (k *Int32) Get(lm label.Map) int32 { + if t := lm.Find(k); t.Valid() { + return k.From(t) + } + return 0 +} + +// From can be used to get a value from a Label. +func (k *Int32) From(t label.Label) int32 { return int32(t.Unpack64()) } + +// Int64 represents a key +type Int64 struct { + name string + description string +} + +// NewInt64 creates a new Key for int64 values. +func NewInt64(name, description string) *Int64 { + return &Int64{name: name, description: description} +} + +func (k *Int64) Name() string { return k.name } +func (k *Int64) Description() string { return k.description } + +func (k *Int64) Format(w io.Writer, buf []byte, l label.Label) { + w.Write(strconv.AppendInt(buf, k.From(l), 10)) +} + +// Of creates a new Label with this key and the supplied value. +func (k *Int64) Of(v int64) label.Label { return label.Of64(k, uint64(v)) } + +// Get can be used to get a label for the key from a label.Map. +func (k *Int64) Get(lm label.Map) int64 { + if t := lm.Find(k); t.Valid() { + return k.From(t) + } + return 0 +} + +// From can be used to get a value from a Label. +func (k *Int64) From(t label.Label) int64 { return int64(t.Unpack64()) } + +// UInt represents a key +type UInt struct { + name string + description string +} + +// NewUInt creates a new Key for uint values. +func NewUInt(name, description string) *UInt { + return &UInt{name: name, description: description} +} + +func (k *UInt) Name() string { return k.name } +func (k *UInt) Description() string { return k.description } + +func (k *UInt) Format(w io.Writer, buf []byte, l label.Label) { + w.Write(strconv.AppendUint(buf, uint64(k.From(l)), 10)) +} + +// Of creates a new Label with this key and the supplied value. +func (k *UInt) Of(v uint) label.Label { return label.Of64(k, uint64(v)) } + +// Get can be used to get a label for the key from a label.Map. +func (k *UInt) Get(lm label.Map) uint { + if t := lm.Find(k); t.Valid() { + return k.From(t) + } + return 0 +} + +// From can be used to get a value from a Label. +func (k *UInt) From(t label.Label) uint { return uint(t.Unpack64()) } + +// UInt8 represents a key +type UInt8 struct { + name string + description string +} + +// NewUInt8 creates a new Key for uint8 values. +func NewUInt8(name, description string) *UInt8 { + return &UInt8{name: name, description: description} +} + +func (k *UInt8) Name() string { return k.name } +func (k *UInt8) Description() string { return k.description } + +func (k *UInt8) Format(w io.Writer, buf []byte, l label.Label) { + w.Write(strconv.AppendUint(buf, uint64(k.From(l)), 10)) +} + +// Of creates a new Label with this key and the supplied value. +func (k *UInt8) Of(v uint8) label.Label { return label.Of64(k, uint64(v)) } + +// Get can be used to get a label for the key from a label.Map. +func (k *UInt8) Get(lm label.Map) uint8 { + if t := lm.Find(k); t.Valid() { + return k.From(t) + } + return 0 +} + +// From can be used to get a value from a Label. +func (k *UInt8) From(t label.Label) uint8 { return uint8(t.Unpack64()) } + +// UInt16 represents a key +type UInt16 struct { + name string + description string +} + +// NewUInt16 creates a new Key for uint16 values. +func NewUInt16(name, description string) *UInt16 { + return &UInt16{name: name, description: description} +} + +func (k *UInt16) Name() string { return k.name } +func (k *UInt16) Description() string { return k.description } + +func (k *UInt16) Format(w io.Writer, buf []byte, l label.Label) { + w.Write(strconv.AppendUint(buf, uint64(k.From(l)), 10)) +} + +// Of creates a new Label with this key and the supplied value. +func (k *UInt16) Of(v uint16) label.Label { return label.Of64(k, uint64(v)) } + +// Get can be used to get a label for the key from a label.Map. +func (k *UInt16) Get(lm label.Map) uint16 { + if t := lm.Find(k); t.Valid() { + return k.From(t) + } + return 0 +} + +// From can be used to get a value from a Label. +func (k *UInt16) From(t label.Label) uint16 { return uint16(t.Unpack64()) } + +// UInt32 represents a key +type UInt32 struct { + name string + description string +} + +// NewUInt32 creates a new Key for uint32 values. +func NewUInt32(name, description string) *UInt32 { + return &UInt32{name: name, description: description} +} + +func (k *UInt32) Name() string { return k.name } +func (k *UInt32) Description() string { return k.description } + +func (k *UInt32) Format(w io.Writer, buf []byte, l label.Label) { + w.Write(strconv.AppendUint(buf, uint64(k.From(l)), 10)) +} + +// Of creates a new Label with this key and the supplied value. +func (k *UInt32) Of(v uint32) label.Label { return label.Of64(k, uint64(v)) } + +// Get can be used to get a label for the key from a label.Map. +func (k *UInt32) Get(lm label.Map) uint32 { + if t := lm.Find(k); t.Valid() { + return k.From(t) + } + return 0 +} + +// From can be used to get a value from a Label. +func (k *UInt32) From(t label.Label) uint32 { return uint32(t.Unpack64()) } + +// UInt64 represents a key +type UInt64 struct { + name string + description string +} + +// NewUInt64 creates a new Key for uint64 values. +func NewUInt64(name, description string) *UInt64 { + return &UInt64{name: name, description: description} +} + +func (k *UInt64) Name() string { return k.name } +func (k *UInt64) Description() string { return k.description } + +func (k *UInt64) Format(w io.Writer, buf []byte, l label.Label) { + w.Write(strconv.AppendUint(buf, k.From(l), 10)) +} + +// Of creates a new Label with this key and the supplied value. +func (k *UInt64) Of(v uint64) label.Label { return label.Of64(k, v) } + +// Get can be used to get a label for the key from a label.Map. +func (k *UInt64) Get(lm label.Map) uint64 { + if t := lm.Find(k); t.Valid() { + return k.From(t) + } + return 0 +} + +// From can be used to get a value from a Label. +func (k *UInt64) From(t label.Label) uint64 { return t.Unpack64() } + +// Float32 represents a key +type Float32 struct { + name string + description string +} + +// NewFloat32 creates a new Key for float32 values. +func NewFloat32(name, description string) *Float32 { + return &Float32{name: name, description: description} +} + +func (k *Float32) Name() string { return k.name } +func (k *Float32) Description() string { return k.description } + +func (k *Float32) Format(w io.Writer, buf []byte, l label.Label) { + w.Write(strconv.AppendFloat(buf, float64(k.From(l)), 'E', -1, 32)) +} + +// Of creates a new Label with this key and the supplied value. +func (k *Float32) Of(v float32) label.Label { + return label.Of64(k, uint64(math.Float32bits(v))) +} + +// Get can be used to get a label for the key from a label.Map. +func (k *Float32) Get(lm label.Map) float32 { + if t := lm.Find(k); t.Valid() { + return k.From(t) + } + return 0 +} + +// From can be used to get a value from a Label. +func (k *Float32) From(t label.Label) float32 { + return math.Float32frombits(uint32(t.Unpack64())) +} + +// Float64 represents a key +type Float64 struct { + name string + description string +} + +// NewFloat64 creates a new Key for int64 values. +func NewFloat64(name, description string) *Float64 { + return &Float64{name: name, description: description} +} + +func (k *Float64) Name() string { return k.name } +func (k *Float64) Description() string { return k.description } + +func (k *Float64) Format(w io.Writer, buf []byte, l label.Label) { + w.Write(strconv.AppendFloat(buf, k.From(l), 'E', -1, 64)) +} + +// Of creates a new Label with this key and the supplied value. +func (k *Float64) Of(v float64) label.Label { + return label.Of64(k, math.Float64bits(v)) +} + +// Get can be used to get a label for the key from a label.Map. +func (k *Float64) Get(lm label.Map) float64 { + if t := lm.Find(k); t.Valid() { + return k.From(t) + } + return 0 +} + +// From can be used to get a value from a Label. +func (k *Float64) From(t label.Label) float64 { + return math.Float64frombits(t.Unpack64()) +} + +// String represents a key +type String struct { + name string + description string +} + +// NewString creates a new Key for int64 values. +func NewString(name, description string) *String { + return &String{name: name, description: description} +} + +func (k *String) Name() string { return k.name } +func (k *String) Description() string { return k.description } + +func (k *String) Format(w io.Writer, buf []byte, l label.Label) { + w.Write(strconv.AppendQuote(buf, k.From(l))) +} + +// Of creates a new Label with this key and the supplied value. +func (k *String) Of(v string) label.Label { return label.OfString(k, v) } + +// Get can be used to get a label for the key from a label.Map. +func (k *String) Get(lm label.Map) string { + if t := lm.Find(k); t.Valid() { + return k.From(t) + } + return "" +} + +// From can be used to get a value from a Label. +func (k *String) From(t label.Label) string { return t.UnpackString() } + +// Boolean represents a key +type Boolean struct { + name string + description string +} + +// NewBoolean creates a new Key for bool values. +func NewBoolean(name, description string) *Boolean { + return &Boolean{name: name, description: description} +} + +func (k *Boolean) Name() string { return k.name } +func (k *Boolean) Description() string { return k.description } + +func (k *Boolean) Format(w io.Writer, buf []byte, l label.Label) { + w.Write(strconv.AppendBool(buf, k.From(l))) +} + +// Of creates a new Label with this key and the supplied value. +func (k *Boolean) Of(v bool) label.Label { + if v { + return label.Of64(k, 1) + } + return label.Of64(k, 0) +} + +// Get can be used to get a label for the key from a label.Map. +func (k *Boolean) Get(lm label.Map) bool { + if t := lm.Find(k); t.Valid() { + return k.From(t) + } + return false +} + +// From can be used to get a value from a Label. +func (k *Boolean) From(t label.Label) bool { return t.Unpack64() > 0 } + +// Error represents a key +type Error struct { + name string + description string +} + +// NewError creates a new Key for int64 values. +func NewError(name, description string) *Error { + return &Error{name: name, description: description} +} + +func (k *Error) Name() string { return k.name } +func (k *Error) Description() string { return k.description } + +func (k *Error) Format(w io.Writer, buf []byte, l label.Label) { + io.WriteString(w, k.From(l).Error()) +} + +// Of creates a new Label with this key and the supplied value. +func (k *Error) Of(v error) label.Label { return label.OfValue(k, v) } + +// Get can be used to get a label for the key from a label.Map. +func (k *Error) Get(lm label.Map) error { + if t := lm.Find(k); t.Valid() { + return k.From(t) + } + return nil +} + +// From can be used to get a value from a Label. +func (k *Error) From(t label.Label) error { + err, _ := t.UnpackValue().(error) + return err +} diff --git a/vendor/golang.org/x/tools/internal/event/keys/standard.go b/vendor/golang.org/x/tools/internal/event/keys/standard.go new file mode 100644 index 000000000..59516c256 --- /dev/null +++ b/vendor/golang.org/x/tools/internal/event/keys/standard.go @@ -0,0 +1,14 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package keys + +var ( + // Msg is a key used to add message strings to label lists. + Msg = NewString("message", "a readable message") + // Name is used for things like traces that have a name. + Name = NewString("name", "an entity name") + // Err is a key used to add error values to label lists. + Err = NewError("error", "an error that occurred") +) diff --git a/vendor/golang.org/x/tools/internal/event/label/label.go b/vendor/golang.org/x/tools/internal/event/label/label.go new file mode 100644 index 000000000..b55c12eb2 --- /dev/null +++ b/vendor/golang.org/x/tools/internal/event/label/label.go @@ -0,0 +1,213 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package label + +import ( + "fmt" + "io" + "reflect" + "unsafe" +) + +// Key is used as the identity of a Label. +// Keys are intended to be compared by pointer only, the name should be unique +// for communicating with external systems, but it is not required or enforced. +type Key interface { + // Name returns the key name. + Name() string + // Description returns a string that can be used to describe the value. + Description() string + + // Format is used in formatting to append the value of the label to the + // supplied buffer. + // The formatter may use the supplied buf as a scratch area to avoid + // allocations. + Format(w io.Writer, buf []byte, l Label) +} + +// Label holds a key and value pair. +// It is normally used when passing around lists of labels. +type Label struct { + key Key + packed uint64 + untyped interface{} +} + +// Map is the interface to a collection of Labels indexed by key. +type Map interface { + // Find returns the label that matches the supplied key. + Find(key Key) Label +} + +// List is the interface to something that provides an iterable +// list of labels. +// Iteration should start from 0 and continue until Valid returns false. +type List interface { + // Valid returns true if the index is within range for the list. + // It does not imply the label at that index will itself be valid. + Valid(index int) bool + // Label returns the label at the given index. + Label(index int) Label +} + +// list implements LabelList for a list of Labels. +type list struct { + labels []Label +} + +// filter wraps a LabelList filtering out specific labels. +type filter struct { + keys []Key + underlying List +} + +// listMap implements LabelMap for a simple list of labels. +type listMap struct { + labels []Label +} + +// mapChain implements LabelMap for a list of underlying LabelMap. +type mapChain struct { + maps []Map +} + +// OfValue creates a new label from the key and value. +// This method is for implementing new key types, label creation should +// normally be done with the Of method of the key. +func OfValue(k Key, value interface{}) Label { return Label{key: k, untyped: value} } + +// UnpackValue assumes the label was built using LabelOfValue and returns the value +// that was passed to that constructor. +// This method is for implementing new key types, for type safety normal +// access should be done with the From method of the key. +func (t Label) UnpackValue() interface{} { return t.untyped } + +// Of64 creates a new label from a key and a uint64. This is often +// used for non uint64 values that can be packed into a uint64. +// This method is for implementing new key types, label creation should +// normally be done with the Of method of the key. +func Of64(k Key, v uint64) Label { return Label{key: k, packed: v} } + +// Unpack64 assumes the label was built using LabelOf64 and returns the value that +// was passed to that constructor. +// This method is for implementing new key types, for type safety normal +// access should be done with the From method of the key. +func (t Label) Unpack64() uint64 { return t.packed } + +// OfString creates a new label from a key and a string. +// This method is for implementing new key types, label creation should +// normally be done with the Of method of the key. +func OfString(k Key, v string) Label { + hdr := (*reflect.StringHeader)(unsafe.Pointer(&v)) + return Label{ + key: k, + packed: uint64(hdr.Len), + untyped: unsafe.Pointer(hdr.Data), + } +} + +// UnpackString assumes the label was built using LabelOfString and returns the +// value that was passed to that constructor. +// This method is for implementing new key types, for type safety normal +// access should be done with the From method of the key. +func (t Label) UnpackString() string { + var v string + hdr := (*reflect.StringHeader)(unsafe.Pointer(&v)) + hdr.Data = uintptr(t.untyped.(unsafe.Pointer)) + hdr.Len = int(t.packed) + return *(*string)(unsafe.Pointer(hdr)) +} + +// Valid returns true if the Label is a valid one (it has a key). +func (t Label) Valid() bool { return t.key != nil } + +// Key returns the key of this Label. +func (t Label) Key() Key { return t.key } + +// Format is used for debug printing of labels. +func (t Label) Format(f fmt.State, r rune) { + if !t.Valid() { + io.WriteString(f, `nil`) + return + } + io.WriteString(f, t.Key().Name()) + io.WriteString(f, "=") + var buf [128]byte + t.Key().Format(f, buf[:0], t) +} + +func (l *list) Valid(index int) bool { + return index >= 0 && index < len(l.labels) +} + +func (l *list) Label(index int) Label { + return l.labels[index] +} + +func (f *filter) Valid(index int) bool { + return f.underlying.Valid(index) +} + +func (f *filter) Label(index int) Label { + l := f.underlying.Label(index) + for _, f := range f.keys { + if l.Key() == f { + return Label{} + } + } + return l +} + +func (lm listMap) Find(key Key) Label { + for _, l := range lm.labels { + if l.Key() == key { + return l + } + } + return Label{} +} + +func (c mapChain) Find(key Key) Label { + for _, src := range c.maps { + l := src.Find(key) + if l.Valid() { + return l + } + } + return Label{} +} + +var emptyList = &list{} + +func NewList(labels ...Label) List { + if len(labels) == 0 { + return emptyList + } + return &list{labels: labels} +} + +func Filter(l List, keys ...Key) List { + if len(keys) == 0 { + return l + } + return &filter{keys: keys, underlying: l} +} + +func NewMap(labels ...Label) Map { + return listMap{labels: labels} +} + +func MergeMaps(srcs ...Map) Map { + var nonNil []Map + for _, src := range srcs { + if src != nil { + nonNil = append(nonNil, src) + } + } + if len(nonNil) == 1 { + return nonNil[0] + } + return mapChain{maps: nonNil} +} diff --git a/vendor/golang.org/x/tools/internal/gocommand/invoke.go b/vendor/golang.org/x/tools/internal/gocommand/invoke.go index 5b1341270..9aa798456 100644 --- a/vendor/golang.org/x/tools/internal/gocommand/invoke.go +++ b/vendor/golang.org/x/tools/internal/gocommand/invoke.go @@ -17,7 +17,7 @@ import ( "sync" "time" - "golang.org/x/tools/internal/telemetry/event" + "golang.org/x/tools/internal/event" ) // An Runner will run go command invocations and serialize @@ -39,7 +39,7 @@ func (runner *Runner) Run(ctx context.Context, inv Invocation) (*bytes.Buffer, e return stdout, friendly } -// Run calls Innvocation.RunRaw, serializing requests if they fight over +// RunRaw calls Invocation.runRaw, serializing requests if they fight over // go.mod changes. func (runner *Runner) RunRaw(ctx context.Context, inv Invocation) (*bytes.Buffer, *bytes.Buffer, error, error) { // We want to run invocations concurrently as much as possible. However, @@ -93,6 +93,7 @@ func (i *Invocation) runRaw(ctx context.Context) (stdout *bytes.Buffer, stderr * stderr = &bytes.Buffer{} rawError = i.RunPiped(ctx, stdout, stderr) if rawError != nil { + friendlyError = rawError // Check for 'go' executable not being found. if ee, ok := rawError.(*exec.Error); ok && ee.Err == exec.ErrNotFound { friendlyError = fmt.Errorf("go command required, not found: %v", ee) @@ -100,7 +101,7 @@ func (i *Invocation) runRaw(ctx context.Context) (stdout *bytes.Buffer, stderr * if ctx.Err() != nil { friendlyError = ctx.Err() } - friendlyError = fmt.Errorf("err: %v: stderr: %s", rawError, stderr) + friendlyError = fmt.Errorf("err: %v: stderr: %s", friendlyError, stderr) } return } diff --git a/vendor/golang.org/x/tools/internal/imports/zstdlib.go b/vendor/golang.org/x/tools/internal/imports/zstdlib.go index 7e60eb04e..16252111f 100644 --- a/vendor/golang.org/x/tools/internal/imports/zstdlib.go +++ b/vendor/golang.org/x/tools/internal/imports/zstdlib.go @@ -415,6 +415,9 @@ var stdlib = map[string][]string{ "crypto/tls": []string{ "Certificate", "CertificateRequestInfo", + "CipherSuite", + "CipherSuiteName", + "CipherSuites", "Client", "ClientAuthType", "ClientHelloInfo", @@ -434,6 +437,7 @@ var stdlib = map[string][]string{ "ECDSAWithP521AndSHA512", "ECDSAWithSHA1", "Ed25519", + "InsecureCipherSuites", "Listen", "LoadX509KeyPair", "NewLRUClientSessionCache", @@ -465,6 +469,7 @@ var stdlib = map[string][]string{ "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305", + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", @@ -473,6 +478,7 @@ var stdlib = map[string][]string{ "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305", + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_RSA_WITH_RC4_128_SHA", "TLS_FALLBACK_SCSV", "TLS_RSA_WITH_3DES_EDE_CBC_SHA", @@ -698,36 +704,65 @@ var stdlib = map[string][]string{ "Attr", "AttrAbstractOrigin", "AttrAccessibility", + "AttrAddrBase", "AttrAddrClass", + "AttrAlignment", "AttrAllocated", "AttrArtificial", "AttrAssociated", "AttrBaseTypes", + "AttrBinaryScale", "AttrBitOffset", "AttrBitSize", "AttrByteSize", + "AttrCallAllCalls", + "AttrCallAllSourceCalls", + "AttrCallAllTailCalls", "AttrCallColumn", + "AttrCallDataLocation", + "AttrCallDataValue", "AttrCallFile", "AttrCallLine", + "AttrCallOrigin", + "AttrCallPC", + "AttrCallParameter", + "AttrCallReturnPC", + "AttrCallTailCall", + "AttrCallTarget", + "AttrCallTargetClobbered", + "AttrCallValue", "AttrCalling", "AttrCommonRef", "AttrCompDir", + "AttrConstExpr", "AttrConstValue", "AttrContainingType", "AttrCount", + "AttrDataBitOffset", "AttrDataLocation", "AttrDataMemberLoc", + "AttrDecimalScale", + "AttrDecimalSign", "AttrDeclColumn", "AttrDeclFile", "AttrDeclLine", "AttrDeclaration", "AttrDefaultValue", + "AttrDefaulted", + "AttrDeleted", "AttrDescription", + "AttrDigitCount", "AttrDiscr", "AttrDiscrList", "AttrDiscrValue", + "AttrDwoName", + "AttrElemental", "AttrEncoding", + "AttrEndianity", "AttrEntrypc", + "AttrEnumClass", + "AttrExplicit", + "AttrExportSymbols", "AttrExtension", "AttrExternal", "AttrFrameBase", @@ -738,27 +773,47 @@ var stdlib = map[string][]string{ "AttrInline", "AttrIsOptional", "AttrLanguage", + "AttrLinkageName", "AttrLocation", + "AttrLoclistsBase", "AttrLowerBound", "AttrLowpc", "AttrMacroInfo", + "AttrMacros", + "AttrMainSubprogram", + "AttrMutable", "AttrName", "AttrNamelistItem", + "AttrNoreturn", + "AttrObjectPointer", "AttrOrdering", + "AttrPictureString", "AttrPriority", "AttrProducer", "AttrPrototyped", + "AttrPure", "AttrRanges", + "AttrRank", + "AttrRecursive", + "AttrReference", "AttrReturnAddr", + "AttrRnglistsBase", + "AttrRvalueReference", "AttrSegment", "AttrSibling", + "AttrSignature", + "AttrSmall", "AttrSpecification", "AttrStartScope", "AttrStaticLink", "AttrStmtList", + "AttrStrOffsetsBase", "AttrStride", "AttrStrideSize", "AttrStringLength", + "AttrStringLengthBitSize", + "AttrStringLengthByteSize", + "AttrThreadsScaled", "AttrTrampoline", "AttrType", "AttrUpperBound", @@ -772,18 +827,23 @@ var stdlib = map[string][]string{ "BoolType", "CharType", "Class", + "ClassAddrPtr", "ClassAddress", "ClassBlock", "ClassConstant", "ClassExprLoc", "ClassFlag", "ClassLinePtr", + "ClassLocList", "ClassLocListPtr", "ClassMacPtr", "ClassRangeListPtr", "ClassReference", "ClassReferenceAlt", "ClassReferenceSig", + "ClassRngList", + "ClassRngListsPtr", + "ClassStrOffsetsPtr", "ClassString", "ClassStringAlt", "ClassUnknown", @@ -814,9 +874,13 @@ var stdlib = map[string][]string{ "Tag", "TagAccessDeclaration", "TagArrayType", + "TagAtomicType", "TagBaseType", + "TagCallSite", + "TagCallSiteParameter", "TagCatchDwarfBlock", "TagClassType", + "TagCoarrayType", "TagCommonDwarfBlock", "TagCommonInclusion", "TagCompileUnit", @@ -824,12 +888,15 @@ var stdlib = map[string][]string{ "TagConstType", "TagConstant", "TagDwarfProcedure", + "TagDynamicType", "TagEntryPoint", "TagEnumerationType", "TagEnumerator", "TagFileType", "TagFormalParameter", "TagFriend", + "TagGenericSubrange", + "TagImmutableType", "TagImportedDeclaration", "TagImportedModule", "TagImportedUnit", @@ -853,6 +920,7 @@ var stdlib = map[string][]string{ "TagRvalueReferenceType", "TagSetType", "TagSharedType", + "TagSkeletonUnit", "TagStringType", "TagStructType", "TagSubprogram", @@ -2359,6 +2427,7 @@ var stdlib = map[string][]string{ "RawValue", "StructuralError", "SyntaxError", + "TagBMPString", "TagBitString", "TagBoolean", "TagEnum", @@ -2787,6 +2856,7 @@ var stdlib = map[string][]string{ "IsPredeclared", "Mode", "New", + "NewFromFiles", "Note", "Package", "PreserveAST", @@ -3115,6 +3185,11 @@ var stdlib = map[string][]string{ "New64", "New64a", }, + "hash/maphash": []string{ + "Hash", + "MakeSeed", + "Seed", + }, "html": []string{ "EscapeString", "UnescapeString", @@ -3367,6 +3442,7 @@ var stdlib = map[string][]string{ "Ldate", "Llongfile", "Lmicroseconds", + "Lmsgprefix", "Logger", "Lshortfile", "LstdFlags", @@ -3443,6 +3519,7 @@ var stdlib = map[string][]string{ "Exp", "Exp2", "Expm1", + "FMA", "Float32bits", "Float32frombits", "Float64bits", @@ -3567,6 +3644,9 @@ var stdlib = map[string][]string{ "OnesCount32", "OnesCount64", "OnesCount8", + "Rem", + "Rem32", + "Rem64", "Reverse", "Reverse16", "Reverse32", @@ -5140,7 +5220,10 @@ var stdlib = map[string][]string{ "CTL_NET", "CTL_QUERY", "CTRL_BREAK_EVENT", + "CTRL_CLOSE_EVENT", "CTRL_C_EVENT", + "CTRL_LOGOFF_EVENT", + "CTRL_SHUTDOWN_EVENT", "CancelIo", "CancelIoEx", "CertAddCertificateContextToStore", @@ -10112,6 +10195,7 @@ var stdlib = map[string][]string{ "Duployan", "Egyptian_Hieroglyphs", "Elbasan", + "Elymaic", "Ethiopic", "Extender", "FoldCategory", @@ -10215,6 +10299,7 @@ var stdlib = map[string][]string{ "Myanmar", "N", "Nabataean", + "Nandinagari", "Nd", "New_Tai_Lue", "Newa", @@ -10224,6 +10309,7 @@ var stdlib = map[string][]string{ "Noncharacter_Code_Point", "Number", "Nushu", + "Nyiakeng_Puachue_Hmong", "Ogham", "Ol_Chiki", "Old_Hungarian", @@ -10331,6 +10417,7 @@ var stdlib = map[string][]string{ "Vai", "Variation_Selector", "Version", + "Wancho", "Warang_Citi", "White_Space", "Yi", diff --git a/vendor/golang.org/x/tools/internal/telemetry/event/event.go b/vendor/golang.org/x/tools/internal/telemetry/event/event.go deleted file mode 100644 index 2b990c5c1..000000000 --- a/vendor/golang.org/x/tools/internal/telemetry/event/event.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package event provides support for event based telemetry. -package event - -import ( - "fmt" - "time" -) - -type eventType uint8 - -const ( - invalidType = eventType(iota) - LogType // an event that should be recorded in a log - StartSpanType // the start of a span of time - EndSpanType // the end of a span of time - LabelType // some values that should be noted for later events - DetachType // an event that causes a context to detach - RecordType // a value that should be tracked -) - -// sTags is used to hold a small number of tags inside an event whichout -// requiring a separate allocation. -// As tags are often on the stack, this avoids an allocation at all for -// the very common cases of simple events. -// The length needs to be large enough to cope with the majority of events -// but no so large as to cause undue stack pressure. -// A log message with two values will use 3 tags (one for each value and -// one for the message itself). -type sTags [3]Tag - -// Event holds the information about an event of note that ocurred. -type Event struct { - At time.Time - - typ eventType - static sTags // inline storage for the first few tags - dynamic []Tag // dynamically sized storage for remaining tags -} - -// eventTagMap implements TagMap for a the tags of an Event. -type eventTagMap struct { - event Event -} - -func (ev Event) IsLog() bool { return ev.typ == LogType } -func (ev Event) IsEndSpan() bool { return ev.typ == EndSpanType } -func (ev Event) IsStartSpan() bool { return ev.typ == StartSpanType } -func (ev Event) IsLabel() bool { return ev.typ == LabelType } -func (ev Event) IsDetach() bool { return ev.typ == DetachType } -func (ev Event) IsRecord() bool { return ev.typ == RecordType } - -func (ev Event) Format(f fmt.State, r rune) { - tagMap := TagMap(ev) - if !ev.At.IsZero() { - fmt.Fprint(f, ev.At.Format("2006/01/02 15:04:05 ")) - } - msg := Msg.Get(tagMap) - err := Err.Get(tagMap) - fmt.Fprint(f, msg) - if err != nil { - if f.Flag('+') { - fmt.Fprintf(f, ": %+v", err) - } else { - fmt.Fprintf(f, ": %v", err) - } - } - for index := 0; ev.Valid(index); index++ { - tag := ev.Tag(index) - // msg and err were both already printed above, so we skip them to avoid - // double printing - if !tag.Valid() || tag.Key() == Msg || tag.Key() == Err { - continue - } - fmt.Fprintf(f, "\n\t%v", tag) - } -} - -func (ev Event) Valid(index int) bool { - return index >= 0 && index < len(ev.static)+len(ev.dynamic) -} - -func (ev Event) Tag(index int) Tag { - if index < len(ev.static) { - return ev.static[index] - } - return ev.dynamic[index-len(ev.static)] -} - -func (ev Event) Find(key Key) Tag { - for _, tag := range ev.static { - if tag.Key() == key { - return tag - } - } - for _, tag := range ev.dynamic { - if tag.Key() == key { - return tag - } - } - return Tag{} -} - -func makeEvent(typ eventType, static sTags, tags []Tag) Event { - return Event{ - typ: typ, - static: static, - dynamic: tags, - } -} diff --git a/vendor/golang.org/x/tools/internal/telemetry/event/key.go b/vendor/golang.org/x/tools/internal/telemetry/event/key.go deleted file mode 100644 index acde7511e..000000000 --- a/vendor/golang.org/x/tools/internal/telemetry/event/key.go +++ /dev/null @@ -1,565 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package event - -import ( - "fmt" - "io" - "math" - "strconv" -) - -var ( - // Msg is a key used to add message strings to tag lists. - Msg = NewStringKey("message", "a readable message") - // Name is used for things like traces that have a name. - Name = NewStringKey("name", "an entity name") - // Err is a key used to add error values to tag lists. - Err = NewErrorKey("error", "an error that occurred") -) - -// Key is used as the identity of a Tag. -// Keys are intended to be compared by pointer only, the name should be unique -// for communicating with external systems, but it is not required or enforced. -type Key interface { - // Name returns the key name. - Name() string - // Description returns a string that can be used to describe the value. - Description() string - - // Format is used in formatting to append the value of the tag to the - // supplied buffer. - // The formatter may use the supplied buf as a scratch area to avoid - // allocations. - Format(w io.Writer, buf []byte, tag Tag) -} - -// ValueKey represents a key for untyped values. -type ValueKey struct { - name string - description string -} - -// NewKey creates a new Key for untyped values. -func NewKey(name, description string) *ValueKey { - return &ValueKey{name: name, description: description} -} - -func (k *ValueKey) Name() string { return k.name } -func (k *ValueKey) Description() string { return k.description } - -func (k *ValueKey) Format(w io.Writer, buf []byte, tag Tag) { - fmt.Fprint(w, k.From(tag)) -} - -// Get can be used to get a tag for the key from a TagMap. -func (k *ValueKey) Get(tags TagMap) interface{} { - if t := tags.Find(k); t.Valid() { - return k.From(t) - } - return nil -} - -// From can be used to get a value from a Tag. -func (k *ValueKey) From(t Tag) interface{} { return t.UnpackValue() } - -// Of creates a new Tag with this key and the supplied value. -func (k *ValueKey) Of(value interface{}) Tag { return TagOfValue(k, value) } - -// IntKey represents a key -type IntKey struct { - name string - description string -} - -// NewIntKey creates a new Key for int values. -func NewIntKey(name, description string) *IntKey { - return &IntKey{name: name, description: description} -} - -func (k *IntKey) Name() string { return k.name } -func (k *IntKey) Description() string { return k.description } - -func (k *IntKey) Format(w io.Writer, buf []byte, tag Tag) { - w.Write(strconv.AppendInt(buf, int64(k.From(tag)), 10)) -} - -// Of creates a new Tag with this key and the supplied value. -func (k *IntKey) Of(v int) Tag { return TagOf64(k, uint64(v)) } - -// Get can be used to get a tag for the key from a TagMap. -func (k *IntKey) Get(tags TagMap) int { - if t := tags.Find(k); t.Valid() { - return k.From(t) - } - return 0 -} - -// From can be used to get a value from a Tag. -func (k *IntKey) From(t Tag) int { return int(t.Unpack64()) } - -// Int8Key represents a key -type Int8Key struct { - name string - description string -} - -// NewInt8Key creates a new Key for int8 values. -func NewInt8Key(name, description string) *Int8Key { - return &Int8Key{name: name, description: description} -} - -func (k *Int8Key) Name() string { return k.name } -func (k *Int8Key) Description() string { return k.description } - -func (k *Int8Key) Format(w io.Writer, buf []byte, tag Tag) { - w.Write(strconv.AppendInt(buf, int64(k.From(tag)), 10)) -} - -// Of creates a new Tag with this key and the supplied value. -func (k *Int8Key) Of(v int8) Tag { return TagOf64(k, uint64(v)) } - -// Get can be used to get a tag for the key from a TagMap. -func (k *Int8Key) Get(tags TagMap) int8 { - if t := tags.Find(k); t.Valid() { - return k.From(t) - } - return 0 -} - -// From can be used to get a value from a Tag. -func (k *Int8Key) From(t Tag) int8 { return int8(t.Unpack64()) } - -// Int16Key represents a key -type Int16Key struct { - name string - description string -} - -// NewInt16Key creates a new Key for int16 values. -func NewInt16Key(name, description string) *Int16Key { - return &Int16Key{name: name, description: description} -} - -func (k *Int16Key) Name() string { return k.name } -func (k *Int16Key) Description() string { return k.description } - -func (k *Int16Key) Format(w io.Writer, buf []byte, tag Tag) { - w.Write(strconv.AppendInt(buf, int64(k.From(tag)), 10)) -} - -// Of creates a new Tag with this key and the supplied value. -func (k *Int16Key) Of(v int16) Tag { return TagOf64(k, uint64(v)) } - -// Get can be used to get a tag for the key from a TagMap. -func (k *Int16Key) Get(tags TagMap) int16 { - if t := tags.Find(k); t.Valid() { - return k.From(t) - } - return 0 -} - -// From can be used to get a value from a Tag. -func (k *Int16Key) From(t Tag) int16 { return int16(t.Unpack64()) } - -// Int32Key represents a key -type Int32Key struct { - name string - description string -} - -// NewInt32Key creates a new Key for int32 values. -func NewInt32Key(name, description string) *Int32Key { - return &Int32Key{name: name, description: description} -} - -func (k *Int32Key) Name() string { return k.name } -func (k *Int32Key) Description() string { return k.description } - -func (k *Int32Key) Format(w io.Writer, buf []byte, tag Tag) { - w.Write(strconv.AppendInt(buf, int64(k.From(tag)), 10)) -} - -// Of creates a new Tag with this key and the supplied value. -func (k *Int32Key) Of(v int32) Tag { return TagOf64(k, uint64(v)) } - -// Get can be used to get a tag for the key from a TagMap. -func (k *Int32Key) Get(tags TagMap) int32 { - if t := tags.Find(k); t.Valid() { - return k.From(t) - } - return 0 -} - -// From can be used to get a value from a Tag. -func (k *Int32Key) From(t Tag) int32 { return int32(t.Unpack64()) } - -// Int64Key represents a key -type Int64Key struct { - name string - description string -} - -// NewInt64Key creates a new Key for int64 values. -func NewInt64Key(name, description string) *Int64Key { - return &Int64Key{name: name, description: description} -} - -func (k *Int64Key) Name() string { return k.name } -func (k *Int64Key) Description() string { return k.description } - -func (k *Int64Key) Format(w io.Writer, buf []byte, tag Tag) { - w.Write(strconv.AppendInt(buf, k.From(tag), 10)) -} - -// Of creates a new Tag with this key and the supplied value. -func (k *Int64Key) Of(v int64) Tag { return TagOf64(k, uint64(v)) } - -// Get can be used to get a tag for the key from a TagMap. -func (k *Int64Key) Get(tags TagMap) int64 { - if t := tags.Find(k); t.Valid() { - return k.From(t) - } - return 0 -} - -// From can be used to get a value from a Tag. -func (k *Int64Key) From(t Tag) int64 { return int64(t.Unpack64()) } - -// UIntKey represents a key -type UIntKey struct { - name string - description string -} - -// NewUIntKey creates a new Key for uint values. -func NewUIntKey(name, description string) *UIntKey { - return &UIntKey{name: name, description: description} -} - -func (k *UIntKey) Name() string { return k.name } -func (k *UIntKey) Description() string { return k.description } - -func (k *UIntKey) Format(w io.Writer, buf []byte, tag Tag) { - w.Write(strconv.AppendUint(buf, uint64(k.From(tag)), 10)) -} - -// Of creates a new Tag with this key and the supplied value. -func (k *UIntKey) Of(v uint) Tag { return TagOf64(k, uint64(v)) } - -// Get can be used to get a tag for the key from a TagMap. -func (k *UIntKey) Get(tags TagMap) uint { - if t := tags.Find(k); t.Valid() { - return k.From(t) - } - return 0 -} - -// From can be used to get a value from a Tag. -func (k *UIntKey) From(t Tag) uint { return uint(t.Unpack64()) } - -// UInt8Key represents a key -type UInt8Key struct { - name string - description string -} - -// NewUInt8Key creates a new Key for uint8 values. -func NewUInt8Key(name, description string) *UInt8Key { - return &UInt8Key{name: name, description: description} -} - -func (k *UInt8Key) Name() string { return k.name } -func (k *UInt8Key) Description() string { return k.description } - -func (k *UInt8Key) Format(w io.Writer, buf []byte, tag Tag) { - w.Write(strconv.AppendUint(buf, uint64(k.From(tag)), 10)) -} - -// Of creates a new Tag with this key and the supplied value. -func (k *UInt8Key) Of(v uint8) Tag { return TagOf64(k, uint64(v)) } - -// Get can be used to get a tag for the key from a TagMap. -func (k *UInt8Key) Get(tags TagMap) uint8 { - if t := tags.Find(k); t.Valid() { - return k.From(t) - } - return 0 -} - -// From can be used to get a value from a Tag. -func (k *UInt8Key) From(t Tag) uint8 { return uint8(t.Unpack64()) } - -// UInt16Key represents a key -type UInt16Key struct { - name string - description string -} - -// NewUInt16Key creates a new Key for uint16 values. -func NewUInt16Key(name, description string) *UInt16Key { - return &UInt16Key{name: name, description: description} -} - -func (k *UInt16Key) Name() string { return k.name } -func (k *UInt16Key) Description() string { return k.description } - -func (k *UInt16Key) Format(w io.Writer, buf []byte, tag Tag) { - w.Write(strconv.AppendUint(buf, uint64(k.From(tag)), 10)) -} - -// Of creates a new Tag with this key and the supplied value. -func (k *UInt16Key) Of(v uint16) Tag { return TagOf64(k, uint64(v)) } - -// Get can be used to get a tag for the key from a TagMap. -func (k *UInt16Key) Get(tags TagMap) uint16 { - if t := tags.Find(k); t.Valid() { - return k.From(t) - } - return 0 -} - -// From can be used to get a value from a Tag. -func (k *UInt16Key) From(t Tag) uint16 { return uint16(t.Unpack64()) } - -// UInt32Key represents a key -type UInt32Key struct { - name string - description string -} - -// NewUInt32Key creates a new Key for uint32 values. -func NewUInt32Key(name, description string) *UInt32Key { - return &UInt32Key{name: name, description: description} -} - -func (k *UInt32Key) Name() string { return k.name } -func (k *UInt32Key) Description() string { return k.description } - -func (k *UInt32Key) Format(w io.Writer, buf []byte, tag Tag) { - w.Write(strconv.AppendUint(buf, uint64(k.From(tag)), 10)) -} - -// Of creates a new Tag with this key and the supplied value. -func (k *UInt32Key) Of(v uint32) Tag { return TagOf64(k, uint64(v)) } - -// Get can be used to get a tag for the key from a TagMap. -func (k *UInt32Key) Get(tags TagMap) uint32 { - if t := tags.Find(k); t.Valid() { - return k.From(t) - } - return 0 -} - -// From can be used to get a value from a Tag. -func (k *UInt32Key) From(t Tag) uint32 { return uint32(t.Unpack64()) } - -// UInt64Key represents a key -type UInt64Key struct { - name string - description string -} - -// NewUInt64Key creates a new Key for uint64 values. -func NewUInt64Key(name, description string) *UInt64Key { - return &UInt64Key{name: name, description: description} -} - -func (k *UInt64Key) Name() string { return k.name } -func (k *UInt64Key) Description() string { return k.description } - -func (k *UInt64Key) Format(w io.Writer, buf []byte, tag Tag) { - w.Write(strconv.AppendUint(buf, k.From(tag), 10)) -} - -// Of creates a new Tag with this key and the supplied value. -func (k *UInt64Key) Of(v uint64) Tag { return TagOf64(k, v) } - -// Get can be used to get a tag for the key from a TagMap. -func (k *UInt64Key) Get(tags TagMap) uint64 { - if t := tags.Find(k); t.Valid() { - return k.From(t) - } - return 0 -} - -// From can be used to get a value from a Tag. -func (k *UInt64Key) From(t Tag) uint64 { return t.Unpack64() } - -// Float32Key represents a key -type Float32Key struct { - name string - description string -} - -// NewFloat32Key creates a new Key for float32 values. -func NewFloat32Key(name, description string) *Float32Key { - return &Float32Key{name: name, description: description} -} - -func (k *Float32Key) Name() string { return k.name } -func (k *Float32Key) Description() string { return k.description } - -func (k *Float32Key) Format(w io.Writer, buf []byte, tag Tag) { - w.Write(strconv.AppendFloat(buf, float64(k.From(tag)), 'E', -1, 32)) -} - -// Of creates a new Tag with this key and the supplied value. -func (k *Float32Key) Of(v float32) Tag { - return TagOf64(k, uint64(math.Float32bits(v))) -} - -// Get can be used to get a tag for the key from a TagMap. -func (k *Float32Key) Get(tags TagMap) float32 { - if t := tags.Find(k); t.Valid() { - return k.From(t) - } - return 0 -} - -// From can be used to get a value from a Tag. -func (k *Float32Key) From(t Tag) float32 { - return math.Float32frombits(uint32(t.Unpack64())) -} - -// Float64Key represents a key -type Float64Key struct { - name string - description string -} - -// NewFloat64Key creates a new Key for int64 values. -func NewFloat64Key(name, description string) *Float64Key { - return &Float64Key{name: name, description: description} -} - -func (k *Float64Key) Name() string { return k.name } -func (k *Float64Key) Description() string { return k.description } - -func (k *Float64Key) Format(w io.Writer, buf []byte, tag Tag) { - w.Write(strconv.AppendFloat(buf, k.From(tag), 'E', -1, 64)) -} - -// Of creates a new Tag with this key and the supplied value. -func (k *Float64Key) Of(v float64) Tag { - return TagOf64(k, math.Float64bits(v)) -} - -// Get can be used to get a tag for the key from a TagMap. -func (k *Float64Key) Get(tags TagMap) float64 { - if t := tags.Find(k); t.Valid() { - return k.From(t) - } - return 0 -} - -// From can be used to get a value from a Tag. -func (k *Float64Key) From(t Tag) float64 { - return math.Float64frombits(t.Unpack64()) -} - -// StringKey represents a key -type StringKey struct { - name string - description string -} - -// NewStringKey creates a new Key for int64 values. -func NewStringKey(name, description string) *StringKey { - return &StringKey{name: name, description: description} -} - -func (k *StringKey) Name() string { return k.name } -func (k *StringKey) Description() string { return k.description } - -func (k *StringKey) Format(w io.Writer, buf []byte, tag Tag) { - w.Write(strconv.AppendQuote(buf, k.From(tag))) -} - -// Of creates a new Tag with this key and the supplied value. -func (k *StringKey) Of(v string) Tag { return TagOfString(k, v) } - -// Get can be used to get a tag for the key from a TagMap. -func (k *StringKey) Get(tags TagMap) string { - if t := tags.Find(k); t.Valid() { - return k.From(t) - } - return "" -} - -// From can be used to get a value from a Tag. -func (k *StringKey) From(t Tag) string { return t.UnpackString() } - -// BooleanKey represents a key -type BooleanKey struct { - name string - description string -} - -// NewBooleanKey creates a new Key for bool values. -func NewBooleanKey(name, description string) *BooleanKey { - return &BooleanKey{name: name, description: description} -} - -func (k *BooleanKey) Name() string { return k.name } -func (k *BooleanKey) Description() string { return k.description } - -func (k *BooleanKey) Format(w io.Writer, buf []byte, tag Tag) { - w.Write(strconv.AppendBool(buf, k.From(tag))) -} - -// Of creates a new Tag with this key and the supplied value. -func (k *BooleanKey) Of(v bool) Tag { - if v { - return TagOf64(k, 1) - } - return TagOf64(k, 0) -} - -// Get can be used to get a tag for the key from a TagMap. -func (k *BooleanKey) Get(tags TagMap) bool { - if t := tags.Find(k); t.Valid() { - return k.From(t) - } - return false -} - -// From can be used to get a value from a Tag. -func (k *BooleanKey) From(t Tag) bool { return t.Unpack64() > 0 } - -// ErrorKey represents a key -type ErrorKey struct { - name string - description string -} - -// NewErrorKey creates a new Key for int64 values. -func NewErrorKey(name, description string) *ErrorKey { - return &ErrorKey{name: name, description: description} -} - -func (k *ErrorKey) Name() string { return k.name } -func (k *ErrorKey) Description() string { return k.description } - -func (k *ErrorKey) Format(w io.Writer, buf []byte, tag Tag) { - io.WriteString(w, k.From(tag).Error()) -} - -// Of creates a new Tag with this key and the supplied value. -func (k *ErrorKey) Of(v error) Tag { return TagOfValue(k, v) } - -// Get can be used to get a tag for the key from a TagMap. -func (k *ErrorKey) Get(tags TagMap) error { - if t := tags.Find(k); t.Valid() { - return k.From(t) - } - return nil -} - -// From can be used to get a value from a Tag. -func (k *ErrorKey) From(t Tag) error { - err, _ := t.UnpackValue().(error) - return err -} diff --git a/vendor/golang.org/x/tools/internal/telemetry/event/label.go b/vendor/golang.org/x/tools/internal/telemetry/event/label.go deleted file mode 100644 index edd34bb08..000000000 --- a/vendor/golang.org/x/tools/internal/telemetry/event/label.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package event - -import ( - "context" -) - -// Label sends a label event to the exporter with the supplied tags. -func Label(ctx context.Context, tags ...Tag) context.Context { - return dispatch(ctx, makeEvent(LabelType, sTags{}, tags)) -} - -// Label1 sends a label event to the exporter with the supplied tags. -func Label1(ctx context.Context, t1 Tag) context.Context { - return dispatch(ctx, makeEvent(LabelType, sTags{t1}, nil)) -} - -// Label2 sends a label event to the exporter with the supplied tags. -func Label2(ctx context.Context, t1, t2 Tag) context.Context { - return dispatch(ctx, makeEvent(LabelType, sTags{t1, t2}, nil)) -} - -// Label3 sends a label event to the exporter with the supplied tags. -func Label3(ctx context.Context, t1, t2, t3 Tag) context.Context { - return dispatch(ctx, makeEvent(LabelType, sTags{t1, t2, t3}, nil)) -} diff --git a/vendor/golang.org/x/tools/internal/telemetry/event/log.go b/vendor/golang.org/x/tools/internal/telemetry/event/log.go deleted file mode 100644 index 568aa1b92..000000000 --- a/vendor/golang.org/x/tools/internal/telemetry/event/log.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package event - -import ( - "context" - "errors" -) - -// Log sends a log event with the supplied tag list to the exporter. -func Log(ctx context.Context, tags ...Tag) { - dispatch(ctx, makeEvent(LogType, sTags{}, tags)) -} - -// Log1 sends a label event to the exporter with the supplied tags. -func Log1(ctx context.Context, t1 Tag) context.Context { - return dispatch(ctx, makeEvent(LogType, sTags{t1}, nil)) -} - -// Log2 sends a label event to the exporter with the supplied tags. -func Log2(ctx context.Context, t1, t2 Tag) context.Context { - return dispatch(ctx, makeEvent(LogType, sTags{t1, t2}, nil)) -} - -// Log3 sends a label event to the exporter with the supplied tags. -func Log3(ctx context.Context, t1, t2, t3 Tag) context.Context { - return dispatch(ctx, makeEvent(LogType, sTags{t1, t2, t3}, nil)) -} - -// Print takes a message and a tag list and combines them into a single event -// before delivering them to the exporter. -func Print(ctx context.Context, message string, tags ...Tag) { - dispatch(ctx, makeEvent(LogType, sTags{Msg.Of(message)}, tags)) -} - -// Print1 takes a message and one tag delivers a log event to the exporter. -// It is a customized version of Print that is faster and does no allocation. -func Print1(ctx context.Context, message string, t1 Tag) { - dispatch(ctx, makeEvent(LogType, sTags{Msg.Of(message), t1}, nil)) -} - -// Print2 takes a message and two tags and delivers a log event to the exporter. -// It is a customized version of Print that is faster and does no allocation. -func Print2(ctx context.Context, message string, t1 Tag, t2 Tag) { - dispatch(ctx, makeEvent(LogType, sTags{Msg.Of(message), t1, t2}, nil)) -} - -// Error takes a message and a tag list and combines them into a single event -// before delivering them to the exporter. It captures the error in the -// delivered event. -func Error(ctx context.Context, message string, err error, tags ...Tag) { - if err == nil { - err = errors.New(message) - message = "" - } - dispatch(ctx, makeEvent(LogType, sTags{Msg.Of(message), Err.Of(err)}, tags)) -} diff --git a/vendor/golang.org/x/tools/internal/telemetry/event/metric.go b/vendor/golang.org/x/tools/internal/telemetry/event/metric.go deleted file mode 100644 index e4092bb0d..000000000 --- a/vendor/golang.org/x/tools/internal/telemetry/event/metric.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package event - -import ( - "context" -) - -// Record sends a label event to the exporter with the supplied tags. -func Record(ctx context.Context, tags ...Tag) context.Context { - return dispatch(ctx, makeEvent(RecordType, sTags{}, tags)) -} - -// Record1 sends a label event to the exporter with the supplied tags. -func Record1(ctx context.Context, t1 Tag) context.Context { - return dispatch(ctx, makeEvent(RecordType, sTags{t1}, nil)) -} - -// Record2 sends a label event to the exporter with the supplied tags. -func Record2(ctx context.Context, t1, t2 Tag) context.Context { - return dispatch(ctx, makeEvent(RecordType, sTags{t1, t2}, nil)) -} - -// Record3 sends a label event to the exporter with the supplied tags. -func Record3(ctx context.Context, t1, t2, t3 Tag) context.Context { - return dispatch(ctx, makeEvent(RecordType, sTags{t1, t2, t3}, nil)) -} diff --git a/vendor/golang.org/x/tools/internal/telemetry/event/tag.go b/vendor/golang.org/x/tools/internal/telemetry/event/tag.go deleted file mode 100644 index 8476bc967..000000000 --- a/vendor/golang.org/x/tools/internal/telemetry/event/tag.go +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package event - -import ( - "fmt" - "io" - "reflect" - "unsafe" -) - -// Tag holds a key and value pair. -// It is normally used when passing around lists of tags. -type Tag struct { - key Key - packed uint64 - untyped interface{} -} - -// TagMap is the interface to a collection of Tags indexed by key. -type TagMap interface { - // Find returns the tag that matches the supplied key. - Find(key Key) Tag -} - -// TagList is the interface to something that provides an iterable -// list of tags. -// Iteration should start from 0 and continue until Valid returns false. -type TagList interface { - // Valid returns true if the index is within range for the list. - // It does not imply the tag at that index will itself be valid. - Valid(index int) bool - // Tag returns the tag at the given index. - Tag(index int) Tag -} - -// tagList implements TagList for a list of Tags. -type tagList struct { - tags []Tag -} - -// tagFilter wraps a TagList filtering out specific tags. -type tagFilter struct { - keys []Key - underlying TagList -} - -// tagMap implements TagMap for a simple list of tags. -type tagMap struct { - tags []Tag -} - -// tagMapChain implements TagMap for a list of underlying TagMap. -type tagMapChain struct { - maps []TagMap -} - -// TagOfValue creates a new tag from the key and value. -// This method is for implementing new key types, tag creation should -// normally be done with the Of method of the key. -func TagOfValue(k Key, value interface{}) Tag { return Tag{key: k, untyped: value} } - -// UnpackValue assumes the tag was built using TagOfValue and returns the value -// that was passed to that constructor. -// This method is for implementing new key types, for type safety normal -// access should be done with the From method of the key. -func (t Tag) UnpackValue() interface{} { return t.untyped } - -// TagOf64 creates a new tag from a key and a uint64. This is often -// used for non uint64 values that can be packed into a uint64. -// This method is for implementing new key types, tag creation should -// normally be done with the Of method of the key. -func TagOf64(k Key, v uint64) Tag { return Tag{key: k, packed: v} } - -// Unpack64 assumes the tag was built using TagOf64 and returns the value that -// was passed to that constructor. -// This method is for implementing new key types, for type safety normal -// access should be done with the From method of the key. -func (t Tag) Unpack64() uint64 { return t.packed } - -// TagOfString creates a new tag from a key and a string. -// This method is for implementing new key types, tag creation should -// normally be done with the Of method of the key. -func TagOfString(k Key, v string) Tag { - hdr := (*reflect.StringHeader)(unsafe.Pointer(&v)) - return Tag{ - key: k, - packed: uint64(hdr.Len), - untyped: unsafe.Pointer(hdr.Data), - } -} - -// UnpackString assumes the tag was built using TagOfString and returns the -// value that was passed to that constructor. -// This method is for implementing new key types, for type safety normal -// access should be done with the From method of the key. -func (t Tag) UnpackString() string { - var v string - hdr := (*reflect.StringHeader)(unsafe.Pointer(&v)) - hdr.Data = uintptr(t.untyped.(unsafe.Pointer)) - hdr.Len = int(t.packed) - return *(*string)(unsafe.Pointer(hdr)) -} - -// Valid returns true if the Tag is a valid one (it has a key). -func (t Tag) Valid() bool { return t.key != nil } - -// Key returns the key of this Tag. -func (t Tag) Key() Key { return t.key } - -// Format is used for debug printing of tags. -func (t Tag) Format(f fmt.State, r rune) { - if !t.Valid() { - io.WriteString(f, `nil`) - return - } - io.WriteString(f, t.Key().Name()) - io.WriteString(f, "=") - var buf [128]byte - t.Key().Format(f, buf[:0], t) -} - -func (l *tagList) Valid(index int) bool { - return index >= 0 && index < len(l.tags) -} - -func (l *tagList) Tag(index int) Tag { - return l.tags[index] -} - -func (f *tagFilter) Valid(index int) bool { - return f.underlying.Valid(index) -} - -func (f *tagFilter) Tag(index int) Tag { - tag := f.underlying.Tag(index) - for _, f := range f.keys { - if tag.Key() == f { - return Tag{} - } - } - return tag -} - -func (l tagMap) Find(key Key) Tag { - for _, tag := range l.tags { - if tag.Key() == key { - return tag - } - } - return Tag{} -} - -func (c tagMapChain) Find(key Key) Tag { - for _, src := range c.maps { - tag := src.Find(key) - if tag.Valid() { - return tag - } - } - return Tag{} -} - -var emptyList = &tagList{} - -func NewTagList(tags ...Tag) TagList { - if len(tags) == 0 { - return emptyList - } - return &tagList{tags: tags} -} - -func Filter(l TagList, keys ...Key) TagList { - if len(keys) == 0 { - return l - } - return &tagFilter{keys: keys, underlying: l} -} - -func NewTagMap(tags ...Tag) TagMap { - return tagMap{tags: tags} -} - -func MergeTagMaps(srcs ...TagMap) TagMap { - return tagMapChain{maps: srcs} -} diff --git a/vendor/golang.org/x/tools/internal/telemetry/event/trace.go b/vendor/golang.org/x/tools/internal/telemetry/event/trace.go deleted file mode 100644 index 2c40341ff..000000000 --- a/vendor/golang.org/x/tools/internal/telemetry/event/trace.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package event - -import ( - "context" -) - -// StartSpan sends a span start event with the supplied tag list to the exporter. -// It also returns a function that will end the span, which should normally be -// deferred. -func StartSpan(ctx context.Context, name string, tags ...Tag) (context.Context, func()) { - return dispatchPair(ctx, - makeEvent(StartSpanType, sTags{Name.Of(name)}, tags), - makeEvent(EndSpanType, sTags{}, nil)) -} - -// StartSpan1 sends a span start event with the supplied tag list to the exporter. -// It also returns a function that will end the span, which should normally be -// deferred. -func StartSpan1(ctx context.Context, name string, t1 Tag) (context.Context, func()) { - return dispatchPair(ctx, - makeEvent(StartSpanType, sTags{Name.Of(name), t1}, nil), - makeEvent(EndSpanType, sTags{}, nil)) -} - -// StartSpan2 sends a span start event with the supplied tag list to the exporter. -// It also returns a function that will end the span, which should normally be -// deferred. -func StartSpan2(ctx context.Context, name string, t1, t2 Tag) (context.Context, func()) { - return dispatchPair(ctx, - makeEvent(StartSpanType, sTags{Name.Of(name), t1, t2}, nil), - makeEvent(EndSpanType, sTags{}, nil)) -} - -// Detach returns a context without an associated span. -// This allows the creation of spans that are not children of the current span. -func Detach(ctx context.Context) context.Context { - return dispatch(ctx, makeEvent(DetachType, sTags{}, nil)) -} diff --git a/vendor/k8s.io/client-go/discovery/fake/discovery.go b/vendor/k8s.io/client-go/discovery/fake/discovery.go deleted file mode 100644 index 335473dd1..000000000 --- a/vendor/k8s.io/client-go/discovery/fake/discovery.go +++ /dev/null @@ -1,160 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fake - -import ( - "fmt" - - "github.com/googleapis/gnostic/OpenAPIv2" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/version" - kubeversion "k8s.io/client-go/pkg/version" - restclient "k8s.io/client-go/rest" - "k8s.io/client-go/testing" -) - -// FakeDiscovery implements discovery.DiscoveryInterface and sometimes calls testing.Fake.Invoke with an action, -// but doesn't respect the return value if any. There is a way to fake static values like ServerVersion by using the Faked... fields on the struct. -type FakeDiscovery struct { - *testing.Fake - FakedServerVersion *version.Info -} - -// ServerResourcesForGroupVersion returns the supported resources for a group -// and version. -func (c *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error) { - action := testing.ActionImpl{ - Verb: "get", - Resource: schema.GroupVersionResource{Resource: "resource"}, - } - c.Invokes(action, nil) - for _, resourceList := range c.Resources { - if resourceList.GroupVersion == groupVersion { - return resourceList, nil - } - } - return nil, fmt.Errorf("GroupVersion %q not found", groupVersion) -} - -// ServerResources returns the supported resources for all groups and versions. -// Deprecated: use ServerGroupsAndResources instead. -func (c *FakeDiscovery) ServerResources() ([]*metav1.APIResourceList, error) { - _, rs, err := c.ServerGroupsAndResources() - return rs, err -} - -// ServerGroupsAndResources returns the supported groups and resources for all groups and versions. -func (c *FakeDiscovery) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error) { - sgs, err := c.ServerGroups() - if err != nil { - return nil, nil, err - } - resultGroups := []*metav1.APIGroup{} - for i := range sgs.Groups { - resultGroups = append(resultGroups, &sgs.Groups[i]) - } - - action := testing.ActionImpl{ - Verb: "get", - Resource: schema.GroupVersionResource{Resource: "resource"}, - } - c.Invokes(action, nil) - return resultGroups, c.Resources, nil -} - -// ServerPreferredResources returns the supported resources with the version -// preferred by the server. -func (c *FakeDiscovery) ServerPreferredResources() ([]*metav1.APIResourceList, error) { - return nil, nil -} - -// ServerPreferredNamespacedResources returns the supported namespaced resources -// with the version preferred by the server. -func (c *FakeDiscovery) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) { - return nil, nil -} - -// ServerGroups returns the supported groups, with information like supported -// versions and the preferred version. -func (c *FakeDiscovery) ServerGroups() (*metav1.APIGroupList, error) { - action := testing.ActionImpl{ - Verb: "get", - Resource: schema.GroupVersionResource{Resource: "group"}, - } - c.Invokes(action, nil) - - groups := map[string]*metav1.APIGroup{} - - for _, res := range c.Resources { - gv, err := schema.ParseGroupVersion(res.GroupVersion) - if err != nil { - return nil, err - } - group := groups[gv.Group] - if group == nil { - group = &metav1.APIGroup{ - Name: gv.Group, - PreferredVersion: metav1.GroupVersionForDiscovery{ - GroupVersion: res.GroupVersion, - Version: gv.Version, - }, - } - groups[gv.Group] = group - } - - group.Versions = append(group.Versions, metav1.GroupVersionForDiscovery{ - GroupVersion: res.GroupVersion, - Version: gv.Version, - }) - } - - list := &metav1.APIGroupList{} - for _, apiGroup := range groups { - list.Groups = append(list.Groups, *apiGroup) - } - - return list, nil - -} - -// ServerVersion retrieves and parses the server's version. -func (c *FakeDiscovery) ServerVersion() (*version.Info, error) { - action := testing.ActionImpl{} - action.Verb = "get" - action.Resource = schema.GroupVersionResource{Resource: "version"} - c.Invokes(action, nil) - - if c.FakedServerVersion != nil { - return c.FakedServerVersion, nil - } - - versionInfo := kubeversion.Get() - return &versionInfo, nil -} - -// OpenAPISchema retrieves and parses the swagger API schema the server supports. -func (c *FakeDiscovery) OpenAPISchema() (*openapi_v2.Document, error) { - return &openapi_v2.Document{}, nil -} - -// RESTClient returns a RESTClient that is used to communicate with API server -// by this client implementation. -func (c *FakeDiscovery) RESTClient() restclient.Interface { - return nil -} diff --git a/vendor/modules.txt b/vendor/modules.txt index fe6517a94..cbbda7b1a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -219,7 +219,7 @@ golang.org/x/text/unicode/norm golang.org/x/text/width # golang.org/x/time v0.0.0-20191024005414-555d28b269f0 golang.org/x/time/rate -# golang.org/x/tools v0.0.0-20200417140056-c07e33ef3290 +# golang.org/x/tools v0.0.0-20200423205358-59e73619c742 golang.org/x/tools/go/analysis golang.org/x/tools/go/analysis/passes/inspect golang.org/x/tools/go/ast/astutil @@ -233,12 +233,15 @@ golang.org/x/tools/go/types/objectpath golang.org/x/tools/go/types/typeutil golang.org/x/tools/imports golang.org/x/tools/internal/analysisinternal +golang.org/x/tools/internal/event +golang.org/x/tools/internal/event/core +golang.org/x/tools/internal/event/keys +golang.org/x/tools/internal/event/label golang.org/x/tools/internal/fastwalk golang.org/x/tools/internal/gocommand golang.org/x/tools/internal/gopathwalk golang.org/x/tools/internal/imports golang.org/x/tools/internal/packagesinternal -golang.org/x/tools/internal/telemetry/event # golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 golang.org/x/xerrors golang.org/x/xerrors/internal @@ -409,7 +412,6 @@ k8s.io/apimachinery/third_party/forked/golang/reflect k8s.io/client-go/discovery k8s.io/client-go/discovery/cached k8s.io/client-go/discovery/cached/memory -k8s.io/client-go/discovery/fake k8s.io/client-go/dynamic k8s.io/client-go/kubernetes k8s.io/client-go/kubernetes/scheme