diff --git a/examples/preflight/host/kernel-modules.yaml b/examples/preflight/host/kernel-modules.yaml new file mode 100644 index 000000000..c08cc86df --- /dev/null +++ b/examples/preflight/host/kernel-modules.yaml @@ -0,0 +1,25 @@ +apiVersion: troubleshoot.sh/v1beta2 +kind: HostPreflight +metadata: + name: modules +spec: + collectors: + - kernelModules: {} + analyzers: + - kernelModules: + outcomes: + - fail: + when: "target_core_mod != loaded,loadable" + message: The 'target_core_mod' kernel module is not loaded or loadable + - fail: + when: "target_core_file != loaded,loadable" + message: The 'target_core_file' kernel module is not loaded or loadable + - fail: + when: "tcm_loop != loaded,loadable" + message: The 'tcm_loop' kernel module is not loaded or loadable + - warn: + when: "nvme != loaded" + message: The system is not using NVME storage, which will provide better performance + - pass: + when: "target_core_mod,target_core_file,tcm_loop == loaded,loadable" + message: The 'target_core_mod', target_core_file', and 'tcm_loop' kernel modules are loaded or loadable diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/clientset.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/clientset.go new file mode 100644 index 000000000..cc5a29168 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/clientset.go @@ -0,0 +1,110 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package troubleshootclientset + +import ( + "fmt" + + troubleshootv1beta1 "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1" + troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2" + 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 + TroubleshootV1beta1() troubleshootv1beta1.TroubleshootV1beta1Interface + TroubleshootV1beta2() troubleshootv1beta2.TroubleshootV1beta2Interface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + troubleshootV1beta1 *troubleshootv1beta1.TroubleshootV1beta1Client + troubleshootV1beta2 *troubleshootv1beta2.TroubleshootV1beta2Client +} + +// TroubleshootV1beta1 retrieves the TroubleshootV1beta1Client +func (c *Clientset) TroubleshootV1beta1() troubleshootv1beta1.TroubleshootV1beta1Interface { + return c.troubleshootV1beta1 +} + +// TroubleshootV1beta2 retrieves the TroubleshootV1beta2Client +func (c *Clientset) TroubleshootV1beta2() troubleshootv1beta2.TroubleshootV1beta2Interface { + return c.troubleshootV1beta2 +} + +// 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.troubleshootV1beta1, err = troubleshootv1beta1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + cs.troubleshootV1beta2, err = troubleshootv1beta2.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.troubleshootV1beta1 = troubleshootv1beta1.NewForConfigOrDie(c) + cs.troubleshootV1beta2 = troubleshootv1beta2.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.troubleshootV1beta1 = troubleshootv1beta1.New(c) + cs.troubleshootV1beta2 = troubleshootv1beta2.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/doc.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/doc.go new file mode 100644 index 000000000..05559a44c --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated clientset. +package troubleshootclientset diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/clientset_generated.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/clientset_generated.go new file mode 100644 index 000000000..a6ef3f96c --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/clientset_generated.go @@ -0,0 +1,88 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + clientset "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset" + troubleshootv1beta1 "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1" + faketroubleshootv1beta1 "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake" + troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2" + faketroubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/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{} + +// TroubleshootV1beta1 retrieves the TroubleshootV1beta1Client +func (c *Clientset) TroubleshootV1beta1() troubleshootv1beta1.TroubleshootV1beta1Interface { + return &faketroubleshootv1beta1.FakeTroubleshootV1beta1{Fake: &c.Fake} +} + +// TroubleshootV1beta2 retrieves the TroubleshootV1beta2Client +func (c *Clientset) TroubleshootV1beta2() troubleshootv1beta2.TroubleshootV1beta2Interface { + return &faketroubleshootv1beta2.FakeTroubleshootV1beta2{Fake: &c.Fake} +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/doc.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/doc.go new file mode 100644 index 000000000..51266d807 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated fake clientset. +package fake diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/register.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/register.go new file mode 100644 index 000000000..8010c8843 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/fake/register.go @@ -0,0 +1,57 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + troubleshootv1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1" + troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + 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{ + troubleshootv1beta1.AddToScheme, + troubleshootv1beta2.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/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme/doc.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme/doc.go new file mode 100644 index 000000000..37f640ec2 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme/register.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme/register.go new file mode 100644 index 000000000..6ff4d4891 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme/register.go @@ -0,0 +1,57 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package scheme + +import ( + troubleshootv1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1" + troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + 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{ + troubleshootv1beta1.AddToScheme, + troubleshootv1beta2.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/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/analyzer.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/analyzer.go new file mode 100644 index 000000000..01541219f --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/analyzer.go @@ -0,0 +1,194 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + "time" + + v1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1" + scheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/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" +) + +// AnalyzersGetter has a method to return a AnalyzerInterface. +// A group's client should implement this interface. +type AnalyzersGetter interface { + Analyzers(namespace string) AnalyzerInterface +} + +// AnalyzerInterface has methods to work with Analyzer resources. +type AnalyzerInterface interface { + Create(ctx context.Context, analyzer *v1beta1.Analyzer, opts v1.CreateOptions) (*v1beta1.Analyzer, error) + Update(ctx context.Context, analyzer *v1beta1.Analyzer, opts v1.UpdateOptions) (*v1beta1.Analyzer, error) + UpdateStatus(ctx context.Context, analyzer *v1beta1.Analyzer, opts v1.UpdateOptions) (*v1beta1.Analyzer, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.Analyzer, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.AnalyzerList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Analyzer, err error) + AnalyzerExpansion +} + +// analyzers implements AnalyzerInterface +type analyzers struct { + client rest.Interface + ns string +} + +// newAnalyzers returns a Analyzers +func newAnalyzers(c *TroubleshootV1beta1Client, namespace string) *analyzers { + return &analyzers{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the analyzer, and returns the corresponding analyzer object, and an error if there is any. +func (c *analyzers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Analyzer, err error) { + result = &v1beta1.Analyzer{} + err = c.client.Get(). + Namespace(c.ns). + Resource("analyzers"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Analyzers that match those selectors. +func (c *analyzers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.AnalyzerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.AnalyzerList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("analyzers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested analyzers. +func (c *analyzers) Watch(ctx context.Context, 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("analyzers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a analyzer and creates it. Returns the server's representation of the analyzer, and an error, if there is any. +func (c *analyzers) Create(ctx context.Context, analyzer *v1beta1.Analyzer, opts v1.CreateOptions) (result *v1beta1.Analyzer, err error) { + result = &v1beta1.Analyzer{} + err = c.client.Post(). + Namespace(c.ns). + Resource("analyzers"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(analyzer). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a analyzer and updates it. Returns the server's representation of the analyzer, and an error, if there is any. +func (c *analyzers) Update(ctx context.Context, analyzer *v1beta1.Analyzer, opts v1.UpdateOptions) (result *v1beta1.Analyzer, err error) { + result = &v1beta1.Analyzer{} + err = c.client.Put(). + Namespace(c.ns). + Resource("analyzers"). + Name(analyzer.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(analyzer). + Do(ctx). + 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 *analyzers) UpdateStatus(ctx context.Context, analyzer *v1beta1.Analyzer, opts v1.UpdateOptions) (result *v1beta1.Analyzer, err error) { + result = &v1beta1.Analyzer{} + err = c.client.Put(). + Namespace(c.ns). + Resource("analyzers"). + Name(analyzer.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(analyzer). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the analyzer and deletes it. Returns an error if one occurs. +func (c *analyzers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("analyzers"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *analyzers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("analyzers"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched analyzer. +func (c *analyzers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Analyzer, err error) { + result = &v1beta1.Analyzer{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("analyzers"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/collector.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/collector.go new file mode 100644 index 000000000..cb814c4d1 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/collector.go @@ -0,0 +1,194 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + "time" + + v1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1" + scheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/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" +) + +// CollectorsGetter has a method to return a CollectorInterface. +// A group's client should implement this interface. +type CollectorsGetter interface { + Collectors(namespace string) CollectorInterface +} + +// CollectorInterface has methods to work with Collector resources. +type CollectorInterface interface { + Create(ctx context.Context, collector *v1beta1.Collector, opts v1.CreateOptions) (*v1beta1.Collector, error) + Update(ctx context.Context, collector *v1beta1.Collector, opts v1.UpdateOptions) (*v1beta1.Collector, error) + UpdateStatus(ctx context.Context, collector *v1beta1.Collector, opts v1.UpdateOptions) (*v1beta1.Collector, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.Collector, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.CollectorList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Collector, err error) + CollectorExpansion +} + +// collectors implements CollectorInterface +type collectors struct { + client rest.Interface + ns string +} + +// newCollectors returns a Collectors +func newCollectors(c *TroubleshootV1beta1Client, namespace string) *collectors { + return &collectors{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the collector, and returns the corresponding collector object, and an error if there is any. +func (c *collectors) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Collector, err error) { + result = &v1beta1.Collector{} + err = c.client.Get(). + Namespace(c.ns). + Resource("collectors"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Collectors that match those selectors. +func (c *collectors) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CollectorList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.CollectorList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("collectors"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested collectors. +func (c *collectors) Watch(ctx context.Context, 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("collectors"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a collector and creates it. Returns the server's representation of the collector, and an error, if there is any. +func (c *collectors) Create(ctx context.Context, collector *v1beta1.Collector, opts v1.CreateOptions) (result *v1beta1.Collector, err error) { + result = &v1beta1.Collector{} + err = c.client.Post(). + Namespace(c.ns). + Resource("collectors"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(collector). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a collector and updates it. Returns the server's representation of the collector, and an error, if there is any. +func (c *collectors) Update(ctx context.Context, collector *v1beta1.Collector, opts v1.UpdateOptions) (result *v1beta1.Collector, err error) { + result = &v1beta1.Collector{} + err = c.client.Put(). + Namespace(c.ns). + Resource("collectors"). + Name(collector.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(collector). + Do(ctx). + 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 *collectors) UpdateStatus(ctx context.Context, collector *v1beta1.Collector, opts v1.UpdateOptions) (result *v1beta1.Collector, err error) { + result = &v1beta1.Collector{} + err = c.client.Put(). + Namespace(c.ns). + Resource("collectors"). + Name(collector.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(collector). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the collector and deletes it. Returns an error if one occurs. +func (c *collectors) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("collectors"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *collectors) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("collectors"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched collector. +func (c *collectors) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Collector, err error) { + result = &v1beta1.Collector{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("collectors"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/doc.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/doc.go new file mode 100644 index 000000000..e189fb145 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/doc.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/doc.go new file mode 100644 index 000000000..0767328a9 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_analyzer.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_analyzer.go new file mode 100644 index 000000000..ec5667589 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_analyzer.go @@ -0,0 +1,141 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1" + 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" +) + +// FakeAnalyzers implements AnalyzerInterface +type FakeAnalyzers struct { + Fake *FakeTroubleshootV1beta1 + ns string +} + +var analyzersResource = schema.GroupVersionResource{Group: "troubleshoot.replicated.com", Version: "v1beta1", Resource: "analyzers"} + +var analyzersKind = schema.GroupVersionKind{Group: "troubleshoot.replicated.com", Version: "v1beta1", Kind: "Analyzer"} + +// Get takes name of the analyzer, and returns the corresponding analyzer object, and an error if there is any. +func (c *FakeAnalyzers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Analyzer, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(analyzersResource, c.ns, name), &v1beta1.Analyzer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Analyzer), err +} + +// List takes label and field selectors, and returns the list of Analyzers that match those selectors. +func (c *FakeAnalyzers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.AnalyzerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(analyzersResource, analyzersKind, c.ns, opts), &v1beta1.AnalyzerList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.AnalyzerList{ListMeta: obj.(*v1beta1.AnalyzerList).ListMeta} + for _, item := range obj.(*v1beta1.AnalyzerList).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 analyzers. +func (c *FakeAnalyzers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(analyzersResource, c.ns, opts)) + +} + +// Create takes the representation of a analyzer and creates it. Returns the server's representation of the analyzer, and an error, if there is any. +func (c *FakeAnalyzers) Create(ctx context.Context, analyzer *v1beta1.Analyzer, opts v1.CreateOptions) (result *v1beta1.Analyzer, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(analyzersResource, c.ns, analyzer), &v1beta1.Analyzer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Analyzer), err +} + +// Update takes the representation of a analyzer and updates it. Returns the server's representation of the analyzer, and an error, if there is any. +func (c *FakeAnalyzers) Update(ctx context.Context, analyzer *v1beta1.Analyzer, opts v1.UpdateOptions) (result *v1beta1.Analyzer, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(analyzersResource, c.ns, analyzer), &v1beta1.Analyzer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Analyzer), 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 *FakeAnalyzers) UpdateStatus(ctx context.Context, analyzer *v1beta1.Analyzer, opts v1.UpdateOptions) (*v1beta1.Analyzer, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(analyzersResource, "status", c.ns, analyzer), &v1beta1.Analyzer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Analyzer), err +} + +// Delete takes name of the analyzer and deletes it. Returns an error if one occurs. +func (c *FakeAnalyzers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(analyzersResource, c.ns, name), &v1beta1.Analyzer{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeAnalyzers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(analyzersResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta1.AnalyzerList{}) + return err +} + +// Patch applies the patch and returns the patched analyzer. +func (c *FakeAnalyzers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Analyzer, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(analyzersResource, c.ns, name, pt, data, subresources...), &v1beta1.Analyzer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Analyzer), err +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_collector.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_collector.go new file mode 100644 index 000000000..8ea3d5ec1 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_collector.go @@ -0,0 +1,141 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1" + 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" +) + +// FakeCollectors implements CollectorInterface +type FakeCollectors struct { + Fake *FakeTroubleshootV1beta1 + ns string +} + +var collectorsResource = schema.GroupVersionResource{Group: "troubleshoot.replicated.com", Version: "v1beta1", Resource: "collectors"} + +var collectorsKind = schema.GroupVersionKind{Group: "troubleshoot.replicated.com", Version: "v1beta1", Kind: "Collector"} + +// Get takes name of the collector, and returns the corresponding collector object, and an error if there is any. +func (c *FakeCollectors) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Collector, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(collectorsResource, c.ns, name), &v1beta1.Collector{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Collector), err +} + +// List takes label and field selectors, and returns the list of Collectors that match those selectors. +func (c *FakeCollectors) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CollectorList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(collectorsResource, collectorsKind, c.ns, opts), &v1beta1.CollectorList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.CollectorList{ListMeta: obj.(*v1beta1.CollectorList).ListMeta} + for _, item := range obj.(*v1beta1.CollectorList).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 collectors. +func (c *FakeCollectors) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(collectorsResource, c.ns, opts)) + +} + +// Create takes the representation of a collector and creates it. Returns the server's representation of the collector, and an error, if there is any. +func (c *FakeCollectors) Create(ctx context.Context, collector *v1beta1.Collector, opts v1.CreateOptions) (result *v1beta1.Collector, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(collectorsResource, c.ns, collector), &v1beta1.Collector{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Collector), err +} + +// Update takes the representation of a collector and updates it. Returns the server's representation of the collector, and an error, if there is any. +func (c *FakeCollectors) Update(ctx context.Context, collector *v1beta1.Collector, opts v1.UpdateOptions) (result *v1beta1.Collector, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(collectorsResource, c.ns, collector), &v1beta1.Collector{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Collector), 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 *FakeCollectors) UpdateStatus(ctx context.Context, collector *v1beta1.Collector, opts v1.UpdateOptions) (*v1beta1.Collector, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(collectorsResource, "status", c.ns, collector), &v1beta1.Collector{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Collector), err +} + +// Delete takes name of the collector and deletes it. Returns an error if one occurs. +func (c *FakeCollectors) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(collectorsResource, c.ns, name), &v1beta1.Collector{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeCollectors) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(collectorsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta1.CollectorList{}) + return err +} + +// Patch applies the patch and returns the patched collector. +func (c *FakeCollectors) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Collector, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(collectorsResource, c.ns, name, pt, data, subresources...), &v1beta1.Collector{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Collector), err +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_preflight.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_preflight.go new file mode 100644 index 000000000..9e2724708 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_preflight.go @@ -0,0 +1,141 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1" + 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" +) + +// FakePreflights implements PreflightInterface +type FakePreflights struct { + Fake *FakeTroubleshootV1beta1 + ns string +} + +var preflightsResource = schema.GroupVersionResource{Group: "troubleshoot.replicated.com", Version: "v1beta1", Resource: "preflights"} + +var preflightsKind = schema.GroupVersionKind{Group: "troubleshoot.replicated.com", Version: "v1beta1", Kind: "Preflight"} + +// Get takes name of the preflight, and returns the corresponding preflight object, and an error if there is any. +func (c *FakePreflights) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Preflight, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(preflightsResource, c.ns, name), &v1beta1.Preflight{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Preflight), err +} + +// List takes label and field selectors, and returns the list of Preflights that match those selectors. +func (c *FakePreflights) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.PreflightList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(preflightsResource, preflightsKind, c.ns, opts), &v1beta1.PreflightList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.PreflightList{ListMeta: obj.(*v1beta1.PreflightList).ListMeta} + for _, item := range obj.(*v1beta1.PreflightList).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 preflights. +func (c *FakePreflights) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(preflightsResource, c.ns, opts)) + +} + +// Create takes the representation of a preflight and creates it. Returns the server's representation of the preflight, and an error, if there is any. +func (c *FakePreflights) Create(ctx context.Context, preflight *v1beta1.Preflight, opts v1.CreateOptions) (result *v1beta1.Preflight, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(preflightsResource, c.ns, preflight), &v1beta1.Preflight{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Preflight), err +} + +// Update takes the representation of a preflight and updates it. Returns the server's representation of the preflight, and an error, if there is any. +func (c *FakePreflights) Update(ctx context.Context, preflight *v1beta1.Preflight, opts v1.UpdateOptions) (result *v1beta1.Preflight, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(preflightsResource, c.ns, preflight), &v1beta1.Preflight{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Preflight), 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 *FakePreflights) UpdateStatus(ctx context.Context, preflight *v1beta1.Preflight, opts v1.UpdateOptions) (*v1beta1.Preflight, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(preflightsResource, "status", c.ns, preflight), &v1beta1.Preflight{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Preflight), err +} + +// Delete takes name of the preflight and deletes it. Returns an error if one occurs. +func (c *FakePreflights) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(preflightsResource, c.ns, name), &v1beta1.Preflight{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakePreflights) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(preflightsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta1.PreflightList{}) + return err +} + +// Patch applies the patch and returns the patched preflight. +func (c *FakePreflights) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Preflight, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(preflightsResource, c.ns, name, pt, data, subresources...), &v1beta1.Preflight{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Preflight), err +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_redactor.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_redactor.go new file mode 100644 index 000000000..3109c7980 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_redactor.go @@ -0,0 +1,141 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1" + 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" +) + +// FakeRedactors implements RedactorInterface +type FakeRedactors struct { + Fake *FakeTroubleshootV1beta1 + ns string +} + +var redactorsResource = schema.GroupVersionResource{Group: "troubleshoot.replicated.com", Version: "v1beta1", Resource: "redactors"} + +var redactorsKind = schema.GroupVersionKind{Group: "troubleshoot.replicated.com", Version: "v1beta1", Kind: "Redactor"} + +// Get takes name of the redactor, and returns the corresponding redactor object, and an error if there is any. +func (c *FakeRedactors) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Redactor, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(redactorsResource, c.ns, name), &v1beta1.Redactor{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Redactor), err +} + +// List takes label and field selectors, and returns the list of Redactors that match those selectors. +func (c *FakeRedactors) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.RedactorList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(redactorsResource, redactorsKind, c.ns, opts), &v1beta1.RedactorList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.RedactorList{ListMeta: obj.(*v1beta1.RedactorList).ListMeta} + for _, item := range obj.(*v1beta1.RedactorList).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 redactors. +func (c *FakeRedactors) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(redactorsResource, c.ns, opts)) + +} + +// Create takes the representation of a redactor and creates it. Returns the server's representation of the redactor, and an error, if there is any. +func (c *FakeRedactors) Create(ctx context.Context, redactor *v1beta1.Redactor, opts v1.CreateOptions) (result *v1beta1.Redactor, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(redactorsResource, c.ns, redactor), &v1beta1.Redactor{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Redactor), err +} + +// Update takes the representation of a redactor and updates it. Returns the server's representation of the redactor, and an error, if there is any. +func (c *FakeRedactors) Update(ctx context.Context, redactor *v1beta1.Redactor, opts v1.UpdateOptions) (result *v1beta1.Redactor, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(redactorsResource, c.ns, redactor), &v1beta1.Redactor{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Redactor), 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 *FakeRedactors) UpdateStatus(ctx context.Context, redactor *v1beta1.Redactor, opts v1.UpdateOptions) (*v1beta1.Redactor, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(redactorsResource, "status", c.ns, redactor), &v1beta1.Redactor{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Redactor), err +} + +// Delete takes name of the redactor and deletes it. Returns an error if one occurs. +func (c *FakeRedactors) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(redactorsResource, c.ns, name), &v1beta1.Redactor{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeRedactors) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(redactorsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta1.RedactorList{}) + return err +} + +// Patch applies the patch and returns the patched redactor. +func (c *FakeRedactors) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Redactor, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(redactorsResource, c.ns, name, pt, data, subresources...), &v1beta1.Redactor{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Redactor), err +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_supportbundle.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_supportbundle.go new file mode 100644 index 000000000..6b4b8e495 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_supportbundle.go @@ -0,0 +1,141 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1" + 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" +) + +// FakeSupportBundles implements SupportBundleInterface +type FakeSupportBundles struct { + Fake *FakeTroubleshootV1beta1 + ns string +} + +var supportbundlesResource = schema.GroupVersionResource{Group: "troubleshoot.replicated.com", Version: "v1beta1", Resource: "supportbundles"} + +var supportbundlesKind = schema.GroupVersionKind{Group: "troubleshoot.replicated.com", Version: "v1beta1", Kind: "SupportBundle"} + +// Get takes name of the supportBundle, and returns the corresponding supportBundle object, and an error if there is any. +func (c *FakeSupportBundles) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.SupportBundle, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(supportbundlesResource, c.ns, name), &v1beta1.SupportBundle{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.SupportBundle), err +} + +// List takes label and field selectors, and returns the list of SupportBundles that match those selectors. +func (c *FakeSupportBundles) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.SupportBundleList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(supportbundlesResource, supportbundlesKind, c.ns, opts), &v1beta1.SupportBundleList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.SupportBundleList{ListMeta: obj.(*v1beta1.SupportBundleList).ListMeta} + for _, item := range obj.(*v1beta1.SupportBundleList).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 supportBundles. +func (c *FakeSupportBundles) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(supportbundlesResource, c.ns, opts)) + +} + +// Create takes the representation of a supportBundle and creates it. Returns the server's representation of the supportBundle, and an error, if there is any. +func (c *FakeSupportBundles) Create(ctx context.Context, supportBundle *v1beta1.SupportBundle, opts v1.CreateOptions) (result *v1beta1.SupportBundle, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(supportbundlesResource, c.ns, supportBundle), &v1beta1.SupportBundle{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.SupportBundle), err +} + +// Update takes the representation of a supportBundle and updates it. Returns the server's representation of the supportBundle, and an error, if there is any. +func (c *FakeSupportBundles) Update(ctx context.Context, supportBundle *v1beta1.SupportBundle, opts v1.UpdateOptions) (result *v1beta1.SupportBundle, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(supportbundlesResource, c.ns, supportBundle), &v1beta1.SupportBundle{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.SupportBundle), 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 *FakeSupportBundles) UpdateStatus(ctx context.Context, supportBundle *v1beta1.SupportBundle, opts v1.UpdateOptions) (*v1beta1.SupportBundle, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(supportbundlesResource, "status", c.ns, supportBundle), &v1beta1.SupportBundle{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.SupportBundle), err +} + +// Delete takes name of the supportBundle and deletes it. Returns an error if one occurs. +func (c *FakeSupportBundles) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(supportbundlesResource, c.ns, name), &v1beta1.SupportBundle{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeSupportBundles) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(supportbundlesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta1.SupportBundleList{}) + return err +} + +// Patch applies the patch and returns the patched supportBundle. +func (c *FakeSupportBundles) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.SupportBundle, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(supportbundlesResource, c.ns, name, pt, data, subresources...), &v1beta1.SupportBundle{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.SupportBundle), err +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_troubleshoot_client.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_troubleshoot_client.go new file mode 100644 index 000000000..5f76d3eec --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/fake/fake_troubleshoot_client.go @@ -0,0 +1,55 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1beta1 "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeTroubleshootV1beta1 struct { + *testing.Fake +} + +func (c *FakeTroubleshootV1beta1) Analyzers(namespace string) v1beta1.AnalyzerInterface { + return &FakeAnalyzers{c, namespace} +} + +func (c *FakeTroubleshootV1beta1) Collectors(namespace string) v1beta1.CollectorInterface { + return &FakeCollectors{c, namespace} +} + +func (c *FakeTroubleshootV1beta1) Preflights(namespace string) v1beta1.PreflightInterface { + return &FakePreflights{c, namespace} +} + +func (c *FakeTroubleshootV1beta1) Redactors(namespace string) v1beta1.RedactorInterface { + return &FakeRedactors{c, namespace} +} + +func (c *FakeTroubleshootV1beta1) SupportBundles(namespace string) v1beta1.SupportBundleInterface { + return &FakeSupportBundles{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeTroubleshootV1beta1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/generated_expansion.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/generated_expansion.go new file mode 100644 index 000000000..a83babe39 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/generated_expansion.go @@ -0,0 +1,28 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +type AnalyzerExpansion interface{} + +type CollectorExpansion interface{} + +type PreflightExpansion interface{} + +type RedactorExpansion interface{} + +type SupportBundleExpansion interface{} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/preflight.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/preflight.go new file mode 100644 index 000000000..774c77fc1 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/preflight.go @@ -0,0 +1,194 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + "time" + + v1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1" + scheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/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" +) + +// PreflightsGetter has a method to return a PreflightInterface. +// A group's client should implement this interface. +type PreflightsGetter interface { + Preflights(namespace string) PreflightInterface +} + +// PreflightInterface has methods to work with Preflight resources. +type PreflightInterface interface { + Create(ctx context.Context, preflight *v1beta1.Preflight, opts v1.CreateOptions) (*v1beta1.Preflight, error) + Update(ctx context.Context, preflight *v1beta1.Preflight, opts v1.UpdateOptions) (*v1beta1.Preflight, error) + UpdateStatus(ctx context.Context, preflight *v1beta1.Preflight, opts v1.UpdateOptions) (*v1beta1.Preflight, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.Preflight, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.PreflightList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Preflight, err error) + PreflightExpansion +} + +// preflights implements PreflightInterface +type preflights struct { + client rest.Interface + ns string +} + +// newPreflights returns a Preflights +func newPreflights(c *TroubleshootV1beta1Client, namespace string) *preflights { + return &preflights{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the preflight, and returns the corresponding preflight object, and an error if there is any. +func (c *preflights) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Preflight, err error) { + result = &v1beta1.Preflight{} + err = c.client.Get(). + Namespace(c.ns). + Resource("preflights"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Preflights that match those selectors. +func (c *preflights) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.PreflightList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.PreflightList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("preflights"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested preflights. +func (c *preflights) Watch(ctx context.Context, 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("preflights"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a preflight and creates it. Returns the server's representation of the preflight, and an error, if there is any. +func (c *preflights) Create(ctx context.Context, preflight *v1beta1.Preflight, opts v1.CreateOptions) (result *v1beta1.Preflight, err error) { + result = &v1beta1.Preflight{} + err = c.client.Post(). + Namespace(c.ns). + Resource("preflights"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(preflight). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a preflight and updates it. Returns the server's representation of the preflight, and an error, if there is any. +func (c *preflights) Update(ctx context.Context, preflight *v1beta1.Preflight, opts v1.UpdateOptions) (result *v1beta1.Preflight, err error) { + result = &v1beta1.Preflight{} + err = c.client.Put(). + Namespace(c.ns). + Resource("preflights"). + Name(preflight.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(preflight). + Do(ctx). + 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 *preflights) UpdateStatus(ctx context.Context, preflight *v1beta1.Preflight, opts v1.UpdateOptions) (result *v1beta1.Preflight, err error) { + result = &v1beta1.Preflight{} + err = c.client.Put(). + Namespace(c.ns). + Resource("preflights"). + Name(preflight.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(preflight). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the preflight and deletes it. Returns an error if one occurs. +func (c *preflights) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("preflights"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *preflights) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("preflights"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched preflight. +func (c *preflights) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Preflight, err error) { + result = &v1beta1.Preflight{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("preflights"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/redactor.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/redactor.go new file mode 100644 index 000000000..f8df5b266 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/redactor.go @@ -0,0 +1,194 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + "time" + + v1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1" + scheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/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" +) + +// RedactorsGetter has a method to return a RedactorInterface. +// A group's client should implement this interface. +type RedactorsGetter interface { + Redactors(namespace string) RedactorInterface +} + +// RedactorInterface has methods to work with Redactor resources. +type RedactorInterface interface { + Create(ctx context.Context, redactor *v1beta1.Redactor, opts v1.CreateOptions) (*v1beta1.Redactor, error) + Update(ctx context.Context, redactor *v1beta1.Redactor, opts v1.UpdateOptions) (*v1beta1.Redactor, error) + UpdateStatus(ctx context.Context, redactor *v1beta1.Redactor, opts v1.UpdateOptions) (*v1beta1.Redactor, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.Redactor, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.RedactorList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Redactor, err error) + RedactorExpansion +} + +// redactors implements RedactorInterface +type redactors struct { + client rest.Interface + ns string +} + +// newRedactors returns a Redactors +func newRedactors(c *TroubleshootV1beta1Client, namespace string) *redactors { + return &redactors{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the redactor, and returns the corresponding redactor object, and an error if there is any. +func (c *redactors) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Redactor, err error) { + result = &v1beta1.Redactor{} + err = c.client.Get(). + Namespace(c.ns). + Resource("redactors"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Redactors that match those selectors. +func (c *redactors) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.RedactorList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.RedactorList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("redactors"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested redactors. +func (c *redactors) Watch(ctx context.Context, 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("redactors"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a redactor and creates it. Returns the server's representation of the redactor, and an error, if there is any. +func (c *redactors) Create(ctx context.Context, redactor *v1beta1.Redactor, opts v1.CreateOptions) (result *v1beta1.Redactor, err error) { + result = &v1beta1.Redactor{} + err = c.client.Post(). + Namespace(c.ns). + Resource("redactors"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(redactor). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a redactor and updates it. Returns the server's representation of the redactor, and an error, if there is any. +func (c *redactors) Update(ctx context.Context, redactor *v1beta1.Redactor, opts v1.UpdateOptions) (result *v1beta1.Redactor, err error) { + result = &v1beta1.Redactor{} + err = c.client.Put(). + Namespace(c.ns). + Resource("redactors"). + Name(redactor.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(redactor). + Do(ctx). + 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 *redactors) UpdateStatus(ctx context.Context, redactor *v1beta1.Redactor, opts v1.UpdateOptions) (result *v1beta1.Redactor, err error) { + result = &v1beta1.Redactor{} + err = c.client.Put(). + Namespace(c.ns). + Resource("redactors"). + Name(redactor.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(redactor). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the redactor and deletes it. Returns an error if one occurs. +func (c *redactors) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("redactors"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *redactors) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("redactors"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched redactor. +func (c *redactors) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Redactor, err error) { + result = &v1beta1.Redactor{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("redactors"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/supportbundle.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/supportbundle.go new file mode 100644 index 000000000..133b4c3af --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/supportbundle.go @@ -0,0 +1,194 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + "time" + + v1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1" + scheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/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" +) + +// SupportBundlesGetter has a method to return a SupportBundleInterface. +// A group's client should implement this interface. +type SupportBundlesGetter interface { + SupportBundles(namespace string) SupportBundleInterface +} + +// SupportBundleInterface has methods to work with SupportBundle resources. +type SupportBundleInterface interface { + Create(ctx context.Context, supportBundle *v1beta1.SupportBundle, opts v1.CreateOptions) (*v1beta1.SupportBundle, error) + Update(ctx context.Context, supportBundle *v1beta1.SupportBundle, opts v1.UpdateOptions) (*v1beta1.SupportBundle, error) + UpdateStatus(ctx context.Context, supportBundle *v1beta1.SupportBundle, opts v1.UpdateOptions) (*v1beta1.SupportBundle, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.SupportBundle, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.SupportBundleList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.SupportBundle, err error) + SupportBundleExpansion +} + +// supportBundles implements SupportBundleInterface +type supportBundles struct { + client rest.Interface + ns string +} + +// newSupportBundles returns a SupportBundles +func newSupportBundles(c *TroubleshootV1beta1Client, namespace string) *supportBundles { + return &supportBundles{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the supportBundle, and returns the corresponding supportBundle object, and an error if there is any. +func (c *supportBundles) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.SupportBundle, err error) { + result = &v1beta1.SupportBundle{} + err = c.client.Get(). + Namespace(c.ns). + Resource("supportbundles"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SupportBundles that match those selectors. +func (c *supportBundles) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.SupportBundleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.SupportBundleList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("supportbundles"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested supportBundles. +func (c *supportBundles) Watch(ctx context.Context, 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("supportbundles"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a supportBundle and creates it. Returns the server's representation of the supportBundle, and an error, if there is any. +func (c *supportBundles) Create(ctx context.Context, supportBundle *v1beta1.SupportBundle, opts v1.CreateOptions) (result *v1beta1.SupportBundle, err error) { + result = &v1beta1.SupportBundle{} + err = c.client.Post(). + Namespace(c.ns). + Resource("supportbundles"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(supportBundle). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a supportBundle and updates it. Returns the server's representation of the supportBundle, and an error, if there is any. +func (c *supportBundles) Update(ctx context.Context, supportBundle *v1beta1.SupportBundle, opts v1.UpdateOptions) (result *v1beta1.SupportBundle, err error) { + result = &v1beta1.SupportBundle{} + err = c.client.Put(). + Namespace(c.ns). + Resource("supportbundles"). + Name(supportBundle.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(supportBundle). + Do(ctx). + 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 *supportBundles) UpdateStatus(ctx context.Context, supportBundle *v1beta1.SupportBundle, opts v1.UpdateOptions) (result *v1beta1.SupportBundle, err error) { + result = &v1beta1.SupportBundle{} + err = c.client.Put(). + Namespace(c.ns). + Resource("supportbundles"). + Name(supportBundle.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(supportBundle). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the supportBundle and deletes it. Returns an error if one occurs. +func (c *supportBundles) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("supportbundles"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *supportBundles) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("supportbundles"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched supportBundle. +func (c *supportBundles) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.SupportBundle, err error) { + result = &v1beta1.SupportBundle{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("supportbundles"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/troubleshoot_client.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/troubleshoot_client.go new file mode 100644 index 000000000..8b5b3299b --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta1/troubleshoot_client.go @@ -0,0 +1,108 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1" + "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme" + rest "k8s.io/client-go/rest" +) + +type TroubleshootV1beta1Interface interface { + RESTClient() rest.Interface + AnalyzersGetter + CollectorsGetter + PreflightsGetter + RedactorsGetter + SupportBundlesGetter +} + +// TroubleshootV1beta1Client is used to interact with features provided by the troubleshoot.replicated.com group. +type TroubleshootV1beta1Client struct { + restClient rest.Interface +} + +func (c *TroubleshootV1beta1Client) Analyzers(namespace string) AnalyzerInterface { + return newAnalyzers(c, namespace) +} + +func (c *TroubleshootV1beta1Client) Collectors(namespace string) CollectorInterface { + return newCollectors(c, namespace) +} + +func (c *TroubleshootV1beta1Client) Preflights(namespace string) PreflightInterface { + return newPreflights(c, namespace) +} + +func (c *TroubleshootV1beta1Client) Redactors(namespace string) RedactorInterface { + return newRedactors(c, namespace) +} + +func (c *TroubleshootV1beta1Client) SupportBundles(namespace string) SupportBundleInterface { + return newSupportBundles(c, namespace) +} + +// NewForConfig creates a new TroubleshootV1beta1Client for the given config. +func NewForConfig(c *rest.Config) (*TroubleshootV1beta1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &TroubleshootV1beta1Client{client}, nil +} + +// NewForConfigOrDie creates a new TroubleshootV1beta1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *TroubleshootV1beta1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new TroubleshootV1beta1Client for the given RESTClient. +func New(c rest.Interface) *TroubleshootV1beta1Client { + return &TroubleshootV1beta1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1beta1.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 *TroubleshootV1beta1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/analyzer.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/analyzer.go new file mode 100644 index 000000000..10c092afd --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/analyzer.go @@ -0,0 +1,194 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "context" + "time" + + v1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + scheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/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" +) + +// AnalyzersGetter has a method to return a AnalyzerInterface. +// A group's client should implement this interface. +type AnalyzersGetter interface { + Analyzers(namespace string) AnalyzerInterface +} + +// AnalyzerInterface has methods to work with Analyzer resources. +type AnalyzerInterface interface { + Create(ctx context.Context, analyzer *v1beta2.Analyzer, opts v1.CreateOptions) (*v1beta2.Analyzer, error) + Update(ctx context.Context, analyzer *v1beta2.Analyzer, opts v1.UpdateOptions) (*v1beta2.Analyzer, error) + UpdateStatus(ctx context.Context, analyzer *v1beta2.Analyzer, opts v1.UpdateOptions) (*v1beta2.Analyzer, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta2.Analyzer, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta2.AnalyzerList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.Analyzer, err error) + AnalyzerExpansion +} + +// analyzers implements AnalyzerInterface +type analyzers struct { + client rest.Interface + ns string +} + +// newAnalyzers returns a Analyzers +func newAnalyzers(c *TroubleshootV1beta2Client, namespace string) *analyzers { + return &analyzers{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the analyzer, and returns the corresponding analyzer object, and an error if there is any. +func (c *analyzers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.Analyzer, err error) { + result = &v1beta2.Analyzer{} + err = c.client.Get(). + Namespace(c.ns). + Resource("analyzers"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Analyzers that match those selectors. +func (c *analyzers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.AnalyzerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.AnalyzerList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("analyzers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested analyzers. +func (c *analyzers) Watch(ctx context.Context, 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("analyzers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a analyzer and creates it. Returns the server's representation of the analyzer, and an error, if there is any. +func (c *analyzers) Create(ctx context.Context, analyzer *v1beta2.Analyzer, opts v1.CreateOptions) (result *v1beta2.Analyzer, err error) { + result = &v1beta2.Analyzer{} + err = c.client.Post(). + Namespace(c.ns). + Resource("analyzers"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(analyzer). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a analyzer and updates it. Returns the server's representation of the analyzer, and an error, if there is any. +func (c *analyzers) Update(ctx context.Context, analyzer *v1beta2.Analyzer, opts v1.UpdateOptions) (result *v1beta2.Analyzer, err error) { + result = &v1beta2.Analyzer{} + err = c.client.Put(). + Namespace(c.ns). + Resource("analyzers"). + Name(analyzer.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(analyzer). + Do(ctx). + 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 *analyzers) UpdateStatus(ctx context.Context, analyzer *v1beta2.Analyzer, opts v1.UpdateOptions) (result *v1beta2.Analyzer, err error) { + result = &v1beta2.Analyzer{} + err = c.client.Put(). + Namespace(c.ns). + Resource("analyzers"). + Name(analyzer.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(analyzer). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the analyzer and deletes it. Returns an error if one occurs. +func (c *analyzers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("analyzers"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *analyzers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("analyzers"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched analyzer. +func (c *analyzers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.Analyzer, err error) { + result = &v1beta2.Analyzer{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("analyzers"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/collector.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/collector.go new file mode 100644 index 000000000..96f95c482 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/collector.go @@ -0,0 +1,194 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "context" + "time" + + v1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + scheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/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" +) + +// CollectorsGetter has a method to return a CollectorInterface. +// A group's client should implement this interface. +type CollectorsGetter interface { + Collectors(namespace string) CollectorInterface +} + +// CollectorInterface has methods to work with Collector resources. +type CollectorInterface interface { + Create(ctx context.Context, collector *v1beta2.Collector, opts v1.CreateOptions) (*v1beta2.Collector, error) + Update(ctx context.Context, collector *v1beta2.Collector, opts v1.UpdateOptions) (*v1beta2.Collector, error) + UpdateStatus(ctx context.Context, collector *v1beta2.Collector, opts v1.UpdateOptions) (*v1beta2.Collector, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta2.Collector, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta2.CollectorList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.Collector, err error) + CollectorExpansion +} + +// collectors implements CollectorInterface +type collectors struct { + client rest.Interface + ns string +} + +// newCollectors returns a Collectors +func newCollectors(c *TroubleshootV1beta2Client, namespace string) *collectors { + return &collectors{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the collector, and returns the corresponding collector object, and an error if there is any. +func (c *collectors) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.Collector, err error) { + result = &v1beta2.Collector{} + err = c.client.Get(). + Namespace(c.ns). + Resource("collectors"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Collectors that match those selectors. +func (c *collectors) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.CollectorList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.CollectorList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("collectors"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested collectors. +func (c *collectors) Watch(ctx context.Context, 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("collectors"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a collector and creates it. Returns the server's representation of the collector, and an error, if there is any. +func (c *collectors) Create(ctx context.Context, collector *v1beta2.Collector, opts v1.CreateOptions) (result *v1beta2.Collector, err error) { + result = &v1beta2.Collector{} + err = c.client.Post(). + Namespace(c.ns). + Resource("collectors"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(collector). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a collector and updates it. Returns the server's representation of the collector, and an error, if there is any. +func (c *collectors) Update(ctx context.Context, collector *v1beta2.Collector, opts v1.UpdateOptions) (result *v1beta2.Collector, err error) { + result = &v1beta2.Collector{} + err = c.client.Put(). + Namespace(c.ns). + Resource("collectors"). + Name(collector.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(collector). + Do(ctx). + 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 *collectors) UpdateStatus(ctx context.Context, collector *v1beta2.Collector, opts v1.UpdateOptions) (result *v1beta2.Collector, err error) { + result = &v1beta2.Collector{} + err = c.client.Put(). + Namespace(c.ns). + Resource("collectors"). + Name(collector.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(collector). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the collector and deletes it. Returns an error if one occurs. +func (c *collectors) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("collectors"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *collectors) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("collectors"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched collector. +func (c *collectors) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.Collector, err error) { + result = &v1beta2.Collector{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("collectors"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/doc.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/doc.go new file mode 100644 index 000000000..828ed2560 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta2 diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/doc.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/doc.go new file mode 100644 index 000000000..0767328a9 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_analyzer.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_analyzer.go new file mode 100644 index 000000000..b17f45840 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_analyzer.go @@ -0,0 +1,141 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + 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" +) + +// FakeAnalyzers implements AnalyzerInterface +type FakeAnalyzers struct { + Fake *FakeTroubleshootV1beta2 + ns string +} + +var analyzersResource = schema.GroupVersionResource{Group: "troubleshoot.sh", Version: "v1beta2", Resource: "analyzers"} + +var analyzersKind = schema.GroupVersionKind{Group: "troubleshoot.sh", Version: "v1beta2", Kind: "Analyzer"} + +// Get takes name of the analyzer, and returns the corresponding analyzer object, and an error if there is any. +func (c *FakeAnalyzers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.Analyzer, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(analyzersResource, c.ns, name), &v1beta2.Analyzer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Analyzer), err +} + +// List takes label and field selectors, and returns the list of Analyzers that match those selectors. +func (c *FakeAnalyzers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.AnalyzerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(analyzersResource, analyzersKind, c.ns, opts), &v1beta2.AnalyzerList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta2.AnalyzerList{ListMeta: obj.(*v1beta2.AnalyzerList).ListMeta} + for _, item := range obj.(*v1beta2.AnalyzerList).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 analyzers. +func (c *FakeAnalyzers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(analyzersResource, c.ns, opts)) + +} + +// Create takes the representation of a analyzer and creates it. Returns the server's representation of the analyzer, and an error, if there is any. +func (c *FakeAnalyzers) Create(ctx context.Context, analyzer *v1beta2.Analyzer, opts v1.CreateOptions) (result *v1beta2.Analyzer, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(analyzersResource, c.ns, analyzer), &v1beta2.Analyzer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Analyzer), err +} + +// Update takes the representation of a analyzer and updates it. Returns the server's representation of the analyzer, and an error, if there is any. +func (c *FakeAnalyzers) Update(ctx context.Context, analyzer *v1beta2.Analyzer, opts v1.UpdateOptions) (result *v1beta2.Analyzer, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(analyzersResource, c.ns, analyzer), &v1beta2.Analyzer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Analyzer), 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 *FakeAnalyzers) UpdateStatus(ctx context.Context, analyzer *v1beta2.Analyzer, opts v1.UpdateOptions) (*v1beta2.Analyzer, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(analyzersResource, "status", c.ns, analyzer), &v1beta2.Analyzer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Analyzer), err +} + +// Delete takes name of the analyzer and deletes it. Returns an error if one occurs. +func (c *FakeAnalyzers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(analyzersResource, c.ns, name), &v1beta2.Analyzer{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeAnalyzers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(analyzersResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta2.AnalyzerList{}) + return err +} + +// Patch applies the patch and returns the patched analyzer. +func (c *FakeAnalyzers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.Analyzer, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(analyzersResource, c.ns, name, pt, data, subresources...), &v1beta2.Analyzer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Analyzer), err +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_collector.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_collector.go new file mode 100644 index 000000000..d352dd092 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_collector.go @@ -0,0 +1,141 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + 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" +) + +// FakeCollectors implements CollectorInterface +type FakeCollectors struct { + Fake *FakeTroubleshootV1beta2 + ns string +} + +var collectorsResource = schema.GroupVersionResource{Group: "troubleshoot.sh", Version: "v1beta2", Resource: "collectors"} + +var collectorsKind = schema.GroupVersionKind{Group: "troubleshoot.sh", Version: "v1beta2", Kind: "Collector"} + +// Get takes name of the collector, and returns the corresponding collector object, and an error if there is any. +func (c *FakeCollectors) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.Collector, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(collectorsResource, c.ns, name), &v1beta2.Collector{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Collector), err +} + +// List takes label and field selectors, and returns the list of Collectors that match those selectors. +func (c *FakeCollectors) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.CollectorList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(collectorsResource, collectorsKind, c.ns, opts), &v1beta2.CollectorList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta2.CollectorList{ListMeta: obj.(*v1beta2.CollectorList).ListMeta} + for _, item := range obj.(*v1beta2.CollectorList).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 collectors. +func (c *FakeCollectors) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(collectorsResource, c.ns, opts)) + +} + +// Create takes the representation of a collector and creates it. Returns the server's representation of the collector, and an error, if there is any. +func (c *FakeCollectors) Create(ctx context.Context, collector *v1beta2.Collector, opts v1.CreateOptions) (result *v1beta2.Collector, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(collectorsResource, c.ns, collector), &v1beta2.Collector{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Collector), err +} + +// Update takes the representation of a collector and updates it. Returns the server's representation of the collector, and an error, if there is any. +func (c *FakeCollectors) Update(ctx context.Context, collector *v1beta2.Collector, opts v1.UpdateOptions) (result *v1beta2.Collector, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(collectorsResource, c.ns, collector), &v1beta2.Collector{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Collector), 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 *FakeCollectors) UpdateStatus(ctx context.Context, collector *v1beta2.Collector, opts v1.UpdateOptions) (*v1beta2.Collector, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(collectorsResource, "status", c.ns, collector), &v1beta2.Collector{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Collector), err +} + +// Delete takes name of the collector and deletes it. Returns an error if one occurs. +func (c *FakeCollectors) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(collectorsResource, c.ns, name), &v1beta2.Collector{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeCollectors) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(collectorsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta2.CollectorList{}) + return err +} + +// Patch applies the patch and returns the patched collector. +func (c *FakeCollectors) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.Collector, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(collectorsResource, c.ns, name, pt, data, subresources...), &v1beta2.Collector{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Collector), err +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_hostpreflight.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_hostpreflight.go new file mode 100644 index 000000000..761fd6d8c --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_hostpreflight.go @@ -0,0 +1,141 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + 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" +) + +// FakeHostPreflights implements HostPreflightInterface +type FakeHostPreflights struct { + Fake *FakeTroubleshootV1beta2 + ns string +} + +var hostpreflightsResource = schema.GroupVersionResource{Group: "troubleshoot.sh", Version: "v1beta2", Resource: "hostpreflights"} + +var hostpreflightsKind = schema.GroupVersionKind{Group: "troubleshoot.sh", Version: "v1beta2", Kind: "HostPreflight"} + +// Get takes name of the hostPreflight, and returns the corresponding hostPreflight object, and an error if there is any. +func (c *FakeHostPreflights) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.HostPreflight, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(hostpreflightsResource, c.ns, name), &v1beta2.HostPreflight{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.HostPreflight), err +} + +// List takes label and field selectors, and returns the list of HostPreflights that match those selectors. +func (c *FakeHostPreflights) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.HostPreflightList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(hostpreflightsResource, hostpreflightsKind, c.ns, opts), &v1beta2.HostPreflightList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta2.HostPreflightList{ListMeta: obj.(*v1beta2.HostPreflightList).ListMeta} + for _, item := range obj.(*v1beta2.HostPreflightList).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 hostPreflights. +func (c *FakeHostPreflights) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(hostpreflightsResource, c.ns, opts)) + +} + +// Create takes the representation of a hostPreflight and creates it. Returns the server's representation of the hostPreflight, and an error, if there is any. +func (c *FakeHostPreflights) Create(ctx context.Context, hostPreflight *v1beta2.HostPreflight, opts v1.CreateOptions) (result *v1beta2.HostPreflight, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(hostpreflightsResource, c.ns, hostPreflight), &v1beta2.HostPreflight{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.HostPreflight), err +} + +// Update takes the representation of a hostPreflight and updates it. Returns the server's representation of the hostPreflight, and an error, if there is any. +func (c *FakeHostPreflights) Update(ctx context.Context, hostPreflight *v1beta2.HostPreflight, opts v1.UpdateOptions) (result *v1beta2.HostPreflight, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(hostpreflightsResource, c.ns, hostPreflight), &v1beta2.HostPreflight{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.HostPreflight), 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 *FakeHostPreflights) UpdateStatus(ctx context.Context, hostPreflight *v1beta2.HostPreflight, opts v1.UpdateOptions) (*v1beta2.HostPreflight, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(hostpreflightsResource, "status", c.ns, hostPreflight), &v1beta2.HostPreflight{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.HostPreflight), err +} + +// Delete takes name of the hostPreflight and deletes it. Returns an error if one occurs. +func (c *FakeHostPreflights) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(hostpreflightsResource, c.ns, name), &v1beta2.HostPreflight{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeHostPreflights) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(hostpreflightsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta2.HostPreflightList{}) + return err +} + +// Patch applies the patch and returns the patched hostPreflight. +func (c *FakeHostPreflights) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.HostPreflight, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(hostpreflightsResource, c.ns, name, pt, data, subresources...), &v1beta2.HostPreflight{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.HostPreflight), err +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_preflight.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_preflight.go new file mode 100644 index 000000000..67ee46668 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_preflight.go @@ -0,0 +1,141 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + 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" +) + +// FakePreflights implements PreflightInterface +type FakePreflights struct { + Fake *FakeTroubleshootV1beta2 + ns string +} + +var preflightsResource = schema.GroupVersionResource{Group: "troubleshoot.sh", Version: "v1beta2", Resource: "preflights"} + +var preflightsKind = schema.GroupVersionKind{Group: "troubleshoot.sh", Version: "v1beta2", Kind: "Preflight"} + +// Get takes name of the preflight, and returns the corresponding preflight object, and an error if there is any. +func (c *FakePreflights) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.Preflight, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(preflightsResource, c.ns, name), &v1beta2.Preflight{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Preflight), err +} + +// List takes label and field selectors, and returns the list of Preflights that match those selectors. +func (c *FakePreflights) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.PreflightList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(preflightsResource, preflightsKind, c.ns, opts), &v1beta2.PreflightList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta2.PreflightList{ListMeta: obj.(*v1beta2.PreflightList).ListMeta} + for _, item := range obj.(*v1beta2.PreflightList).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 preflights. +func (c *FakePreflights) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(preflightsResource, c.ns, opts)) + +} + +// Create takes the representation of a preflight and creates it. Returns the server's representation of the preflight, and an error, if there is any. +func (c *FakePreflights) Create(ctx context.Context, preflight *v1beta2.Preflight, opts v1.CreateOptions) (result *v1beta2.Preflight, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(preflightsResource, c.ns, preflight), &v1beta2.Preflight{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Preflight), err +} + +// Update takes the representation of a preflight and updates it. Returns the server's representation of the preflight, and an error, if there is any. +func (c *FakePreflights) Update(ctx context.Context, preflight *v1beta2.Preflight, opts v1.UpdateOptions) (result *v1beta2.Preflight, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(preflightsResource, c.ns, preflight), &v1beta2.Preflight{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Preflight), 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 *FakePreflights) UpdateStatus(ctx context.Context, preflight *v1beta2.Preflight, opts v1.UpdateOptions) (*v1beta2.Preflight, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(preflightsResource, "status", c.ns, preflight), &v1beta2.Preflight{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Preflight), err +} + +// Delete takes name of the preflight and deletes it. Returns an error if one occurs. +func (c *FakePreflights) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(preflightsResource, c.ns, name), &v1beta2.Preflight{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakePreflights) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(preflightsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta2.PreflightList{}) + return err +} + +// Patch applies the patch and returns the patched preflight. +func (c *FakePreflights) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.Preflight, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(preflightsResource, c.ns, name, pt, data, subresources...), &v1beta2.Preflight{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Preflight), err +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_redactor.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_redactor.go new file mode 100644 index 000000000..433496600 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_redactor.go @@ -0,0 +1,141 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + 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" +) + +// FakeRedactors implements RedactorInterface +type FakeRedactors struct { + Fake *FakeTroubleshootV1beta2 + ns string +} + +var redactorsResource = schema.GroupVersionResource{Group: "troubleshoot.sh", Version: "v1beta2", Resource: "redactors"} + +var redactorsKind = schema.GroupVersionKind{Group: "troubleshoot.sh", Version: "v1beta2", Kind: "Redactor"} + +// Get takes name of the redactor, and returns the corresponding redactor object, and an error if there is any. +func (c *FakeRedactors) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.Redactor, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(redactorsResource, c.ns, name), &v1beta2.Redactor{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Redactor), err +} + +// List takes label and field selectors, and returns the list of Redactors that match those selectors. +func (c *FakeRedactors) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.RedactorList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(redactorsResource, redactorsKind, c.ns, opts), &v1beta2.RedactorList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta2.RedactorList{ListMeta: obj.(*v1beta2.RedactorList).ListMeta} + for _, item := range obj.(*v1beta2.RedactorList).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 redactors. +func (c *FakeRedactors) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(redactorsResource, c.ns, opts)) + +} + +// Create takes the representation of a redactor and creates it. Returns the server's representation of the redactor, and an error, if there is any. +func (c *FakeRedactors) Create(ctx context.Context, redactor *v1beta2.Redactor, opts v1.CreateOptions) (result *v1beta2.Redactor, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(redactorsResource, c.ns, redactor), &v1beta2.Redactor{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Redactor), err +} + +// Update takes the representation of a redactor and updates it. Returns the server's representation of the redactor, and an error, if there is any. +func (c *FakeRedactors) Update(ctx context.Context, redactor *v1beta2.Redactor, opts v1.UpdateOptions) (result *v1beta2.Redactor, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(redactorsResource, c.ns, redactor), &v1beta2.Redactor{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Redactor), 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 *FakeRedactors) UpdateStatus(ctx context.Context, redactor *v1beta2.Redactor, opts v1.UpdateOptions) (*v1beta2.Redactor, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(redactorsResource, "status", c.ns, redactor), &v1beta2.Redactor{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Redactor), err +} + +// Delete takes name of the redactor and deletes it. Returns an error if one occurs. +func (c *FakeRedactors) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(redactorsResource, c.ns, name), &v1beta2.Redactor{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeRedactors) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(redactorsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta2.RedactorList{}) + return err +} + +// Patch applies the patch and returns the patched redactor. +func (c *FakeRedactors) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.Redactor, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(redactorsResource, c.ns, name, pt, data, subresources...), &v1beta2.Redactor{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.Redactor), err +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_supportbundle.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_supportbundle.go new file mode 100644 index 000000000..e5cb8ad8f --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_supportbundle.go @@ -0,0 +1,141 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + 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" +) + +// FakeSupportBundles implements SupportBundleInterface +type FakeSupportBundles struct { + Fake *FakeTroubleshootV1beta2 + ns string +} + +var supportbundlesResource = schema.GroupVersionResource{Group: "troubleshoot.sh", Version: "v1beta2", Resource: "supportbundles"} + +var supportbundlesKind = schema.GroupVersionKind{Group: "troubleshoot.sh", Version: "v1beta2", Kind: "SupportBundle"} + +// Get takes name of the supportBundle, and returns the corresponding supportBundle object, and an error if there is any. +func (c *FakeSupportBundles) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.SupportBundle, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(supportbundlesResource, c.ns, name), &v1beta2.SupportBundle{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.SupportBundle), err +} + +// List takes label and field selectors, and returns the list of SupportBundles that match those selectors. +func (c *FakeSupportBundles) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.SupportBundleList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(supportbundlesResource, supportbundlesKind, c.ns, opts), &v1beta2.SupportBundleList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta2.SupportBundleList{ListMeta: obj.(*v1beta2.SupportBundleList).ListMeta} + for _, item := range obj.(*v1beta2.SupportBundleList).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 supportBundles. +func (c *FakeSupportBundles) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(supportbundlesResource, c.ns, opts)) + +} + +// Create takes the representation of a supportBundle and creates it. Returns the server's representation of the supportBundle, and an error, if there is any. +func (c *FakeSupportBundles) Create(ctx context.Context, supportBundle *v1beta2.SupportBundle, opts v1.CreateOptions) (result *v1beta2.SupportBundle, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(supportbundlesResource, c.ns, supportBundle), &v1beta2.SupportBundle{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.SupportBundle), err +} + +// Update takes the representation of a supportBundle and updates it. Returns the server's representation of the supportBundle, and an error, if there is any. +func (c *FakeSupportBundles) Update(ctx context.Context, supportBundle *v1beta2.SupportBundle, opts v1.UpdateOptions) (result *v1beta2.SupportBundle, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(supportbundlesResource, c.ns, supportBundle), &v1beta2.SupportBundle{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.SupportBundle), 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 *FakeSupportBundles) UpdateStatus(ctx context.Context, supportBundle *v1beta2.SupportBundle, opts v1.UpdateOptions) (*v1beta2.SupportBundle, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(supportbundlesResource, "status", c.ns, supportBundle), &v1beta2.SupportBundle{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.SupportBundle), err +} + +// Delete takes name of the supportBundle and deletes it. Returns an error if one occurs. +func (c *FakeSupportBundles) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(supportbundlesResource, c.ns, name), &v1beta2.SupportBundle{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeSupportBundles) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(supportbundlesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta2.SupportBundleList{}) + return err +} + +// Patch applies the patch and returns the patched supportBundle. +func (c *FakeSupportBundles) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.SupportBundle, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(supportbundlesResource, c.ns, name, pt, data, subresources...), &v1beta2.SupportBundle{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.SupportBundle), err +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_troubleshoot_client.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_troubleshoot_client.go new file mode 100644 index 000000000..3e11fbec9 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/fake/fake_troubleshoot_client.go @@ -0,0 +1,59 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1beta2 "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeTroubleshootV1beta2 struct { + *testing.Fake +} + +func (c *FakeTroubleshootV1beta2) Analyzers(namespace string) v1beta2.AnalyzerInterface { + return &FakeAnalyzers{c, namespace} +} + +func (c *FakeTroubleshootV1beta2) Collectors(namespace string) v1beta2.CollectorInterface { + return &FakeCollectors{c, namespace} +} + +func (c *FakeTroubleshootV1beta2) HostPreflights(namespace string) v1beta2.HostPreflightInterface { + return &FakeHostPreflights{c, namespace} +} + +func (c *FakeTroubleshootV1beta2) Preflights(namespace string) v1beta2.PreflightInterface { + return &FakePreflights{c, namespace} +} + +func (c *FakeTroubleshootV1beta2) Redactors(namespace string) v1beta2.RedactorInterface { + return &FakeRedactors{c, namespace} +} + +func (c *FakeTroubleshootV1beta2) SupportBundles(namespace string) v1beta2.SupportBundleInterface { + return &FakeSupportBundles{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeTroubleshootV1beta2) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/generated_expansion.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/generated_expansion.go new file mode 100644 index 000000000..0779c12fb --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/generated_expansion.go @@ -0,0 +1,30 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta2 + +type AnalyzerExpansion interface{} + +type CollectorExpansion interface{} + +type HostPreflightExpansion interface{} + +type PreflightExpansion interface{} + +type RedactorExpansion interface{} + +type SupportBundleExpansion interface{} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/hostpreflight.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/hostpreflight.go new file mode 100644 index 000000000..f360ea8ae --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/hostpreflight.go @@ -0,0 +1,194 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "context" + "time" + + v1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + scheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/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" +) + +// HostPreflightsGetter has a method to return a HostPreflightInterface. +// A group's client should implement this interface. +type HostPreflightsGetter interface { + HostPreflights(namespace string) HostPreflightInterface +} + +// HostPreflightInterface has methods to work with HostPreflight resources. +type HostPreflightInterface interface { + Create(ctx context.Context, hostPreflight *v1beta2.HostPreflight, opts v1.CreateOptions) (*v1beta2.HostPreflight, error) + Update(ctx context.Context, hostPreflight *v1beta2.HostPreflight, opts v1.UpdateOptions) (*v1beta2.HostPreflight, error) + UpdateStatus(ctx context.Context, hostPreflight *v1beta2.HostPreflight, opts v1.UpdateOptions) (*v1beta2.HostPreflight, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta2.HostPreflight, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta2.HostPreflightList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.HostPreflight, err error) + HostPreflightExpansion +} + +// hostPreflights implements HostPreflightInterface +type hostPreflights struct { + client rest.Interface + ns string +} + +// newHostPreflights returns a HostPreflights +func newHostPreflights(c *TroubleshootV1beta2Client, namespace string) *hostPreflights { + return &hostPreflights{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the hostPreflight, and returns the corresponding hostPreflight object, and an error if there is any. +func (c *hostPreflights) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.HostPreflight, err error) { + result = &v1beta2.HostPreflight{} + err = c.client.Get(). + Namespace(c.ns). + Resource("hostpreflights"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of HostPreflights that match those selectors. +func (c *hostPreflights) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.HostPreflightList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.HostPreflightList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("hostpreflights"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested hostPreflights. +func (c *hostPreflights) Watch(ctx context.Context, 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("hostpreflights"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a hostPreflight and creates it. Returns the server's representation of the hostPreflight, and an error, if there is any. +func (c *hostPreflights) Create(ctx context.Context, hostPreflight *v1beta2.HostPreflight, opts v1.CreateOptions) (result *v1beta2.HostPreflight, err error) { + result = &v1beta2.HostPreflight{} + err = c.client.Post(). + Namespace(c.ns). + Resource("hostpreflights"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(hostPreflight). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a hostPreflight and updates it. Returns the server's representation of the hostPreflight, and an error, if there is any. +func (c *hostPreflights) Update(ctx context.Context, hostPreflight *v1beta2.HostPreflight, opts v1.UpdateOptions) (result *v1beta2.HostPreflight, err error) { + result = &v1beta2.HostPreflight{} + err = c.client.Put(). + Namespace(c.ns). + Resource("hostpreflights"). + Name(hostPreflight.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(hostPreflight). + Do(ctx). + 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 *hostPreflights) UpdateStatus(ctx context.Context, hostPreflight *v1beta2.HostPreflight, opts v1.UpdateOptions) (result *v1beta2.HostPreflight, err error) { + result = &v1beta2.HostPreflight{} + err = c.client.Put(). + Namespace(c.ns). + Resource("hostpreflights"). + Name(hostPreflight.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(hostPreflight). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the hostPreflight and deletes it. Returns an error if one occurs. +func (c *hostPreflights) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("hostpreflights"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *hostPreflights) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("hostpreflights"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched hostPreflight. +func (c *hostPreflights) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.HostPreflight, err error) { + result = &v1beta2.HostPreflight{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("hostpreflights"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/preflight.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/preflight.go new file mode 100644 index 000000000..a519896ef --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/preflight.go @@ -0,0 +1,194 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "context" + "time" + + v1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + scheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/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" +) + +// PreflightsGetter has a method to return a PreflightInterface. +// A group's client should implement this interface. +type PreflightsGetter interface { + Preflights(namespace string) PreflightInterface +} + +// PreflightInterface has methods to work with Preflight resources. +type PreflightInterface interface { + Create(ctx context.Context, preflight *v1beta2.Preflight, opts v1.CreateOptions) (*v1beta2.Preflight, error) + Update(ctx context.Context, preflight *v1beta2.Preflight, opts v1.UpdateOptions) (*v1beta2.Preflight, error) + UpdateStatus(ctx context.Context, preflight *v1beta2.Preflight, opts v1.UpdateOptions) (*v1beta2.Preflight, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta2.Preflight, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta2.PreflightList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.Preflight, err error) + PreflightExpansion +} + +// preflights implements PreflightInterface +type preflights struct { + client rest.Interface + ns string +} + +// newPreflights returns a Preflights +func newPreflights(c *TroubleshootV1beta2Client, namespace string) *preflights { + return &preflights{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the preflight, and returns the corresponding preflight object, and an error if there is any. +func (c *preflights) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.Preflight, err error) { + result = &v1beta2.Preflight{} + err = c.client.Get(). + Namespace(c.ns). + Resource("preflights"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Preflights that match those selectors. +func (c *preflights) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.PreflightList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.PreflightList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("preflights"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested preflights. +func (c *preflights) Watch(ctx context.Context, 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("preflights"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a preflight and creates it. Returns the server's representation of the preflight, and an error, if there is any. +func (c *preflights) Create(ctx context.Context, preflight *v1beta2.Preflight, opts v1.CreateOptions) (result *v1beta2.Preflight, err error) { + result = &v1beta2.Preflight{} + err = c.client.Post(). + Namespace(c.ns). + Resource("preflights"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(preflight). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a preflight and updates it. Returns the server's representation of the preflight, and an error, if there is any. +func (c *preflights) Update(ctx context.Context, preflight *v1beta2.Preflight, opts v1.UpdateOptions) (result *v1beta2.Preflight, err error) { + result = &v1beta2.Preflight{} + err = c.client.Put(). + Namespace(c.ns). + Resource("preflights"). + Name(preflight.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(preflight). + Do(ctx). + 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 *preflights) UpdateStatus(ctx context.Context, preflight *v1beta2.Preflight, opts v1.UpdateOptions) (result *v1beta2.Preflight, err error) { + result = &v1beta2.Preflight{} + err = c.client.Put(). + Namespace(c.ns). + Resource("preflights"). + Name(preflight.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(preflight). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the preflight and deletes it. Returns an error if one occurs. +func (c *preflights) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("preflights"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *preflights) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("preflights"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched preflight. +func (c *preflights) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.Preflight, err error) { + result = &v1beta2.Preflight{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("preflights"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/redactor.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/redactor.go new file mode 100644 index 000000000..a82d200e3 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/redactor.go @@ -0,0 +1,194 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "context" + "time" + + v1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + scheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/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" +) + +// RedactorsGetter has a method to return a RedactorInterface. +// A group's client should implement this interface. +type RedactorsGetter interface { + Redactors(namespace string) RedactorInterface +} + +// RedactorInterface has methods to work with Redactor resources. +type RedactorInterface interface { + Create(ctx context.Context, redactor *v1beta2.Redactor, opts v1.CreateOptions) (*v1beta2.Redactor, error) + Update(ctx context.Context, redactor *v1beta2.Redactor, opts v1.UpdateOptions) (*v1beta2.Redactor, error) + UpdateStatus(ctx context.Context, redactor *v1beta2.Redactor, opts v1.UpdateOptions) (*v1beta2.Redactor, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta2.Redactor, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta2.RedactorList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.Redactor, err error) + RedactorExpansion +} + +// redactors implements RedactorInterface +type redactors struct { + client rest.Interface + ns string +} + +// newRedactors returns a Redactors +func newRedactors(c *TroubleshootV1beta2Client, namespace string) *redactors { + return &redactors{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the redactor, and returns the corresponding redactor object, and an error if there is any. +func (c *redactors) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.Redactor, err error) { + result = &v1beta2.Redactor{} + err = c.client.Get(). + Namespace(c.ns). + Resource("redactors"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Redactors that match those selectors. +func (c *redactors) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.RedactorList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.RedactorList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("redactors"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested redactors. +func (c *redactors) Watch(ctx context.Context, 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("redactors"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a redactor and creates it. Returns the server's representation of the redactor, and an error, if there is any. +func (c *redactors) Create(ctx context.Context, redactor *v1beta2.Redactor, opts v1.CreateOptions) (result *v1beta2.Redactor, err error) { + result = &v1beta2.Redactor{} + err = c.client.Post(). + Namespace(c.ns). + Resource("redactors"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(redactor). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a redactor and updates it. Returns the server's representation of the redactor, and an error, if there is any. +func (c *redactors) Update(ctx context.Context, redactor *v1beta2.Redactor, opts v1.UpdateOptions) (result *v1beta2.Redactor, err error) { + result = &v1beta2.Redactor{} + err = c.client.Put(). + Namespace(c.ns). + Resource("redactors"). + Name(redactor.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(redactor). + Do(ctx). + 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 *redactors) UpdateStatus(ctx context.Context, redactor *v1beta2.Redactor, opts v1.UpdateOptions) (result *v1beta2.Redactor, err error) { + result = &v1beta2.Redactor{} + err = c.client.Put(). + Namespace(c.ns). + Resource("redactors"). + Name(redactor.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(redactor). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the redactor and deletes it. Returns an error if one occurs. +func (c *redactors) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("redactors"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *redactors) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("redactors"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched redactor. +func (c *redactors) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.Redactor, err error) { + result = &v1beta2.Redactor{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("redactors"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/supportbundle.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/supportbundle.go new file mode 100644 index 000000000..49399e767 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/supportbundle.go @@ -0,0 +1,194 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "context" + "time" + + v1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + scheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/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" +) + +// SupportBundlesGetter has a method to return a SupportBundleInterface. +// A group's client should implement this interface. +type SupportBundlesGetter interface { + SupportBundles(namespace string) SupportBundleInterface +} + +// SupportBundleInterface has methods to work with SupportBundle resources. +type SupportBundleInterface interface { + Create(ctx context.Context, supportBundle *v1beta2.SupportBundle, opts v1.CreateOptions) (*v1beta2.SupportBundle, error) + Update(ctx context.Context, supportBundle *v1beta2.SupportBundle, opts v1.UpdateOptions) (*v1beta2.SupportBundle, error) + UpdateStatus(ctx context.Context, supportBundle *v1beta2.SupportBundle, opts v1.UpdateOptions) (*v1beta2.SupportBundle, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta2.SupportBundle, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta2.SupportBundleList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.SupportBundle, err error) + SupportBundleExpansion +} + +// supportBundles implements SupportBundleInterface +type supportBundles struct { + client rest.Interface + ns string +} + +// newSupportBundles returns a SupportBundles +func newSupportBundles(c *TroubleshootV1beta2Client, namespace string) *supportBundles { + return &supportBundles{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the supportBundle, and returns the corresponding supportBundle object, and an error if there is any. +func (c *supportBundles) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.SupportBundle, err error) { + result = &v1beta2.SupportBundle{} + err = c.client.Get(). + Namespace(c.ns). + Resource("supportbundles"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SupportBundles that match those selectors. +func (c *supportBundles) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.SupportBundleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.SupportBundleList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("supportbundles"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested supportBundles. +func (c *supportBundles) Watch(ctx context.Context, 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("supportbundles"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a supportBundle and creates it. Returns the server's representation of the supportBundle, and an error, if there is any. +func (c *supportBundles) Create(ctx context.Context, supportBundle *v1beta2.SupportBundle, opts v1.CreateOptions) (result *v1beta2.SupportBundle, err error) { + result = &v1beta2.SupportBundle{} + err = c.client.Post(). + Namespace(c.ns). + Resource("supportbundles"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(supportBundle). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a supportBundle and updates it. Returns the server's representation of the supportBundle, and an error, if there is any. +func (c *supportBundles) Update(ctx context.Context, supportBundle *v1beta2.SupportBundle, opts v1.UpdateOptions) (result *v1beta2.SupportBundle, err error) { + result = &v1beta2.SupportBundle{} + err = c.client.Put(). + Namespace(c.ns). + Resource("supportbundles"). + Name(supportBundle.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(supportBundle). + Do(ctx). + 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 *supportBundles) UpdateStatus(ctx context.Context, supportBundle *v1beta2.SupportBundle, opts v1.UpdateOptions) (result *v1beta2.SupportBundle, err error) { + result = &v1beta2.SupportBundle{} + err = c.client.Put(). + Namespace(c.ns). + Resource("supportbundles"). + Name(supportBundle.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(supportBundle). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the supportBundle and deletes it. Returns an error if one occurs. +func (c *supportBundles) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("supportbundles"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *supportBundles) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("supportbundles"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched supportBundle. +func (c *supportBundles) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.SupportBundle, err error) { + result = &v1beta2.SupportBundle{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("supportbundles"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/troubleshoot_client.go b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/troubleshoot_client.go new file mode 100644 index 000000000..9dc93fe14 --- /dev/null +++ b/github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/typed/troubleshoot/v1beta2/troubleshoot_client.go @@ -0,0 +1,113 @@ +/* +Copyright 2019 Replicated, Inc.. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta2 + +import ( + v1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme" + rest "k8s.io/client-go/rest" +) + +type TroubleshootV1beta2Interface interface { + RESTClient() rest.Interface + AnalyzersGetter + CollectorsGetter + HostPreflightsGetter + PreflightsGetter + RedactorsGetter + SupportBundlesGetter +} + +// TroubleshootV1beta2Client is used to interact with features provided by the troubleshoot.sh group. +type TroubleshootV1beta2Client struct { + restClient rest.Interface +} + +func (c *TroubleshootV1beta2Client) Analyzers(namespace string) AnalyzerInterface { + return newAnalyzers(c, namespace) +} + +func (c *TroubleshootV1beta2Client) Collectors(namespace string) CollectorInterface { + return newCollectors(c, namespace) +} + +func (c *TroubleshootV1beta2Client) HostPreflights(namespace string) HostPreflightInterface { + return newHostPreflights(c, namespace) +} + +func (c *TroubleshootV1beta2Client) Preflights(namespace string) PreflightInterface { + return newPreflights(c, namespace) +} + +func (c *TroubleshootV1beta2Client) Redactors(namespace string) RedactorInterface { + return newRedactors(c, namespace) +} + +func (c *TroubleshootV1beta2Client) SupportBundles(namespace string) SupportBundleInterface { + return newSupportBundles(c, namespace) +} + +// NewForConfig creates a new TroubleshootV1beta2Client for the given config. +func NewForConfig(c *rest.Config) (*TroubleshootV1beta2Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &TroubleshootV1beta2Client{client}, nil +} + +// NewForConfigOrDie creates a new TroubleshootV1beta2Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *TroubleshootV1beta2Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new TroubleshootV1beta2Client for the given RESTClient. +func New(c rest.Interface) *TroubleshootV1beta2Client { + return &TroubleshootV1beta2Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1beta2.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 *TroubleshootV1beta2Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/analyze/host_analyzer.go b/pkg/analyze/host_analyzer.go index 21627fa01..ca2dd2adc 100644 --- a/pkg/analyze/host_analyzer.go +++ b/pkg/analyze/host_analyzer.go @@ -28,6 +28,8 @@ func GetHostAnalyzer(analyzer *troubleshootv1beta2.HostAnalyze) (HostAnalyzer, b return &AnalyzeHostTime{analyzer.Time}, true case analyzer.BlockDevices != nil: return &AnalyzeHostBlockDevices{analyzer.BlockDevices}, true + case analyzer.KernelModules != nil: + return &AnalyzeHostKernelModules{analyzer.KernelModules}, true case analyzer.TCPConnect != nil: return &AnalyzeHostTCPConnect{analyzer.TCPConnect}, true case analyzer.IPV4Interfaces != nil: diff --git a/pkg/analyze/host_kernel_modules.go b/pkg/analyze/host_kernel_modules.go new file mode 100644 index 000000000..a46af4359 --- /dev/null +++ b/pkg/analyze/host_kernel_modules.go @@ -0,0 +1,156 @@ +package analyzer + +import ( + "encoding/json" + "fmt" + "strings" + + "github.com/pkg/errors" + troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + "github.com/replicatedhq/troubleshoot/pkg/collect" +) + +type AnalyzeHostKernelModules struct { + hostAnalyzer *troubleshootv1beta2.KernelModulesAnalyze +} + +func (a *AnalyzeHostKernelModules) Title() string { + return hostAnalyzerTitleOrDefault(a.hostAnalyzer.AnalyzeMeta, "Kernel Modules") +} + +func (a *AnalyzeHostKernelModules) IsExcluded() (bool, error) { + return isExcluded(a.hostAnalyzer.Exclude) +} + +func (a *AnalyzeHostKernelModules) Analyze(getCollectedFileContents func(string) ([]byte, error)) (*AnalyzeResult, error) { + hostAnalyzer := a.hostAnalyzer + contents, err := getCollectedFileContents("system/kernel_modules.json") + if err != nil { + return nil, errors.Wrap(err, "failed to get collected file") + } + modules := make(map[string]collect.KernelModuleInfo) + if err := json.Unmarshal(contents, &modules); err != nil { + return nil, errors.Wrap(err, "failed to unmarshal kernel modules") + } + + result := AnalyzeResult{} + + result.Title = a.Title() + + for _, outcome := range hostAnalyzer.Outcomes { + if outcome.Fail != nil { + if outcome.Fail.When == "" { + result.IsFail = true + result.Message = outcome.Fail.Message + result.URI = outcome.Fail.URI + + return &result, nil + } + + isMatch, err := compareKernelModuleConditionalToActual(outcome.Fail.When, modules) + if err != nil { + return nil, errors.Wrapf(err, "failed to compare %s", outcome.Fail.When) + } + + if isMatch { + result.IsFail = true + result.Message = outcome.Fail.Message + result.URI = outcome.Fail.URI + + return &result, nil + } + } else if outcome.Warn != nil { + if outcome.Warn.When == "" { + result.IsWarn = true + result.Message = outcome.Warn.Message + result.URI = outcome.Warn.URI + + return &result, nil + } + + isMatch, err := compareKernelModuleConditionalToActual(outcome.Warn.When, modules) + if err != nil { + return nil, errors.Wrapf(err, "failed to compare %s", outcome.Warn.When) + } + + if isMatch { + result.IsWarn = true + result.Message = outcome.Warn.Message + result.URI = outcome.Warn.URI + + return &result, nil + } + } else if outcome.Pass != nil { + if outcome.Pass.When == "" { + result.IsPass = true + result.Message = outcome.Pass.Message + result.URI = outcome.Pass.URI + + return &result, nil + } + + isMatch, err := compareKernelModuleConditionalToActual(outcome.Pass.When, modules) + if err != nil { + return nil, errors.Wrapf(err, "failed to compare %s", outcome.Pass.When) + } + + if isMatch { + result.IsPass = true + result.Message = outcome.Pass.Message + result.URI = outcome.Pass.URI + + return &result, nil + } + } + } + + return &result, nil +} + +func compareKernelModuleConditionalToActual(conditional string, modules map[string]collect.KernelModuleInfo) (res bool, err error) { + parts := strings.Split(conditional, " ") + if len(parts) != 3 { + return false, fmt.Errorf("Expected exactly 3 parts in conditional, got %d", len(parts)) + } + + matchModules := strings.Split(parts[0], ",") + matchStatuses := strings.Split(parts[2], ",") + + switch parts[1] { + case "=", "==": + for _, name := range matchModules { + module, ok := modules[name] + if !ok { + return false, nil + } + moduleOK := false + // Only one status must be true. + for _, status := range matchStatuses { + if module.Status == collect.KernelModuleStatus(status) { + moduleOK = true + continue + } + } + if !moduleOK { + return false, nil + } + } + return true, nil + case "!=", "<>": + for _, name := range matchModules { + module, ok := modules[name] + if !ok { + return true, nil + } + + for _, status := range matchStatuses { + if module.Status == collect.KernelModuleStatus(status) { + return false, nil + } + } + } + return true, nil + } + + return false, fmt.Errorf("unexpected operator %q", parts[1]) +} diff --git a/pkg/analyze/host_kernel_modules_test.go b/pkg/analyze/host_kernel_modules_test.go new file mode 100644 index 000000000..27a8a9ea2 --- /dev/null +++ b/pkg/analyze/host_kernel_modules_test.go @@ -0,0 +1,273 @@ +package analyzer + +import ( + "encoding/json" + "testing" + + troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" + "github.com/replicatedhq/troubleshoot/pkg/collect" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestAnalyzeKernelModules(t *testing.T) { + tests := []struct { + name string + info map[string]collect.KernelModuleInfo + hostAnalyzer *troubleshootv1beta2.KernelModulesAnalyze + result *AnalyzeResult + expectErr bool + }{ + { + name: "module 'abc' is not loaded", + info: map[string]collect.KernelModuleInfo{}, + hostAnalyzer: &troubleshootv1beta2.KernelModulesAnalyze{ + Outcomes: []*troubleshootv1beta2.Outcome{ + { + Fail: &troubleshootv1beta2.SingleOutcome{ + When: "abc != loaded", + Message: "the module 'abc' is not loaded", + }, + }, + }, + }, + result: &AnalyzeResult{ + Title: "Kernel Modules", + IsFail: true, + Message: "the module 'abc' is not loaded", + }, + }, + { + name: "module 'abc' is loaded", + info: map[string]collect.KernelModuleInfo{ + "abc": { + Status: "loaded", + }, + }, + hostAnalyzer: &troubleshootv1beta2.KernelModulesAnalyze{ + Outcomes: []*troubleshootv1beta2.Outcome{ + { + Fail: &troubleshootv1beta2.SingleOutcome{ + When: "abc != loaded", + Message: "the module 'abc' is not loaded", + }, + }, + { + Pass: &troubleshootv1beta2.SingleOutcome{ + When: "abc == loaded", + Message: "the module 'abc' is loaded", + }, + }, + }, + }, + result: &AnalyzeResult{ + Title: "Kernel Modules", + IsPass: true, + Message: "the module 'abc' is loaded", + }, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + req := require.New(t) + b, err := json.Marshal(test.info) + if err != nil { + t.Fatal(err) + } + + getCollectedFileContents := func(filename string) ([]byte, error) { + return b, nil + } + + result, err := (&AnalyzeHostKernelModules{test.hostAnalyzer}).Analyze(getCollectedFileContents) + if test.expectErr { + req.Error(err) + } else { + req.NoError(err) + } + + assert.Equal(t, test.result, result) + }) + } +} + +func Test_compareKernelModuleConditionalToActual(t *testing.T) { + tests := []struct { + name string + conditional string + modules map[string]collect.KernelModuleInfo + wantRes bool + wantErr bool + }{ + { + name: "match second item", + conditional: "def = loaded", + modules: map[string]collect.KernelModuleInfo{ + "abc": { + Status: "unloading", + }, + "def": { + Status: "loaded", + }, + }, + wantRes: true, + }, + { + name: "match multiple items", + conditional: "abc,def = loaded,loadable", + modules: map[string]collect.KernelModuleInfo{ + "abc": { + Status: "loadable", + }, + "def": { + Status: "loaded", + }, + }, + wantRes: true, + }, + { + name: "match multiple items, one not ok", + conditional: "abc,def,ghi = loaded,loadable", + modules: map[string]collect.KernelModuleInfo{ + "abc": { + Status: "loadable", + }, + "def": { + Status: "unloading", + }, + "ghi": { + Status: "loaded", + }, + }, + wantRes: false, + }, + { + name: "item not in list", + conditional: "abc = loaded", + modules: map[string]collect.KernelModuleInfo{ + "def": { + Status: "unloading", + }, + }, + wantRes: false, + }, + { + name: "item does not match", + conditional: "abc = loaded", + modules: map[string]collect.KernelModuleInfo{ + "abc": { + Status: "unloading", + }, + }, + wantRes: false, + }, + { + name: "other operator", + conditional: "abc * loaded", + modules: map[string]collect.KernelModuleInfo{ + "abc": { + Status: "unloading", + }, + }, + wantErr: true, + }, + { + name: "item matches one of multiple", + conditional: "abc = loaded,loadable", + modules: map[string]collect.KernelModuleInfo{ + "abc": { + Status: "loadable", + }, + }, + wantRes: true, + }, + { + name: "item matches with !=", + conditional: "abc != unloading", + modules: map[string]collect.KernelModuleInfo{ + "abc": { + Status: "loadable", + }, + }, + wantRes: true, + }, + { + name: "item not found matches with !=", + conditional: "abc != unloading", + modules: map[string]collect.KernelModuleInfo{}, + wantRes: true, + }, + { + name: "item does not match with !=", + conditional: "abc != loadable", + modules: map[string]collect.KernelModuleInfo{ + "abc": { + Status: "loadable", + }, + }, + wantRes: false, + }, + { + name: "item matches one of multiple with !=", + conditional: "abc != loaded,loadable", + modules: map[string]collect.KernelModuleInfo{ + "abc": { + Status: "unloading", + }, + }, + wantRes: true, + }, + { + name: "item does not match one of multiple with !=", + conditional: "abc != loaded,loadable", + modules: map[string]collect.KernelModuleInfo{ + "abc": { + Status: "loadable", + }, + }, + wantRes: false, + }, + { + name: "match multiple items with !=", + conditional: "abc,def != loading,unloading", + modules: map[string]collect.KernelModuleInfo{ + "abc": { + Status: "loadable", + }, + "def": { + Status: "loaded", + }, + }, + wantRes: true, + }, + { + name: "match multiple items with !=, one not ok", + conditional: "abc,def,ghi != loading,unloading", + modules: map[string]collect.KernelModuleInfo{ + "abc": { + Status: "loadable", + }, + "def": { + Status: "unloading", + }, + "ghi": { + Status: "loaded", + }, + }, + wantRes: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + req := require.New(t) + gotRes, err := compareKernelModuleConditionalToActual(tt.conditional, tt.modules) + if tt.wantErr { + req.Error(err) + } else { + req.NoError(err) + req.Equal(tt.wantRes, gotRes) + } + }) + } +} diff --git a/pkg/apis/troubleshoot/v1beta2/hostanalyzer_shared.go b/pkg/apis/troubleshoot/v1beta2/hostanalyzer_shared.go index f8a2a6dae..e5bbfefa7 100644 --- a/pkg/apis/troubleshoot/v1beta2/hostanalyzer_shared.go +++ b/pkg/apis/troubleshoot/v1beta2/hostanalyzer_shared.go @@ -51,6 +51,10 @@ type BlockDevicesAnalyze struct { IncludeUnmountedPartitions bool `json:"includeUnmountedPartitions" yaml:"includeUnmountedPartitions"` Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"` } +type KernelModulesAnalyze struct { + AnalyzeMeta `json:",inline" yaml:",inline"` + Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"` +} type TCPConnectAnalyze struct { AnalyzeMeta `json:",inline" yaml:",inline"` @@ -98,6 +102,8 @@ type HostAnalyze struct { BlockDevices *BlockDevicesAnalyze `json:"blockDevices,omitempty" yaml:"blockDevices,omitempty"` + KernelModules *KernelModulesAnalyze `json:"kernelModules,omitempty" yaml:"kernelModules,omitempty"` + TCPConnect *TCPConnectAnalyze `json:"tcpConnect,omitempty" yaml:"tcpConnect,omitempty"` IPV4Interfaces *IPV4InterfacesAnalyze `json:"ipv4Interfaces,omitempty" yaml:"ipv4Interfaces,omitempty"` diff --git a/pkg/apis/troubleshoot/v1beta2/hostcollector_shared.go b/pkg/apis/troubleshoot/v1beta2/hostcollector_shared.go index 4b4eaf6b0..d06920381 100644 --- a/pkg/apis/troubleshoot/v1beta2/hostcollector_shared.go +++ b/pkg/apis/troubleshoot/v1beta2/hostcollector_shared.go @@ -67,6 +67,10 @@ type HostBlockDevices struct { HostCollectorMeta `json:",inline" yaml:",inline"` } +type HostKernelModules struct { + HostCollectorMeta `json:",inline" yaml:",inline"` +} + type TCPConnect struct { HostCollectorMeta `json:",inline" yaml:",inline"` Address string `json:"address"` @@ -136,6 +140,7 @@ type HostCollect struct { HTTP *HostHTTP `json:"http,omitempty" yaml:"http,omitempty"` Time *HostTime `json:"time,omitempty" yaml:"time,omitempty"` BlockDevices *HostBlockDevices `json:"blockDevices,omitempty" yaml:"blockDevices,omitempty"` + KernelModules *HostKernelModules `json:"kernelModules,omitempty" yaml:"kernelModules,omitempty"` TCPConnect *TCPConnect `json:"tcpConnect,omitempty" yaml:"tcpConnect,omitempty"` FilesystemPerformance *FilesystemPerformance `json:"filesystemPerformance,omitempty" yaml:"filesystemPerformance,omitempty"` Certificate *Certificate `json:"certificate,omitempty" yaml:"certificate,omitempty"` diff --git a/pkg/apis/troubleshoot/v1beta2/zz_generated.deepcopy.go b/pkg/apis/troubleshoot/v1beta2/zz_generated.deepcopy.go index b45df9f0a..484bc53c6 100644 --- a/pkg/apis/troubleshoot/v1beta2/zz_generated.deepcopy.go +++ b/pkg/apis/troubleshoot/v1beta2/zz_generated.deepcopy.go @@ -1278,6 +1278,11 @@ func (in *HostAnalyze) DeepCopyInto(out *HostAnalyze) { *out = new(BlockDevicesAnalyze) (*in).DeepCopyInto(*out) } + if in.KernelModules != nil { + in, out := &in.KernelModules, &out.KernelModules + *out = new(KernelModulesAnalyze) + (*in).DeepCopyInto(*out) + } if in.TCPConnect != nil { in, out := &in.TCPConnect, &out.TCPConnect *out = new(TCPConnectAnalyze) @@ -1389,6 +1394,11 @@ func (in *HostCollect) DeepCopyInto(out *HostCollect) { *out = new(HostBlockDevices) **out = **in } + if in.KernelModules != nil { + in, out := &in.KernelModules, &out.KernelModules + *out = new(HostKernelModules) + **out = **in + } if in.TCPConnect != nil { in, out := &in.TCPConnect, &out.TCPConnect *out = new(TCPConnect) @@ -1468,6 +1478,22 @@ func (in *HostHTTP) DeepCopy() *HostHTTP { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HostKernelModules) DeepCopyInto(out *HostKernelModules) { + *out = *in + out.HostCollectorMeta = in.HostCollectorMeta +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostKernelModules. +func (in *HostKernelModules) DeepCopy() *HostKernelModules { + if in == nil { + return nil + } + out := new(HostKernelModules) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HostPreflight) DeepCopyInto(out *HostPreflight) { *out = *in @@ -1757,6 +1783,33 @@ func (in *Ingress) DeepCopy() *Ingress { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KernelModulesAnalyze) DeepCopyInto(out *KernelModulesAnalyze) { + *out = *in + out.AnalyzeMeta = in.AnalyzeMeta + if in.Outcomes != nil { + in, out := &in.Outcomes, &out.Outcomes + *out = make([]*Outcome, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(Outcome) + (*in).DeepCopyInto(*out) + } + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KernelModulesAnalyze. +func (in *KernelModulesAnalyze) DeepCopy() *KernelModulesAnalyze { + if in == nil { + return nil + } + out := new(KernelModulesAnalyze) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Kubernetes) DeepCopyInto(out *Kubernetes) { *out = *in diff --git a/pkg/collect/host_collector.go b/pkg/collect/host_collector.go index a864cc9bf..c36883e49 100644 --- a/pkg/collect/host_collector.go +++ b/pkg/collect/host_collector.go @@ -30,6 +30,8 @@ func GetHostCollector(collector *troubleshootv1beta2.HostCollect) (HostCollector return &CollectHostTime{collector.Time}, true case collector.BlockDevices != nil: return &CollectHostBlockDevices{collector.BlockDevices}, true + case collector.KernelModules != nil: + return &CollectHostKernelModules{collector.KernelModules}, true case collector.TCPConnect != nil: return &CollectHostTCPConnect{collector.TCPConnect}, true case collector.IPV4Interfaces != nil: diff --git a/pkg/collect/host_kernel_modules.go b/pkg/collect/host_kernel_modules.go new file mode 100644 index 000000000..b6b23951e --- /dev/null +++ b/pkg/collect/host_kernel_modules.go @@ -0,0 +1,140 @@ +package collect + +import ( + "bufio" + "bytes" + "encoding/json" + "os" + "os/exec" + "path/filepath" + "strconv" + "strings" + + "github.com/pkg/errors" + troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" +) + +const ( + KernelModuleUnknown = "unknown" + KernelModuleLoaded = "loaded" + KernelModuleLoadable = "loadable" + KernelModuleLoading = "loading" + KernelModuleUnloading = "unloading" +) + +type KernelModuleStatus string + +type KernelModuleInfo struct { + Size uint64 `json:"size"` + Instances string `json:"instances"` + UsedBy []string `json:"usedBy"` + Status KernelModuleStatus `json:"status"` +} + +type CollectHostKernelModules struct { + hostCollector *troubleshootv1beta2.HostKernelModules +} + +func (c *CollectHostKernelModules) Title() string { + return hostCollectorTitleOrDefault(c.hostCollector.HostCollectorMeta, "Kernel Modules") +} + +func (c *CollectHostKernelModules) IsExcluded() (bool, error) { + return isExcluded(c.hostCollector.Exclude) +} + +func (c *CollectHostKernelModules) Collect(progressChan chan<- interface{}) (map[string][]byte, error) { + modules, err := collectLoadable() + if err != nil { + return nil, errors.Wrap(err, "failed to read loadable kernel modules") + } + loaded, err := collectLoaded() + if err != nil { + return nil, errors.Wrap(err, "failed to read loaded kernel modules") + } + + // Overlay with loaded modules. + for name, module := range loaded { + modules[name] = module + } + + b, err := json.Marshal(modules) + if err != nil { + return nil, errors.Wrap(err, "failed to marshal kernel modules") + } + + return map[string][]byte{ + "system/kernel_modules.json": b, + }, nil +} + +func collectLoadable() (map[string]KernelModuleInfo, error) { + modules := make(map[string]KernelModuleInfo) + + out, err := exec.Command("uname", "-r").Output() + if err != nil { + return nil, errors.Wrap(err, "failed to determine kernel release") + } + kernel := strings.TrimSpace(string(out)) + + cmd := exec.Command("/usr/bin/find", "/lib/modules/"+kernel, "-type", "f", "-name", "*.ko*") + stdout, err := cmd.Output() + if err != nil { + return nil, err + } + buf := bytes.NewBuffer(stdout) + scanner := bufio.NewScanner(buf) + + for scanner.Scan() { + _, file := filepath.Split(scanner.Text()) + name := strings.TrimSuffix(file, filepath.Ext(file)) + + if name == "" { + continue + } + + modules[name] = KernelModuleInfo{ + Status: KernelModuleLoadable, + } + } + return modules, nil +} + +func collectLoaded() (map[string]KernelModuleInfo, error) { + modules := make(map[string]KernelModuleInfo) + + file, err := os.Open("/proc/modules") + if err != nil { + return nil, err + } + defer file.Close() + scanner := bufio.NewScanner(file) + + for scanner.Scan() { + s := strings.Split(scanner.Text(), " ") + name, size, instances, usedBy, state := s[0], s[1], s[2], s[3], s[4] + + sizeInt, err := strconv.Atoi(size) + if err != nil { + sizeInt = 0 + } + + var status KernelModuleStatus = KernelModuleUnknown + switch state { + case "Live": + status = KernelModuleLoaded + case "Loading": + status = KernelModuleLoading + case "Unloading": + status = KernelModuleUnloading + } + + modules[name] = KernelModuleInfo{ + Size: uint64(sizeInt), + Instances: instances, + UsedBy: strings.Split(usedBy, ","), + Status: status, + } + } + return modules, nil +}