From 6e2b9ac1ce2b304d368687a083eea07d254d6efa Mon Sep 17 00:00:00 2001 From: jwierzbo Date: Thu, 11 Nov 2021 14:06:37 +0100 Subject: [PATCH 1/2] ArangoJob model --- pkg/apis/apps/definitions.go | 35 +++ pkg/apis/apps/v1/doc.go | 25 +++ pkg/apis/apps/v1/job.go | 63 ++++++ pkg/apis/apps/v1/job_spec.go | 30 +++ pkg/apis/apps/v1/job_validate.go | 45 ++++ pkg/apis/apps/v1/register.go | 57 +++++ pkg/apis/apps/v1/zz_generated.deepcopy.go | 112 ++++++++++ .../clientset/versioned/clientset.go | 14 ++ .../versioned/fake/clientset_generated.go | 7 + .../clientset/versioned/fake/register.go | 2 + .../clientset/versioned/scheme/register.go | 2 + .../versioned/typed/apps/v1/apps_client.go | 93 ++++++++ .../versioned/typed/apps/v1/arangojob.go | 199 ++++++++++++++++++ .../clientset/versioned/typed/apps/v1/doc.go | 24 +++ .../versioned/typed/apps/v1/fake/doc.go | 24 +++ .../typed/apps/v1/fake/fake_apps_client.go | 44 ++++ .../typed/apps/v1/fake/fake_arangojob.go | 146 +++++++++++++ .../typed/apps/v1/generated_expansion.go | 25 +++ .../externalversions/apps/interface.go | 50 +++++ .../externalversions/apps/v1/arangojob.go | 94 +++++++++ .../externalversions/apps/v1/interface.go | 49 +++++ .../informers/externalversions/factory.go | 6 + .../informers/externalversions/generic.go | 13 +- pkg/generated/listers/apps/v1/arangojob.go | 103 +++++++++ .../listers/apps/v1/expansion_generated.go | 31 +++ 25 files changed, 1289 insertions(+), 4 deletions(-) create mode 100644 pkg/apis/apps/definitions.go create mode 100644 pkg/apis/apps/v1/doc.go create mode 100644 pkg/apis/apps/v1/job.go create mode 100644 pkg/apis/apps/v1/job_spec.go create mode 100644 pkg/apis/apps/v1/job_validate.go create mode 100644 pkg/apis/apps/v1/register.go create mode 100644 pkg/apis/apps/v1/zz_generated.deepcopy.go create mode 100644 pkg/generated/clientset/versioned/typed/apps/v1/apps_client.go create mode 100644 pkg/generated/clientset/versioned/typed/apps/v1/arangojob.go create mode 100644 pkg/generated/clientset/versioned/typed/apps/v1/doc.go create mode 100644 pkg/generated/clientset/versioned/typed/apps/v1/fake/doc.go create mode 100644 pkg/generated/clientset/versioned/typed/apps/v1/fake/fake_apps_client.go create mode 100644 pkg/generated/clientset/versioned/typed/apps/v1/fake/fake_arangojob.go create mode 100644 pkg/generated/clientset/versioned/typed/apps/v1/generated_expansion.go create mode 100644 pkg/generated/informers/externalversions/apps/interface.go create mode 100644 pkg/generated/informers/externalversions/apps/v1/arangojob.go create mode 100644 pkg/generated/informers/externalversions/apps/v1/interface.go create mode 100644 pkg/generated/listers/apps/v1/arangojob.go create mode 100644 pkg/generated/listers/apps/v1/expansion_generated.go diff --git a/pkg/apis/apps/definitions.go b/pkg/apis/apps/definitions.go new file mode 100644 index 000000000..e291cad61 --- /dev/null +++ b/pkg/apis/apps/definitions.go @@ -0,0 +1,35 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Jakub Wierzbowski +// + +package apps + +const ( + ArangoJobCRDName = ArangoJobResourcePlural + "." + ArangoAppsGroupName + ArangoJobResourceKind = "ArangoJob" + ArangoJobResourcePlural = "arangojobs" + + ArangoAppsGroupName = "apps.arangodb.com" +) + +var ( + ArangoJobShortNames = []string{"arangojob"} +) diff --git a/pkg/apis/apps/v1/doc.go b/pkg/apis/apps/v1/doc.go new file mode 100644 index 000000000..2bb38f0d5 --- /dev/null +++ b/pkg/apis/apps/v1/doc.go @@ -0,0 +1,25 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Jakub Wierzbowski +// + +// +k8s:deepcopy-gen=package +// +groupName=apps.arangodb.com +package v1 diff --git a/pkg/apis/apps/v1/job.go b/pkg/apis/apps/v1/job.go new file mode 100644 index 000000000..20c0d2bb3 --- /dev/null +++ b/pkg/apis/apps/v1/job.go @@ -0,0 +1,63 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Jakub Wierzbowski +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/apis/apps" + + batchv1 "k8s.io/api/batch/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ArangoJobList is a list of ArangoDB jobs. +type ArangoJobList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []ArangoJob `json:"items"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ArangoJob contains definition and status of the ArangoDB type Job. +type ArangoJob struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec ArangoJobSpec `json:"spec,omitempty"` + Status batchv1.JobStatus `json:"status,omitempty"` +} + +// AsOwner creates an OwnerReference for the given job +func (a *ArangoJob) AsOwner() metav1.OwnerReference { + trueVar := true + return metav1.OwnerReference{ + APIVersion: SchemeGroupVersion.String(), + Kind: apps.ArangoJobResourceKind, + Name: a.Name, + UID: a.UID, + Controller: &trueVar, + } +} diff --git a/pkg/apis/apps/v1/job_spec.go b/pkg/apis/apps/v1/job_spec.go new file mode 100644 index 000000000..9e28149f2 --- /dev/null +++ b/pkg/apis/apps/v1/job_spec.go @@ -0,0 +1,30 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Jakub Wierzbowski +// + +package v1 + +import batchv1 "k8s.io/api/batch/v1" + +type ArangoJobSpec struct { + ArangoDeploymentName string `json:"arangoDeploymentName"` + JobTemplate *batchv1.JobSpec `json:"jobTemplate,omitempty"` +} diff --git a/pkg/apis/apps/v1/job_validate.go b/pkg/apis/apps/v1/job_validate.go new file mode 100644 index 000000000..9c12ededb --- /dev/null +++ b/pkg/apis/apps/v1/job_validate.go @@ -0,0 +1,45 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Jakub Wierzbowski +// + +package v1 + +import "github.com/arangodb/kube-arangodb/pkg/util/errors" + +func (a *ArangoJob) Validate() error { + if err := a.Spec.Validate(); err != nil { + return err + } + + return nil +} + +func (a *ArangoJobSpec) Validate() error { + if a.ArangoDeploymentName == "" { + return errors.Newf("deployment name can not be empty") + } + + if a.JobTemplate == nil { + return errors.Newf("jobTemplate name can not be empty") + } + + return nil +} diff --git a/pkg/apis/apps/v1/register.go b/pkg/apis/apps/v1/register.go new file mode 100644 index 000000000..600b67978 --- /dev/null +++ b/pkg/apis/apps/v1/register.go @@ -0,0 +1,57 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Jakub Wierzbowski +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/apis/apps" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +const ( + ArangoAppsVersion = "v1" +) + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme + + SchemeGroupVersion = schema.GroupVersion{Group: apps.ArangoAppsGroupName, Version: ArangoAppsVersion} +) + +// Resource gets an ArangoCluster GroupResource for a specified resource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// addKnownTypes adds the set of types defined in this package to the supplied scheme. +func addKnownTypes(s *runtime.Scheme) error { + s.AddKnownTypes(SchemeGroupVersion, + &ArangoJob{}, + &ArangoJobList{}, + ) + metav1.AddToGroupVersion(s, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/apps/v1/zz_generated.deepcopy.go b/pkg/apis/apps/v1/zz_generated.deepcopy.go new file mode 100644 index 000000000..fe7f8fd3c --- /dev/null +++ b/pkg/apis/apps/v1/zz_generated.deepcopy.go @@ -0,0 +1,112 @@ +// +build !ignore_autogenerated + +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1 + +import ( + batchv1 "k8s.io/api/batch/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoJob) DeepCopyInto(out *ArangoJob) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoJob. +func (in *ArangoJob) DeepCopy() *ArangoJob { + if in == nil { + return nil + } + out := new(ArangoJob) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ArangoJob) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoJobList) DeepCopyInto(out *ArangoJobList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ArangoJob, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoJobList. +func (in *ArangoJobList) DeepCopy() *ArangoJobList { + if in == nil { + return nil + } + out := new(ArangoJobList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ArangoJobList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoJobSpec) DeepCopyInto(out *ArangoJobSpec) { + *out = *in + if in.JobTemplate != nil { + in, out := &in.JobTemplate, &out.JobTemplate + *out = new(batchv1.JobSpec) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoJobSpec. +func (in *ArangoJobSpec) DeepCopy() *ArangoJobSpec { + if in == nil { + return nil + } + out := new(ArangoJobSpec) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/generated/clientset/versioned/clientset.go b/pkg/generated/clientset/versioned/clientset.go index 33c16f7ab..c0d0ffb82 100644 --- a/pkg/generated/clientset/versioned/clientset.go +++ b/pkg/generated/clientset/versioned/clientset.go @@ -25,6 +25,7 @@ package versioned import ( "fmt" + appsv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/apps/v1" backupv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/backup/v1" databasev1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/deployment/v1" databasev2alpha1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/deployment/v2alpha1" @@ -38,6 +39,7 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface + AppsV1() appsv1.AppsV1Interface BackupV1() backupv1.BackupV1Interface DatabaseV1() databasev1.DatabaseV1Interface DatabaseV2alpha1() databasev2alpha1.DatabaseV2alpha1Interface @@ -50,6 +52,7 @@ type Interface interface { // version included in a Clientset. type Clientset struct { *discovery.DiscoveryClient + appsV1 *appsv1.AppsV1Client backupV1 *backupv1.BackupV1Client databaseV1 *databasev1.DatabaseV1Client databaseV2alpha1 *databasev2alpha1.DatabaseV2alpha1Client @@ -58,6 +61,11 @@ type Clientset struct { storageV1alpha *storagev1alpha.StorageV1alphaClient } +// AppsV1 retrieves the AppsV1Client +func (c *Clientset) AppsV1() appsv1.AppsV1Interface { + return c.appsV1 +} + // BackupV1 retrieves the BackupV1Client func (c *Clientset) BackupV1() backupv1.BackupV1Interface { return c.backupV1 @@ -109,6 +117,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { } var cs Clientset var err error + cs.appsV1, err = appsv1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.backupV1, err = backupv1.NewForConfig(&configShallowCopy) if err != nil { return nil, err @@ -145,6 +157,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { // panics if there is an error in the config. func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset + cs.appsV1 = appsv1.NewForConfigOrDie(c) cs.backupV1 = backupv1.NewForConfigOrDie(c) cs.databaseV1 = databasev1.NewForConfigOrDie(c) cs.databaseV2alpha1 = databasev2alpha1.NewForConfigOrDie(c) @@ -159,6 +172,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset + cs.appsV1 = appsv1.New(c) cs.backupV1 = backupv1.New(c) cs.databaseV1 = databasev1.New(c) cs.databaseV2alpha1 = databasev2alpha1.New(c) diff --git a/pkg/generated/clientset/versioned/fake/clientset_generated.go b/pkg/generated/clientset/versioned/fake/clientset_generated.go index 55d4ca5a6..c3390d74d 100644 --- a/pkg/generated/clientset/versioned/fake/clientset_generated.go +++ b/pkg/generated/clientset/versioned/fake/clientset_generated.go @@ -24,6 +24,8 @@ package fake import ( clientset "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" + appsv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/apps/v1" + fakeappsv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/apps/v1/fake" backupv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/backup/v1" fakebackupv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/backup/v1/fake" databasev1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/deployment/v1" @@ -90,6 +92,11 @@ func (c *Clientset) Tracker() testing.ObjectTracker { var _ clientset.Interface = &Clientset{} +// AppsV1 retrieves the AppsV1Client +func (c *Clientset) AppsV1() appsv1.AppsV1Interface { + return &fakeappsv1.FakeAppsV1{Fake: &c.Fake} +} + // BackupV1 retrieves the BackupV1Client func (c *Clientset) BackupV1() backupv1.BackupV1Interface { return &fakebackupv1.FakeBackupV1{Fake: &c.Fake} diff --git a/pkg/generated/clientset/versioned/fake/register.go b/pkg/generated/clientset/versioned/fake/register.go index 4e3a789f3..ffcd0e0a6 100644 --- a/pkg/generated/clientset/versioned/fake/register.go +++ b/pkg/generated/clientset/versioned/fake/register.go @@ -23,6 +23,7 @@ package fake import ( + appsv1 "github.com/arangodb/kube-arangodb/pkg/apis/apps/v1" backupv1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" databasev1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" databasev2alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v2alpha1" @@ -40,6 +41,7 @@ var scheme = runtime.NewScheme() var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ + appsv1.AddToScheme, backupv1.AddToScheme, databasev1.AddToScheme, databasev2alpha1.AddToScheme, diff --git a/pkg/generated/clientset/versioned/scheme/register.go b/pkg/generated/clientset/versioned/scheme/register.go index eed930a44..9d713b948 100644 --- a/pkg/generated/clientset/versioned/scheme/register.go +++ b/pkg/generated/clientset/versioned/scheme/register.go @@ -23,6 +23,7 @@ package scheme import ( + appsv1 "github.com/arangodb/kube-arangodb/pkg/apis/apps/v1" backupv1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" databasev1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" databasev2alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v2alpha1" @@ -40,6 +41,7 @@ var Scheme = runtime.NewScheme() var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ + appsv1.AddToScheme, backupv1.AddToScheme, databasev1.AddToScheme, databasev2alpha1.AddToScheme, diff --git a/pkg/generated/clientset/versioned/typed/apps/v1/apps_client.go b/pkg/generated/clientset/versioned/typed/apps/v1/apps_client.go new file mode 100644 index 000000000..8e0051cc3 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/apps/v1/apps_client.go @@ -0,0 +1,93 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/arangodb/kube-arangodb/pkg/apis/apps/v1" + "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type AppsV1Interface interface { + RESTClient() rest.Interface + ArangoJobsGetter +} + +// AppsV1Client is used to interact with features provided by the apps.arangodb.com group. +type AppsV1Client struct { + restClient rest.Interface +} + +func (c *AppsV1Client) ArangoJobs(namespace string) ArangoJobInterface { + return newArangoJobs(c, namespace) +} + +// NewForConfig creates a new AppsV1Client for the given config. +func NewForConfig(c *rest.Config) (*AppsV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &AppsV1Client{client}, nil +} + +// NewForConfigOrDie creates a new AppsV1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *AppsV1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new AppsV1Client for the given RESTClient. +func New(c rest.Interface) *AppsV1Client { + return &AppsV1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1.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 *AppsV1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/generated/clientset/versioned/typed/apps/v1/arangojob.go b/pkg/generated/clientset/versioned/typed/apps/v1/arangojob.go new file mode 100644 index 000000000..2c7310984 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/apps/v1/arangojob.go @@ -0,0 +1,199 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + "context" + "time" + + v1 "github.com/arangodb/kube-arangodb/pkg/apis/apps/v1" + scheme "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/scheme" + metav1 "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" +) + +// ArangoJobsGetter has a method to return a ArangoJobInterface. +// A group's client should implement this interface. +type ArangoJobsGetter interface { + ArangoJobs(namespace string) ArangoJobInterface +} + +// ArangoJobInterface has methods to work with ArangoJob resources. +type ArangoJobInterface interface { + Create(ctx context.Context, arangoJob *v1.ArangoJob, opts metav1.CreateOptions) (*v1.ArangoJob, error) + Update(ctx context.Context, arangoJob *v1.ArangoJob, opts metav1.UpdateOptions) (*v1.ArangoJob, error) + UpdateStatus(ctx context.Context, arangoJob *v1.ArangoJob, opts metav1.UpdateOptions) (*v1.ArangoJob, error) + Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error + Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.ArangoJob, error) + List(ctx context.Context, opts metav1.ListOptions) (*v1.ArangoJobList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ArangoJob, err error) + ArangoJobExpansion +} + +// arangoJobs implements ArangoJobInterface +type arangoJobs struct { + client rest.Interface + ns string +} + +// newArangoJobs returns a ArangoJobs +func newArangoJobs(c *AppsV1Client, namespace string) *arangoJobs { + return &arangoJobs{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the arangoJob, and returns the corresponding arangoJob object, and an error if there is any. +func (c *arangoJobs) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.ArangoJob, err error) { + result = &v1.ArangoJob{} + err = c.client.Get(). + Namespace(c.ns). + Resource("arangojobs"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ArangoJobs that match those selectors. +func (c *arangoJobs) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ArangoJobList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ArangoJobList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("arangojobs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested arangoJobs. +func (c *arangoJobs) Watch(ctx context.Context, opts metav1.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("arangojobs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a arangoJob and creates it. Returns the server's representation of the arangoJob, and an error, if there is any. +func (c *arangoJobs) Create(ctx context.Context, arangoJob *v1.ArangoJob, opts metav1.CreateOptions) (result *v1.ArangoJob, err error) { + result = &v1.ArangoJob{} + err = c.client.Post(). + Namespace(c.ns). + Resource("arangojobs"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(arangoJob). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a arangoJob and updates it. Returns the server's representation of the arangoJob, and an error, if there is any. +func (c *arangoJobs) Update(ctx context.Context, arangoJob *v1.ArangoJob, opts metav1.UpdateOptions) (result *v1.ArangoJob, err error) { + result = &v1.ArangoJob{} + err = c.client.Put(). + Namespace(c.ns). + Resource("arangojobs"). + Name(arangoJob.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(arangoJob). + 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 *arangoJobs) UpdateStatus(ctx context.Context, arangoJob *v1.ArangoJob, opts metav1.UpdateOptions) (result *v1.ArangoJob, err error) { + result = &v1.ArangoJob{} + err = c.client.Put(). + Namespace(c.ns). + Resource("arangojobs"). + Name(arangoJob.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(arangoJob). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the arangoJob and deletes it. Returns an error if one occurs. +func (c *arangoJobs) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("arangojobs"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *arangoJobs) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.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("arangojobs"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched arangoJob. +func (c *arangoJobs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ArangoJob, err error) { + result = &v1.ArangoJob{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("arangojobs"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/generated/clientset/versioned/typed/apps/v1/doc.go b/pkg/generated/clientset/versioned/typed/apps/v1/doc.go new file mode 100644 index 000000000..e16a0b981 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/apps/v1/doc.go @@ -0,0 +1,24 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/pkg/generated/clientset/versioned/typed/apps/v1/fake/doc.go b/pkg/generated/clientset/versioned/typed/apps/v1/fake/doc.go new file mode 100644 index 000000000..b64e12d94 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/apps/v1/fake/doc.go @@ -0,0 +1,24 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/generated/clientset/versioned/typed/apps/v1/fake/fake_apps_client.go b/pkg/generated/clientset/versioned/typed/apps/v1/fake/fake_apps_client.go new file mode 100644 index 000000000..b90fbaaa1 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/apps/v1/fake/fake_apps_client.go @@ -0,0 +1,44 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/apps/v1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeAppsV1 struct { + *testing.Fake +} + +func (c *FakeAppsV1) ArangoJobs(namespace string) v1.ArangoJobInterface { + return &FakeArangoJobs{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeAppsV1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/generated/clientset/versioned/typed/apps/v1/fake/fake_arangojob.go b/pkg/generated/clientset/versioned/typed/apps/v1/fake/fake_arangojob.go new file mode 100644 index 000000000..fa2273dec --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/apps/v1/fake/fake_arangojob.go @@ -0,0 +1,146 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + appsv1 "github.com/arangodb/kube-arangodb/pkg/apis/apps/v1" + 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" +) + +// FakeArangoJobs implements ArangoJobInterface +type FakeArangoJobs struct { + Fake *FakeAppsV1 + ns string +} + +var arangojobsResource = schema.GroupVersionResource{Group: "apps.arangodb.com", Version: "v1", Resource: "arangojobs"} + +var arangojobsKind = schema.GroupVersionKind{Group: "apps.arangodb.com", Version: "v1", Kind: "ArangoJob"} + +// Get takes name of the arangoJob, and returns the corresponding arangoJob object, and an error if there is any. +func (c *FakeArangoJobs) Get(ctx context.Context, name string, options v1.GetOptions) (result *appsv1.ArangoJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(arangojobsResource, c.ns, name), &appsv1.ArangoJob{}) + + if obj == nil { + return nil, err + } + return obj.(*appsv1.ArangoJob), err +} + +// List takes label and field selectors, and returns the list of ArangoJobs that match those selectors. +func (c *FakeArangoJobs) List(ctx context.Context, opts v1.ListOptions) (result *appsv1.ArangoJobList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(arangojobsResource, arangojobsKind, c.ns, opts), &appsv1.ArangoJobList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &appsv1.ArangoJobList{ListMeta: obj.(*appsv1.ArangoJobList).ListMeta} + for _, item := range obj.(*appsv1.ArangoJobList).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 arangoJobs. +func (c *FakeArangoJobs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(arangojobsResource, c.ns, opts)) + +} + +// Create takes the representation of a arangoJob and creates it. Returns the server's representation of the arangoJob, and an error, if there is any. +func (c *FakeArangoJobs) Create(ctx context.Context, arangoJob *appsv1.ArangoJob, opts v1.CreateOptions) (result *appsv1.ArangoJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(arangojobsResource, c.ns, arangoJob), &appsv1.ArangoJob{}) + + if obj == nil { + return nil, err + } + return obj.(*appsv1.ArangoJob), err +} + +// Update takes the representation of a arangoJob and updates it. Returns the server's representation of the arangoJob, and an error, if there is any. +func (c *FakeArangoJobs) Update(ctx context.Context, arangoJob *appsv1.ArangoJob, opts v1.UpdateOptions) (result *appsv1.ArangoJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(arangojobsResource, c.ns, arangoJob), &appsv1.ArangoJob{}) + + if obj == nil { + return nil, err + } + return obj.(*appsv1.ArangoJob), 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 *FakeArangoJobs) UpdateStatus(ctx context.Context, arangoJob *appsv1.ArangoJob, opts v1.UpdateOptions) (*appsv1.ArangoJob, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(arangojobsResource, "status", c.ns, arangoJob), &appsv1.ArangoJob{}) + + if obj == nil { + return nil, err + } + return obj.(*appsv1.ArangoJob), err +} + +// Delete takes name of the arangoJob and deletes it. Returns an error if one occurs. +func (c *FakeArangoJobs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(arangojobsResource, c.ns, name), &appsv1.ArangoJob{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeArangoJobs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(arangojobsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &appsv1.ArangoJobList{}) + return err +} + +// Patch applies the patch and returns the patched arangoJob. +func (c *FakeArangoJobs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *appsv1.ArangoJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(arangojobsResource, c.ns, name, pt, data, subresources...), &appsv1.ArangoJob{}) + + if obj == nil { + return nil, err + } + return obj.(*appsv1.ArangoJob), err +} diff --git a/pkg/generated/clientset/versioned/typed/apps/v1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/apps/v1/generated_expansion.go new file mode 100644 index 000000000..140ef7032 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/apps/v1/generated_expansion.go @@ -0,0 +1,25 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +type ArangoJobExpansion interface{} diff --git a/pkg/generated/informers/externalversions/apps/interface.go b/pkg/generated/informers/externalversions/apps/interface.go new file mode 100644 index 000000000..88e87412c --- /dev/null +++ b/pkg/generated/informers/externalversions/apps/interface.go @@ -0,0 +1,50 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by informer-gen. DO NOT EDIT. + +package apps + +import ( + v1 "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/apps/v1" + internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1 provides access to shared informers for resources in V1. + V1() v1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1 returns a new v1.Interface. +func (g *group) V1() v1.Interface { + return v1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/generated/informers/externalversions/apps/v1/arangojob.go b/pkg/generated/informers/externalversions/apps/v1/arangojob.go new file mode 100644 index 000000000..aa14d35f5 --- /dev/null +++ b/pkg/generated/informers/externalversions/apps/v1/arangojob.go @@ -0,0 +1,94 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + "context" + time "time" + + appsv1 "github.com/arangodb/kube-arangodb/pkg/apis/apps/v1" + versioned "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" + internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" + v1 "github.com/arangodb/kube-arangodb/pkg/generated/listers/apps/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ArangoJobInformer provides access to a shared informer and lister for +// ArangoJobs. +type ArangoJobInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.ArangoJobLister +} + +type arangoJobInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewArangoJobInformer constructs a new informer for ArangoJob type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewArangoJobInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredArangoJobInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredArangoJobInformer constructs a new informer for ArangoJob type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredArangoJobInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AppsV1().ArangoJobs(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AppsV1().ArangoJobs(namespace).Watch(context.TODO(), options) + }, + }, + &appsv1.ArangoJob{}, + resyncPeriod, + indexers, + ) +} + +func (f *arangoJobInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredArangoJobInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *arangoJobInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&appsv1.ArangoJob{}, f.defaultInformer) +} + +func (f *arangoJobInformer) Lister() v1.ArangoJobLister { + return v1.NewArangoJobLister(f.Informer().GetIndexer()) +} diff --git a/pkg/generated/informers/externalversions/apps/v1/interface.go b/pkg/generated/informers/externalversions/apps/v1/interface.go new file mode 100644 index 000000000..5a0f96af3 --- /dev/null +++ b/pkg/generated/informers/externalversions/apps/v1/interface.go @@ -0,0 +1,49 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // ArangoJobs returns a ArangoJobInformer. + ArangoJobs() ArangoJobInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// ArangoJobs returns a ArangoJobInformer. +func (v *version) ArangoJobs() ArangoJobInformer { + return &arangoJobInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/generated/informers/externalversions/factory.go b/pkg/generated/informers/externalversions/factory.go index e75cbeade..c7fffa7f7 100644 --- a/pkg/generated/informers/externalversions/factory.go +++ b/pkg/generated/informers/externalversions/factory.go @@ -28,6 +28,7 @@ import ( time "time" versioned "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" + apps "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/apps" backup "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/backup" deployment "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/deployment" internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" @@ -179,12 +180,17 @@ type SharedInformerFactory interface { ForResource(resource schema.GroupVersionResource) (GenericInformer, error) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + Apps() apps.Interface Backup() backup.Interface Database() deployment.Interface Replication() replication.Interface Storage() storage.Interface } +func (f *sharedInformerFactory) Apps() apps.Interface { + return apps.New(f, f.namespace, f.tweakListOptions) +} + func (f *sharedInformerFactory) Backup() backup.Interface { return backup.New(f, f.namespace, f.tweakListOptions) } diff --git a/pkg/generated/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go index c26de0a52..0db87aa74 100644 --- a/pkg/generated/informers/externalversions/generic.go +++ b/pkg/generated/informers/externalversions/generic.go @@ -25,7 +25,8 @@ package externalversions import ( "fmt" - v1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + v1 "github.com/arangodb/kube-arangodb/pkg/apis/apps/v1" + backupv1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" deploymentv1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" v2alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v2alpha1" replicationv1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" @@ -61,10 +62,14 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=backup.arangodb.com, Version=v1 - case v1.SchemeGroupVersion.WithResource("arangobackups"): + // Group=apps.arangodb.com, Version=v1 + case v1.SchemeGroupVersion.WithResource("arangojobs"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1().ArangoJobs().Informer()}, nil + + // Group=backup.arangodb.com, Version=v1 + case backupv1.SchemeGroupVersion.WithResource("arangobackups"): return &genericInformer{resource: resource.GroupResource(), informer: f.Backup().V1().ArangoBackups().Informer()}, nil - case v1.SchemeGroupVersion.WithResource("arangobackuppolicies"): + case backupv1.SchemeGroupVersion.WithResource("arangobackuppolicies"): return &genericInformer{resource: resource.GroupResource(), informer: f.Backup().V1().ArangoBackupPolicies().Informer()}, nil // Group=database.arangodb.com, Version=v1 diff --git a/pkg/generated/listers/apps/v1/arangojob.go b/pkg/generated/listers/apps/v1/arangojob.go new file mode 100644 index 000000000..3cf66c877 --- /dev/null +++ b/pkg/generated/listers/apps/v1/arangojob.go @@ -0,0 +1,103 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/arangodb/kube-arangodb/pkg/apis/apps/v1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ArangoJobLister helps list ArangoJobs. +// All objects returned here must be treated as read-only. +type ArangoJobLister interface { + // List lists all ArangoJobs in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1.ArangoJob, err error) + // ArangoJobs returns an object that can list and get ArangoJobs. + ArangoJobs(namespace string) ArangoJobNamespaceLister + ArangoJobListerExpansion +} + +// arangoJobLister implements the ArangoJobLister interface. +type arangoJobLister struct { + indexer cache.Indexer +} + +// NewArangoJobLister returns a new ArangoJobLister. +func NewArangoJobLister(indexer cache.Indexer) ArangoJobLister { + return &arangoJobLister{indexer: indexer} +} + +// List lists all ArangoJobs in the indexer. +func (s *arangoJobLister) List(selector labels.Selector) (ret []*v1.ArangoJob, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.ArangoJob)) + }) + return ret, err +} + +// ArangoJobs returns an object that can list and get ArangoJobs. +func (s *arangoJobLister) ArangoJobs(namespace string) ArangoJobNamespaceLister { + return arangoJobNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ArangoJobNamespaceLister helps list and get ArangoJobs. +// All objects returned here must be treated as read-only. +type ArangoJobNamespaceLister interface { + // List lists all ArangoJobs in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1.ArangoJob, err error) + // Get retrieves the ArangoJob from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1.ArangoJob, error) + ArangoJobNamespaceListerExpansion +} + +// arangoJobNamespaceLister implements the ArangoJobNamespaceLister +// interface. +type arangoJobNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ArangoJobs in the indexer for a given namespace. +func (s arangoJobNamespaceLister) List(selector labels.Selector) (ret []*v1.ArangoJob, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.ArangoJob)) + }) + return ret, err +} + +// Get retrieves the ArangoJob from the indexer for a given namespace and name. +func (s arangoJobNamespaceLister) Get(name string) (*v1.ArangoJob, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("arangojob"), name) + } + return obj.(*v1.ArangoJob), nil +} diff --git a/pkg/generated/listers/apps/v1/expansion_generated.go b/pkg/generated/listers/apps/v1/expansion_generated.go new file mode 100644 index 000000000..72497349c --- /dev/null +++ b/pkg/generated/listers/apps/v1/expansion_generated.go @@ -0,0 +1,31 @@ +// +// DISCLAIMER +// +// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany +// +// 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. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +// ArangoJobListerExpansion allows custom methods to be added to +// ArangoJobLister. +type ArangoJobListerExpansion interface{} + +// ArangoJobNamespaceListerExpansion allows custom methods to be added to +// ArangoJobNamespaceLister. +type ArangoJobNamespaceListerExpansion interface{} From 04d04e3fb07d7cfe6e8e0077b33fbe3045c9ed56 Mon Sep 17 00:00:00 2001 From: jwierzbo Date: Thu, 11 Nov 2021 19:51:02 +0100 Subject: [PATCH 2/2] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index aade2920c..ca2d2f230 100644 --- a/Makefile +++ b/Makefile @@ -219,7 +219,7 @@ update-generated: "all" \ "github.com/arangodb/kube-arangodb/pkg/generated" \ "github.com/arangodb/kube-arangodb/pkg/apis" \ - "deployment:v1 replication:v1 storage:v1alpha backup:v1 deployment:v2alpha1 replication:v2alpha1" \ + "deployment:v1 replication:v1 storage:v1alpha backup:v1 deployment:v2alpha1 replication:v2alpha1 apps:v1" \ --go-header-file "./tools/codegen/boilerplate.go.txt" \ $(VERIFYARGS) GOPATH=$(GOBUILDDIR) $(VENDORDIR)/k8s.io/code-generator/generate-groups.sh \