Merge pull request #466 from ibuildthecloud/master

Port to wrangler
pull/503/head v0.6.0-rc2
Erik Wilson 2019-05-27 13:38:13 -07:00 committed by GitHub
commit afe32395bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
467 changed files with 27345 additions and 20293 deletions

View File

@ -1,5 +1,6 @@
//go:generate go run types/codegen/cleanup/main.go
//go:generate go run types/codegen/main.go
//go:generate go run pkg/codegen/cleanup/main.go
//go:generate /bin/rm -rf pkg/generated
//go:generate go run pkg/codegen/main.go
//go:generate go fmt pkg/deploy/zz_generated_bindata.go
//go:generate go fmt pkg/static/zz_generated_bindata.go
//go:generate go fmt pkg/openapi/zz_generated_bindata.go

View File

@ -1,4 +1,4 @@
apiVersion: k3s.cattle.io/v1
apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
name: traefik

View File

@ -21,8 +21,8 @@ import (
"github.com/pkg/errors"
"github.com/rancher/k3s/pkg/cli/cmds"
"github.com/rancher/k3s/pkg/clientaccess"
"github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/norman/pkg/clientaccess"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/apimachinery/pkg/util/net"

View File

@ -6,7 +6,7 @@ import (
"github.com/pkg/errors"
"github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/norman/pkg/proxy"
"github.com/rancher/k3s/pkg/proxy"
"github.com/sirupsen/logrus"
)

View File

@ -16,9 +16,9 @@ import (
"github.com/rancher/k3s/pkg/agent/syssetup"
"github.com/rancher/k3s/pkg/agent/tunnel"
"github.com/rancher/k3s/pkg/cli/cmds"
"github.com/rancher/k3s/pkg/clientaccess"
"github.com/rancher/k3s/pkg/daemons/agent"
"github.com/rancher/k3s/pkg/rootless"
"github.com/rancher/norman/pkg/clientaccess"
"github.com/sirupsen/logrus"
)

View File

@ -13,7 +13,7 @@ import (
"github.com/gorilla/websocket"
"github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/norman/pkg/remotedialer"
"github.com/rancher/remotedialer"
"github.com/sirupsen/logrus"
"k8s.io/client-go/tools/clientcmd"
)

View File

@ -1,5 +1,5 @@
/*
Copyright 2016 The Kubernetes Authors.
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,16 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package maps
// Code generated by main. DO NOT EDIT.
// CopySS makes a shallow copy of a map.
func CopySS(m map[string]string) map[string]string {
if m == nil {
return nil
}
copy := make(map[string]string, len(m))
for k, v := range m {
copy[k] = v
}
return copy
}
// +k8s:deepcopy-gen=package
// +groupName=k3s.cattle.io
package v1

View File

@ -0,0 +1,37 @@
package v1
import (
"github.com/rancher/dynamiclistener"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type ListenerConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Status dynamiclistener.ListenerStatus `json:"status,omitempty"`
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type Addon struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec AddonSpec `json:"spec,omitempty"`
Status AddonStatus `json:"status,omitempty"`
}
type AddonSpec struct {
Source string `json:"source,omitempty"`
Checksum string `json:"checksum,omitempty"`
}
type AddonStatus struct {
GVKs []schema.GroupVersionKind `json:"gvks,omitempty"`
}

View File

@ -1,15 +1,33 @@
// +build !ignore_autogenerated
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
intstr "k8s.io/apimachinery/pkg/util/intstr"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Addon) DeepCopyInto(out *Addon) {
*out = *in
out.Namespaced = in.Namespaced
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
@ -105,111 +123,9 @@ func (in *AddonStatus) DeepCopy() *AddonStatus {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HelmChart) DeepCopyInto(out *HelmChart) {
*out = *in
out.Namespaced = in.Namespaced
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
out.Status = in.Status
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmChart.
func (in *HelmChart) DeepCopy() *HelmChart {
if in == nil {
return nil
}
out := new(HelmChart)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *HelmChart) 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 *HelmChartList) DeepCopyInto(out *HelmChartList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]HelmChart, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmChartList.
func (in *HelmChartList) DeepCopy() *HelmChartList {
if in == nil {
return nil
}
out := new(HelmChartList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *HelmChartList) 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 *HelmChartSpec) DeepCopyInto(out *HelmChartSpec) {
*out = *in
if in.Set != nil {
in, out := &in.Set, &out.Set
*out = make(map[string]intstr.IntOrString, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmChartSpec.
func (in *HelmChartSpec) DeepCopy() *HelmChartSpec {
if in == nil {
return nil
}
out := new(HelmChartSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HelmChartStatus) DeepCopyInto(out *HelmChartStatus) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmChartStatus.
func (in *HelmChartStatus) DeepCopy() *HelmChartStatus {
if in == nil {
return nil
}
out := new(HelmChartStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ListenerConfig) DeepCopyInto(out *ListenerConfig) {
*out = *in
out.Namespaced = in.Namespaced
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Status.DeepCopyInto(&out.Status)

View File

@ -0,0 +1,59 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
// +k8s:deepcopy-gen=package
// +groupName=k3s.cattle.io
package v1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ListenerConfigList is a list of ListenerConfig resources
type ListenerConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []ListenerConfig `json:"items"`
}
func NewListenerConfig(namespace, name string, obj ListenerConfig) *ListenerConfig {
obj.APIVersion, obj.Kind = SchemeGroupVersion.WithKind("ListenerConfig").ToAPIVersionAndKind()
obj.Name = name
obj.Namespace = namespace
return &obj
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// AddonList is a list of Addon resources
type AddonList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Addon `json:"items"`
}
func NewAddon(namespace, name string, obj Addon) *Addon {
obj.APIVersion, obj.Kind = SchemeGroupVersion.WithKind("Addon").ToAPIVersionAndKind()
obj.Name = name
obj.Namespace = namespace
return &obj
}

View File

@ -0,0 +1,58 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
// +k8s:deepcopy-gen=package
// +groupName=k3s.cattle.io
package v1
import (
k3s "github.com/rancher/k3s/pkg/apis/k3s.cattle.io"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: k3s.GroupName, Version: "v1"}
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
)
// Adds the list of known types to Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&Addon{},
&AddonList{},
&ListenerConfig{},
&ListenerConfigList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}

View File

@ -0,0 +1,24 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package k3s
const (
// Package-wide consts from generator "zz_generated_register".
GroupName = "k3s.cattle.io"
)

View File

@ -8,10 +8,11 @@ import (
"strings"
"time"
"github.com/rancher/wrangler/pkg/signals"
"github.com/rancher/k3s/pkg/agent"
"github.com/rancher/k3s/pkg/cli/cmds"
"github.com/rancher/k3s/pkg/datadir"
"github.com/rancher/norman/signal"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
@ -67,7 +68,7 @@ func Run(ctx *cli.Context) error {
cfg.DataDir = dataDir
cfg.Labels = append(cfg.Labels, "node-role.kubernetes.io/worker=true")
contextCtx := signal.SigTermCancelContext(context.Background())
contextCtx := signals.SetupSignalHandler(context.Background())
return agent.Run(contextCtx, cfg)
}

View File

@ -19,7 +19,7 @@ import (
"github.com/rancher/k3s/pkg/datadir"
"github.com/rancher/k3s/pkg/rootless"
"github.com/rancher/k3s/pkg/server"
"github.com/rancher/norman/signal"
"github.com/rancher/wrangler/pkg/signals"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"k8s.io/apimachinery/pkg/util/net"
@ -145,7 +145,7 @@ func run(app *cli.Context, cfg *cmds.Server) error {
notifySocket := os.Getenv("NOTIFY_SOCKET")
os.Unsetenv("NOTIFY_SOCKET")
ctx := signal.SigTermCancelContext(context.Background())
ctx := signals.SetupSignalHandler(context.Background())
certs, err := server.StartServer(ctx, &serverConfig)
if err != nil {
return err

View File

@ -0,0 +1,12 @@
package main
import (
"github.com/rancher/wrangler/pkg/cleanup"
"github.com/sirupsen/logrus"
)
func main() {
if err := cleanup.Cleanup("./pkg/apis"); err != nil {
logrus.Fatal(err)
}
}

View File

@ -1,14 +1,13 @@
package main
import (
"os"
bindata "github.com/jteeuwen/go-bindata"
v1 "github.com/rancher/k3s/types/apis/k3s.cattle.io/v1"
"github.com/rancher/norman/generator"
v1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
controllergen "github.com/rancher/wrangler/pkg/controller-gen"
"github.com/rancher/wrangler/pkg/controller-gen/args"
"github.com/sirupsen/logrus"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
)
var (
@ -16,6 +15,7 @@ var (
)
func main() {
os.Unsetenv("GOPATH")
bc := &bindata.Config{
Input: []bindata.InputConfig{
{
@ -82,38 +82,17 @@ func main() {
logrus.Fatal(err)
}
if err := generator.DefaultGenerate(v1.Schemas, basePackage, false, nil); err != nil {
logrus.Fatal(err)
}
if err := generator.ControllersForForeignTypes(basePackage, corev1.SchemeGroupVersion, []interface{}{
corev1.ServiceAccount{},
corev1.Endpoints{},
corev1.Service{},
corev1.Pod{},
corev1.ConfigMap{},
}, []interface{}{
corev1.Node{},
}); err != nil {
logrus.Fatal(err)
}
if err := generator.ControllersForForeignTypes(basePackage, appsv1.SchemeGroupVersion, []interface{}{
appsv1.DaemonSet{},
appsv1.Deployment{},
}, nil); err != nil {
logrus.Fatal(err)
}
if err := generator.ControllersForForeignTypes(basePackage, batchv1.SchemeGroupVersion, []interface{}{
batchv1.Job{},
}, nil); err != nil {
logrus.Fatal(err)
}
if err := generator.ControllersForForeignTypes(basePackage, rbacv1.SchemeGroupVersion, nil, []interface{}{
rbacv1.ClusterRoleBinding{},
}); err != nil {
logrus.Fatal(err)
}
controllergen.Run(args.Options{
OutputPackage: "github.com/rancher/k3s/pkg/generated",
Boilerplate: "scripts/boilerplate.go.txt",
Groups: map[string]args.Group{
"k3s.cattle.io": {
Types: []interface{}{
v1.ListenerConfig{},
v1.Addon{},
},
GenerateTypes: true,
},
},
})
}

View File

@ -23,8 +23,8 @@ import (
"strings"
"time"
certutil "github.com/rancher/dynamiclistener/cert"
"github.com/rancher/k3s/pkg/daemons/config"
certutil "github.com/rancher/norman/pkg/cert"
"github.com/sirupsen/logrus"
"k8s.io/apiserver/pkg/authentication/authenticator"
"k8s.io/kubernetes/cmd/kube-apiserver/app"

View File

@ -6,8 +6,8 @@ import (
"net/http"
"time"
"github.com/rancher/norman/pkg/kv"
"github.com/rancher/norman/pkg/remotedialer"
"github.com/rancher/remotedialer"
"github.com/rancher/wrangler/pkg/kv"
utilnet "k8s.io/apimachinery/pkg/util/net"
"k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/kubernetes/cmd/kube-apiserver/app"

View File

@ -4,7 +4,7 @@ import (
"os"
"github.com/pkg/errors"
"github.com/rancher/norman/pkg/resolvehome"
"github.com/rancher/wrangler/pkg/resolvehome"
)
const (

View File

@ -14,20 +14,16 @@ import (
"time"
errors2 "github.com/pkg/errors"
v1 "github.com/rancher/k3s/types/apis/k3s.cattle.io/v1"
"github.com/rancher/norman"
"github.com/rancher/norman/objectclient"
"github.com/rancher/norman/pkg/objectset"
"github.com/rancher/norman/types"
v12 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
v1 "github.com/rancher/k3s/pkg/generated/controllers/k3s.cattle.io/v1"
"github.com/rancher/wrangler/pkg/apply"
"github.com/rancher/wrangler/pkg/merr"
"github.com/rancher/wrangler/pkg/objectset"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
yamlDecoder "k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/client-go/discovery"
"k8s.io/client-go/rest"
)
const (
@ -35,21 +31,16 @@ const (
startKey = "_start_"
)
func WatchFiles(ctx context.Context, bases ...string) error {
server := norman.GetServer(ctx)
addons := v1.ClientsFrom(ctx).Addon
func WatchFiles(ctx context.Context, apply apply.Apply, addons v1.AddonController, bases ...string) error {
w := &watcher{
apply: apply,
addonCache: addons.Cache(),
addons: addons,
bases: bases,
restConfig: *server.Runtime.LocalConfig,
discovery: server.K8sClient.Discovery(),
clients: map[schema.GroupVersionKind]*objectclient.ObjectClient{},
}
addons.Enqueue("", startKey)
addons.Interface().AddHandler(ctx, "addon-start", func(key string, _ *v1.Addon) (runtime.Object, error) {
addons.OnChange(ctx, "addon-start", func(key string, _ *v12.Addon) (*v12.Addon, error) {
if key == startKey {
go w.start(ctx)
}
@ -60,13 +51,10 @@ func WatchFiles(ctx context.Context, bases ...string) error {
}
type watcher struct {
addonCache v1.AddonClientCache
apply apply.Apply
addonCache v1.AddonCache
addons v1.AddonClient
bases []string
restConfig rest.Config
discovery discovery.DiscoveryInterface
clients map[schema.GroupVersionKind]*objectclient.ObjectClient
namespaced map[schema.GroupVersionKind]bool
}
func (w *watcher) start(ctx context.Context) {
@ -93,7 +81,7 @@ func (w *watcher) listFiles(force bool) error {
}
}
return types.NewErrors(errs...)
return merr.NewErrors(errs...)
}
func (w *watcher) listFilesIn(base string, force bool) error {
@ -122,7 +110,7 @@ func (w *watcher) listFilesIn(base string, force bool) error {
}
}
return types.NewErrors(errs...)
return merr.NewErrors(errs...)
}
func (w *watcher) deploy(path string, compareChecksum bool) error {
@ -148,24 +136,14 @@ func (w *watcher) deploy(path string, compareChecksum bool) error {
return err
}
clients, err := w.apply(addon, objectSet)
if err != nil {
if err := w.apply.WithOwner(&addon).Apply(objectSet); err != nil {
return err
}
if w.clients == nil {
w.clients = map[schema.GroupVersionKind]*objectclient.ObjectClient{}
}
addon.Spec.Source = path
addon.Spec.Checksum = checksum
addon.Status.GVKs = nil
for gvk, client := range clients {
addon.Status.GVKs = append(addon.Status.GVKs, gvk)
w.clients[gvk] = client
}
if addon.UID == "" {
_, err := w.addons.Create(&addon)
return err
@ -175,55 +153,16 @@ func (w *watcher) deploy(path string, compareChecksum bool) error {
return err
}
func (w *watcher) addon(name string) (v1.Addon, error) {
func (w *watcher) addon(name string) (v12.Addon, error) {
addon, err := w.addonCache.Get(ns, name)
if errors.IsNotFound(err) {
addon = v1.NewAddon(ns, name, v1.Addon{})
addon = v12.NewAddon(ns, name, v12.Addon{})
} else if err != nil {
return v1.Addon{}, err
return v12.Addon{}, err
}
return *addon, nil
}
func (w *watcher) apply(addon v1.Addon, set *objectset.ObjectSet) (map[schema.GroupVersionKind]*objectclient.ObjectClient, error) {
var (
err error
)
op := objectset.NewProcessor(addon.Name)
op.AllowDiscovery(w.discovery, w.restConfig)
ds := op.NewDesiredSet(nil, set)
for _, gvk := range addon.Status.GVKs {
var (
namespaced bool
)
client, ok := w.clients[gvk]
if ok {
namespaced = w.namespaced[gvk]
} else {
client, namespaced, err = objectset.NewDiscoveredClient(gvk, w.restConfig, w.discovery)
if err != nil {
return nil, err
}
if w.namespaced == nil {
w.namespaced = map[schema.GroupVersionKind]bool{}
}
w.namespaced[gvk] = namespaced
}
ds.AddDiscoveredClient(gvk, client, namespaced)
}
if err := ds.Apply(); err != nil {
return nil, err
}
return ds.DiscoveredClients(), nil
}
func objectSet(content []byte) (*objectset.ObjectSet, error) {
objs, err := yamlToObjects(bytes.NewBuffer(content))
if err != nil {

View File

@ -89,7 +89,7 @@ func corednsYaml() (*asset, error) {
return a, nil
}
var _traefikYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\xcc\x4d\x4b\xc4\x30\x10\xc6\xf1\x7b\x3e\xc5\xb0\xb0\xc7\x4d\x5c\x14\x0f\x73\x53\x29\x28\x82\x88\x6f\x57\x99\xa6\xa3\x0d\x79\x69\xc8\x4c\x05\x15\xbf\xbb\xb4\xf4\xb6\xc7\x99\xe7\xcf\x8f\x6a\x78\xe3\x26\x61\x2a\x08\xf1\x5c\xac\x27\xd5\xc4\x36\x4c\xee\xeb\x68\x62\x28\x03\xc2\x2d\xa7\x7c\x33\x52\x53\x93\x59\x69\x20\x25\x34\x00\x85\x32\x23\x68\x23\xfe\x08\x71\xbb\xa5\x92\x67\x84\x38\xf7\x7c\x90\x6f\x51\xce\x46\x2a\xfb\x25\xf7\x0b\x80\x30\xaa\x56\x41\xe7\xf6\xbf\xf7\xaf\xd7\xdd\xd3\x43\xf7\xd2\x3d\xbf\x5f\x3d\xde\xfd\xed\x9d\x28\x69\xf0\x6e\x0d\xc5\x6d\xf0\xe1\x68\x2f\x2f\xec\x99\xd5\xcf\x1f\x03\x20\xac\x8b\x05\xd0\x7a\xf2\x96\x0b\xf5\x89\x07\x84\x9d\xb6\x99\x77\xeb\x20\x92\x4e\xfe\xff\x01\x00\x00\xff\xff\xf0\x93\x36\xe7\xe3\x00\x00\x00")
var _traefikYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\xcc\x4d\x4b\xc7\x30\x0c\xc7\xf1\x7b\x5f\x45\xf8\xc3\x8e\x6b\x1d\x88\x87\xdc\x54\x06\x8a\x20\xe2\xd3\x55\xb2\x2e\xba\xb2\xb6\x2b\x4d\x26\xa8\xf8\xde\x65\x63\x37\x8f\xc9\xef\xcb\x87\x4a\x78\xe5\x2a\x61\xc9\x08\x13\xc7\x64\x3d\xa9\x46\xb6\x61\x71\x9f\x9d\x99\x43\x1e\x11\x6e\x38\xa6\xeb\x89\xaa\x9a\xc4\x4a\x23\x29\xa1\x01\xc8\x94\x18\x41\x2b\xf1\x7b\x98\x8f\x5b\x0a\x79\x46\x98\xd7\x81\x5b\xf9\x12\xe5\x64\xa4\xb0\xdf\x72\xbf\x01\x08\x93\x6a\x11\x74\xae\xf9\xb9\x7b\xb9\xea\x1f\xef\xfb\xe7\xfe\xe9\xed\xf2\xe1\xf6\xb7\x71\xa2\xa4\xc1\xbb\x3d\x14\x77\xc0\x6d\x67\x2f\xce\xed\x99\xd5\x8f\x6f\x03\x20\xac\x9b\x05\x50\x07\xf2\x96\x33\x0d\x91\x47\x84\x93\xd6\x95\x4f\xfb\x20\x12\xff\xfd\xff\x02\x00\x00\xff\xff\x29\xa0\xaa\xfe\xe4\x00\x00\x00")
func traefikYamlBytes() ([]byte, error) {
return bindataRead(

View File

@ -0,0 +1,90 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package versioned
import (
k3sv1 "github.com/rancher/k3s/pkg/generated/clientset/versioned/typed/k3s.cattle.io/v1"
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
K3sV1() k3sv1.K3sV1Interface
}
// Clientset contains the clients for groups. Each group has exactly one
// version included in a Clientset.
type Clientset struct {
*discovery.DiscoveryClient
k3sV1 *k3sv1.K3sV1Client
}
// K3sV1 retrieves the K3sV1Client
func (c *Clientset) K3sV1() k3sv1.K3sV1Interface {
return c.k3sV1
}
// 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.
func NewForConfig(c *rest.Config) (*Clientset, error) {
configShallowCopy := *c
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
}
var cs Clientset
var err error
cs.k3sV1, err = k3sv1.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.k3sV1 = k3sv1.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.k3sV1 = k3sv1.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs
}

View File

@ -0,0 +1,20 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
// This package has the automatically generated clientset.
package versioned

View File

@ -0,0 +1,77 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package fake
import (
clientset "github.com/rancher/k3s/pkg/generated/clientset/versioned"
k3sv1 "github.com/rancher/k3s/pkg/generated/clientset/versioned/typed/k3s.cattle.io/v1"
fakek3sv1 "github.com/rancher/k3s/pkg/generated/clientset/versioned/typed/k3s.cattle.io/v1/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{}
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
}
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
return c.discovery
}
var _ clientset.Interface = &Clientset{}
// K3sV1 retrieves the K3sV1Client
func (c *Clientset) K3sV1() k3sv1.K3sV1Interface {
return &fakek3sv1.FakeK3sV1{Fake: &c.Fake}
}

View File

@ -0,0 +1,20 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
// This package has the automatically generated fake clientset.
package fake

View File

@ -0,0 +1,56 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package fake
import (
k3sv1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
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{
k3sv1.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))
}

View File

@ -0,0 +1,20 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
// This package contains the scheme of the automatically generated clientset.
package scheme

View File

@ -0,0 +1,56 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package scheme
import (
k3sv1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
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{
k3sv1.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))
}

View File

@ -0,0 +1,191 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
"time"
v1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
scheme "github.com/rancher/k3s/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"
)
// AddonsGetter has a method to return a AddonInterface.
// A group's client should implement this interface.
type AddonsGetter interface {
Addons(namespace string) AddonInterface
}
// AddonInterface has methods to work with Addon resources.
type AddonInterface interface {
Create(*v1.Addon) (*v1.Addon, error)
Update(*v1.Addon) (*v1.Addon, error)
UpdateStatus(*v1.Addon) (*v1.Addon, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error
Get(name string, options metav1.GetOptions) (*v1.Addon, error)
List(opts metav1.ListOptions) (*v1.AddonList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Addon, err error)
AddonExpansion
}
// addons implements AddonInterface
type addons struct {
client rest.Interface
ns string
}
// newAddons returns a Addons
func newAddons(c *K3sV1Client, namespace string) *addons {
return &addons{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the addon, and returns the corresponding addon object, and an error if there is any.
func (c *addons) Get(name string, options metav1.GetOptions) (result *v1.Addon, err error) {
result = &v1.Addon{}
err = c.client.Get().
Namespace(c.ns).
Resource("addons").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of Addons that match those selectors.
func (c *addons) List(opts metav1.ListOptions) (result *v1.AddonList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1.AddonList{}
err = c.client.Get().
Namespace(c.ns).
Resource("addons").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested addons.
func (c *addons) Watch(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("addons").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
// Create takes the representation of a addon and creates it. Returns the server's representation of the addon, and an error, if there is any.
func (c *addons) Create(addon *v1.Addon) (result *v1.Addon, err error) {
result = &v1.Addon{}
err = c.client.Post().
Namespace(c.ns).
Resource("addons").
Body(addon).
Do().
Into(result)
return
}
// Update takes the representation of a addon and updates it. Returns the server's representation of the addon, and an error, if there is any.
func (c *addons) Update(addon *v1.Addon) (result *v1.Addon, err error) {
result = &v1.Addon{}
err = c.client.Put().
Namespace(c.ns).
Resource("addons").
Name(addon.Name).
Body(addon).
Do().
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *addons) UpdateStatus(addon *v1.Addon) (result *v1.Addon, err error) {
result = &v1.Addon{}
err = c.client.Put().
Namespace(c.ns).
Resource("addons").
Name(addon.Name).
SubResource("status").
Body(addon).
Do().
Into(result)
return
}
// Delete takes name of the addon and deletes it. Returns an error if one occurs.
func (c *addons) Delete(name string, options *metav1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("addons").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *addons) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("addons").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()
}
// Patch applies the patch and returns the patched addon.
func (c *addons) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Addon, err error) {
result = &v1.Addon{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("addons").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}

View File

@ -0,0 +1,20 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
// This package has the automatically generated typed clients.
package v1

View File

@ -0,0 +1,20 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
// Package fake has the automatically generated clients.
package fake

View File

@ -0,0 +1,140 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package fake
import (
k3scattleiov1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/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"
)
// FakeAddons implements AddonInterface
type FakeAddons struct {
Fake *FakeK3sV1
ns string
}
var addonsResource = schema.GroupVersionResource{Group: "k3s.cattle.io", Version: "v1", Resource: "addons"}
var addonsKind = schema.GroupVersionKind{Group: "k3s.cattle.io", Version: "v1", Kind: "Addon"}
// Get takes name of the addon, and returns the corresponding addon object, and an error if there is any.
func (c *FakeAddons) Get(name string, options v1.GetOptions) (result *k3scattleiov1.Addon, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(addonsResource, c.ns, name), &k3scattleiov1.Addon{})
if obj == nil {
return nil, err
}
return obj.(*k3scattleiov1.Addon), err
}
// List takes label and field selectors, and returns the list of Addons that match those selectors.
func (c *FakeAddons) List(opts v1.ListOptions) (result *k3scattleiov1.AddonList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(addonsResource, addonsKind, c.ns, opts), &k3scattleiov1.AddonList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &k3scattleiov1.AddonList{ListMeta: obj.(*k3scattleiov1.AddonList).ListMeta}
for _, item := range obj.(*k3scattleiov1.AddonList).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 addons.
func (c *FakeAddons) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(addonsResource, c.ns, opts))
}
// Create takes the representation of a addon and creates it. Returns the server's representation of the addon, and an error, if there is any.
func (c *FakeAddons) Create(addon *k3scattleiov1.Addon) (result *k3scattleiov1.Addon, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(addonsResource, c.ns, addon), &k3scattleiov1.Addon{})
if obj == nil {
return nil, err
}
return obj.(*k3scattleiov1.Addon), err
}
// Update takes the representation of a addon and updates it. Returns the server's representation of the addon, and an error, if there is any.
func (c *FakeAddons) Update(addon *k3scattleiov1.Addon) (result *k3scattleiov1.Addon, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(addonsResource, c.ns, addon), &k3scattleiov1.Addon{})
if obj == nil {
return nil, err
}
return obj.(*k3scattleiov1.Addon), 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 *FakeAddons) UpdateStatus(addon *k3scattleiov1.Addon) (*k3scattleiov1.Addon, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(addonsResource, "status", c.ns, addon), &k3scattleiov1.Addon{})
if obj == nil {
return nil, err
}
return obj.(*k3scattleiov1.Addon), err
}
// Delete takes name of the addon and deletes it. Returns an error if one occurs.
func (c *FakeAddons) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(addonsResource, c.ns, name), &k3scattleiov1.Addon{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeAddons) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(addonsResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &k3scattleiov1.AddonList{})
return err
}
// Patch applies the patch and returns the patched addon.
func (c *FakeAddons) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *k3scattleiov1.Addon, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(addonsResource, c.ns, name, pt, data, subresources...), &k3scattleiov1.Addon{})
if obj == nil {
return nil, err
}
return obj.(*k3scattleiov1.Addon), err
}

View File

@ -0,0 +1,44 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package fake
import (
v1 "github.com/rancher/k3s/pkg/generated/clientset/versioned/typed/k3s.cattle.io/v1"
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
)
type FakeK3sV1 struct {
*testing.Fake
}
func (c *FakeK3sV1) Addons(namespace string) v1.AddonInterface {
return &FakeAddons{c, namespace}
}
func (c *FakeK3sV1) ListenerConfigs(namespace string) v1.ListenerConfigInterface {
return &FakeListenerConfigs{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeK3sV1) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}

View File

@ -0,0 +1,140 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package fake
import (
k3scattleiov1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/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"
)
// FakeListenerConfigs implements ListenerConfigInterface
type FakeListenerConfigs struct {
Fake *FakeK3sV1
ns string
}
var listenerconfigsResource = schema.GroupVersionResource{Group: "k3s.cattle.io", Version: "v1", Resource: "listenerconfigs"}
var listenerconfigsKind = schema.GroupVersionKind{Group: "k3s.cattle.io", Version: "v1", Kind: "ListenerConfig"}
// Get takes name of the listenerConfig, and returns the corresponding listenerConfig object, and an error if there is any.
func (c *FakeListenerConfigs) Get(name string, options v1.GetOptions) (result *k3scattleiov1.ListenerConfig, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(listenerconfigsResource, c.ns, name), &k3scattleiov1.ListenerConfig{})
if obj == nil {
return nil, err
}
return obj.(*k3scattleiov1.ListenerConfig), err
}
// List takes label and field selectors, and returns the list of ListenerConfigs that match those selectors.
func (c *FakeListenerConfigs) List(opts v1.ListOptions) (result *k3scattleiov1.ListenerConfigList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(listenerconfigsResource, listenerconfigsKind, c.ns, opts), &k3scattleiov1.ListenerConfigList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &k3scattleiov1.ListenerConfigList{ListMeta: obj.(*k3scattleiov1.ListenerConfigList).ListMeta}
for _, item := range obj.(*k3scattleiov1.ListenerConfigList).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 listenerConfigs.
func (c *FakeListenerConfigs) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(listenerconfigsResource, c.ns, opts))
}
// Create takes the representation of a listenerConfig and creates it. Returns the server's representation of the listenerConfig, and an error, if there is any.
func (c *FakeListenerConfigs) Create(listenerConfig *k3scattleiov1.ListenerConfig) (result *k3scattleiov1.ListenerConfig, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(listenerconfigsResource, c.ns, listenerConfig), &k3scattleiov1.ListenerConfig{})
if obj == nil {
return nil, err
}
return obj.(*k3scattleiov1.ListenerConfig), err
}
// Update takes the representation of a listenerConfig and updates it. Returns the server's representation of the listenerConfig, and an error, if there is any.
func (c *FakeListenerConfigs) Update(listenerConfig *k3scattleiov1.ListenerConfig) (result *k3scattleiov1.ListenerConfig, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(listenerconfigsResource, c.ns, listenerConfig), &k3scattleiov1.ListenerConfig{})
if obj == nil {
return nil, err
}
return obj.(*k3scattleiov1.ListenerConfig), 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 *FakeListenerConfigs) UpdateStatus(listenerConfig *k3scattleiov1.ListenerConfig) (*k3scattleiov1.ListenerConfig, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(listenerconfigsResource, "status", c.ns, listenerConfig), &k3scattleiov1.ListenerConfig{})
if obj == nil {
return nil, err
}
return obj.(*k3scattleiov1.ListenerConfig), err
}
// Delete takes name of the listenerConfig and deletes it. Returns an error if one occurs.
func (c *FakeListenerConfigs) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(listenerconfigsResource, c.ns, name), &k3scattleiov1.ListenerConfig{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeListenerConfigs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(listenerconfigsResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &k3scattleiov1.ListenerConfigList{})
return err
}
// Patch applies the patch and returns the patched listenerConfig.
func (c *FakeListenerConfigs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *k3scattleiov1.ListenerConfig, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(listenerconfigsResource, c.ns, name, pt, data, subresources...), &k3scattleiov1.ListenerConfig{})
if obj == nil {
return nil, err
}
return obj.(*k3scattleiov1.ListenerConfig), err
}

View File

@ -0,0 +1,23 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
type AddonExpansion interface{}
type ListenerConfigExpansion interface{}

View File

@ -0,0 +1,95 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
v1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
"github.com/rancher/k3s/pkg/generated/clientset/versioned/scheme"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
rest "k8s.io/client-go/rest"
)
type K3sV1Interface interface {
RESTClient() rest.Interface
AddonsGetter
ListenerConfigsGetter
}
// K3sV1Client is used to interact with features provided by the k3s.cattle.io group.
type K3sV1Client struct {
restClient rest.Interface
}
func (c *K3sV1Client) Addons(namespace string) AddonInterface {
return newAddons(c, namespace)
}
func (c *K3sV1Client) ListenerConfigs(namespace string) ListenerConfigInterface {
return newListenerConfigs(c, namespace)
}
// NewForConfig creates a new K3sV1Client for the given config.
func NewForConfig(c *rest.Config) (*K3sV1Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &K3sV1Client{client}, nil
}
// NewForConfigOrDie creates a new K3sV1Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *K3sV1Client {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}
// New creates a new K3sV1Client for the given RESTClient.
func New(c rest.Interface) *K3sV1Client {
return &K3sV1Client{c}
}
func setConfigDefaults(config *rest.Config) error {
gv := v1.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
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 *K3sV1Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}

View File

@ -0,0 +1,191 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
"time"
v1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
scheme "github.com/rancher/k3s/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"
)
// ListenerConfigsGetter has a method to return a ListenerConfigInterface.
// A group's client should implement this interface.
type ListenerConfigsGetter interface {
ListenerConfigs(namespace string) ListenerConfigInterface
}
// ListenerConfigInterface has methods to work with ListenerConfig resources.
type ListenerConfigInterface interface {
Create(*v1.ListenerConfig) (*v1.ListenerConfig, error)
Update(*v1.ListenerConfig) (*v1.ListenerConfig, error)
UpdateStatus(*v1.ListenerConfig) (*v1.ListenerConfig, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error
Get(name string, options metav1.GetOptions) (*v1.ListenerConfig, error)
List(opts metav1.ListOptions) (*v1.ListenerConfigList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ListenerConfig, err error)
ListenerConfigExpansion
}
// listenerConfigs implements ListenerConfigInterface
type listenerConfigs struct {
client rest.Interface
ns string
}
// newListenerConfigs returns a ListenerConfigs
func newListenerConfigs(c *K3sV1Client, namespace string) *listenerConfigs {
return &listenerConfigs{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the listenerConfig, and returns the corresponding listenerConfig object, and an error if there is any.
func (c *listenerConfigs) Get(name string, options metav1.GetOptions) (result *v1.ListenerConfig, err error) {
result = &v1.ListenerConfig{}
err = c.client.Get().
Namespace(c.ns).
Resource("listenerconfigs").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of ListenerConfigs that match those selectors.
func (c *listenerConfigs) List(opts metav1.ListOptions) (result *v1.ListenerConfigList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1.ListenerConfigList{}
err = c.client.Get().
Namespace(c.ns).
Resource("listenerconfigs").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested listenerConfigs.
func (c *listenerConfigs) Watch(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("listenerconfigs").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
// Create takes the representation of a listenerConfig and creates it. Returns the server's representation of the listenerConfig, and an error, if there is any.
func (c *listenerConfigs) Create(listenerConfig *v1.ListenerConfig) (result *v1.ListenerConfig, err error) {
result = &v1.ListenerConfig{}
err = c.client.Post().
Namespace(c.ns).
Resource("listenerconfigs").
Body(listenerConfig).
Do().
Into(result)
return
}
// Update takes the representation of a listenerConfig and updates it. Returns the server's representation of the listenerConfig, and an error, if there is any.
func (c *listenerConfigs) Update(listenerConfig *v1.ListenerConfig) (result *v1.ListenerConfig, err error) {
result = &v1.ListenerConfig{}
err = c.client.Put().
Namespace(c.ns).
Resource("listenerconfigs").
Name(listenerConfig.Name).
Body(listenerConfig).
Do().
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *listenerConfigs) UpdateStatus(listenerConfig *v1.ListenerConfig) (result *v1.ListenerConfig, err error) {
result = &v1.ListenerConfig{}
err = c.client.Put().
Namespace(c.ns).
Resource("listenerconfigs").
Name(listenerConfig.Name).
SubResource("status").
Body(listenerConfig).
Do().
Into(result)
return
}
// Delete takes name of the listenerConfig and deletes it. Returns an error if one occurs.
func (c *listenerConfigs) Delete(name string, options *metav1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("listenerconfigs").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *listenerConfigs) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("listenerconfigs").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()
}
// Patch applies the patch and returns the patched listenerConfig.
func (c *listenerConfigs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ListenerConfig, err error) {
result = &v1.ListenerConfig{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("listenerconfigs").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}

View File

@ -0,0 +1,101 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package k3s
import (
"context"
"time"
clientset "github.com/rancher/k3s/pkg/generated/clientset/versioned"
informers "github.com/rancher/k3s/pkg/generated/informers/externalversions"
"github.com/rancher/wrangler/pkg/generic"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/rest"
)
type Factory struct {
synced bool
informerFactory informers.SharedInformerFactory
clientset clientset.Interface
controllerManager *generic.ControllerManager
threadiness map[schema.GroupVersionKind]int
}
func NewFactoryFromConfigOrDie(config *rest.Config) *Factory {
f, err := NewFactoryFromConfig(config)
if err != nil {
panic(err)
}
return f
}
func NewFactoryFromConfig(config *rest.Config) (*Factory, error) {
cs, err := clientset.NewForConfig(config)
if err != nil {
return nil, err
}
informerFactory := informers.NewSharedInformerFactory(cs, 2*time.Hour)
return NewFactory(cs, informerFactory), nil
}
func NewFactoryFromConfigWithNamespace(config *rest.Config, namespace string) (*Factory, error) {
if namespace == "" {
return NewFactoryFromConfig(config)
}
cs, err := clientset.NewForConfig(config)
if err != nil {
return nil, err
}
informerFactory := informers.NewSharedInformerFactoryWithOptions(cs, 2*time.Hour, informers.WithNamespace(namespace))
return NewFactory(cs, informerFactory), nil
}
func NewFactory(clientset clientset.Interface, informerFactory informers.SharedInformerFactory) *Factory {
return &Factory{
threadiness: map[schema.GroupVersionKind]int{},
controllerManager: &generic.ControllerManager{},
clientset: clientset,
informerFactory: informerFactory,
}
}
func (c *Factory) SetThreadiness(gvk schema.GroupVersionKind, threadiness int) {
c.threadiness[gvk] = threadiness
}
func (c *Factory) Sync(ctx context.Context) error {
c.informerFactory.Start(ctx.Done())
c.informerFactory.WaitForCacheSync(ctx.Done())
return nil
}
func (c *Factory) Start(ctx context.Context, defaultThreadiness int) error {
if err := c.Sync(ctx); err != nil {
return err
}
return c.controllerManager.Start(ctx, defaultThreadiness, c.threadiness)
}
func (c *Factory) K3s() Interface {
return New(c.controllerManager, c.informerFactory.K3s(), c.clientset)
}

View File

@ -0,0 +1,50 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package k3s
import (
clientset "github.com/rancher/k3s/pkg/generated/clientset/versioned"
v1 "github.com/rancher/k3s/pkg/generated/controllers/k3s.cattle.io/v1"
informers "github.com/rancher/k3s/pkg/generated/informers/externalversions/k3s.cattle.io"
"github.com/rancher/wrangler/pkg/generic"
)
type Interface interface {
V1() v1.Interface
}
type group struct {
controllerManager *generic.ControllerManager
informers informers.Interface
client clientset.Interface
}
// New returns a new Interface.
func New(controllerManager *generic.ControllerManager, informers informers.Interface,
client clientset.Interface) Interface {
return &group{
controllerManager: controllerManager,
informers: informers,
client: client,
}
}
func (g *group) V1() v1.Interface {
return v1.New(g.controllerManager, g.client.K3sV1(), g.informers.V1())
}

View File

@ -0,0 +1,242 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
"context"
v1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
clientset "github.com/rancher/k3s/pkg/generated/clientset/versioned/typed/k3s.cattle.io/v1"
informers "github.com/rancher/k3s/pkg/generated/informers/externalversions/k3s.cattle.io/v1"
listers "github.com/rancher/k3s/pkg/generated/listers/k3s.cattle.io/v1"
"github.com/rancher/wrangler/pkg/generic"
"k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
type AddonHandler func(string, *v1.Addon) (*v1.Addon, error)
type AddonController interface {
AddonClient
OnChange(ctx context.Context, name string, sync AddonHandler)
OnRemove(ctx context.Context, name string, sync AddonHandler)
Enqueue(namespace, name string)
Cache() AddonCache
Informer() cache.SharedIndexInformer
GroupVersionKind() schema.GroupVersionKind
AddGenericHandler(ctx context.Context, name string, handler generic.Handler)
AddGenericRemoveHandler(ctx context.Context, name string, handler generic.Handler)
Updater() generic.Updater
}
type AddonClient interface {
Create(*v1.Addon) (*v1.Addon, error)
Update(*v1.Addon) (*v1.Addon, error)
UpdateStatus(*v1.Addon) (*v1.Addon, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
Get(namespace, name string, options metav1.GetOptions) (*v1.Addon, error)
List(namespace string, opts metav1.ListOptions) (*v1.AddonList, error)
Watch(namespace string, opts metav1.ListOptions) (watch.Interface, error)
Patch(namespace, name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Addon, err error)
}
type AddonCache interface {
Get(namespace, name string) (*v1.Addon, error)
List(namespace string, selector labels.Selector) ([]*v1.Addon, error)
AddIndexer(indexName string, indexer AddonIndexer)
GetByIndex(indexName, key string) ([]*v1.Addon, error)
}
type AddonIndexer func(obj *v1.Addon) ([]string, error)
type addonController struct {
controllerManager *generic.ControllerManager
clientGetter clientset.AddonsGetter
informer informers.AddonInformer
gvk schema.GroupVersionKind
}
func NewAddonController(gvk schema.GroupVersionKind, controllerManager *generic.ControllerManager, clientGetter clientset.AddonsGetter, informer informers.AddonInformer) AddonController {
return &addonController{
controllerManager: controllerManager,
clientGetter: clientGetter,
informer: informer,
gvk: gvk,
}
}
func FromAddonHandlerToHandler(sync AddonHandler) generic.Handler {
return func(key string, obj runtime.Object) (ret runtime.Object, err error) {
var v *v1.Addon
if obj == nil {
v, err = sync(key, nil)
} else {
v, err = sync(key, obj.(*v1.Addon))
}
if v == nil {
return nil, err
}
return v, err
}
}
func (c *addonController) Updater() generic.Updater {
return func(obj runtime.Object) (runtime.Object, error) {
newObj, err := c.Update(obj.(*v1.Addon))
if newObj == nil {
return nil, err
}
return newObj, err
}
}
func UpdateAddonOnChange(updater generic.Updater, handler AddonHandler) AddonHandler {
return func(key string, obj *v1.Addon) (*v1.Addon, error) {
if obj == nil {
return handler(key, nil)
}
copyObj := obj.DeepCopy()
newObj, err := handler(key, copyObj)
if newObj != nil {
copyObj = newObj
}
if obj.ResourceVersion == copyObj.ResourceVersion && !equality.Semantic.DeepEqual(obj, copyObj) {
newObj, err := updater(copyObj)
if newObj != nil && err == nil {
copyObj = newObj.(*v1.Addon)
}
}
return copyObj, err
}
}
func (c *addonController) AddGenericHandler(ctx context.Context, name string, handler generic.Handler) {
c.controllerManager.AddHandler(ctx, c.gvk, c.informer.Informer(), name, handler)
}
func (c *addonController) AddGenericRemoveHandler(ctx context.Context, name string, handler generic.Handler) {
removeHandler := generic.NewRemoveHandler(name, c.Updater(), handler)
c.controllerManager.AddHandler(ctx, c.gvk, c.informer.Informer(), name, removeHandler)
}
func (c *addonController) OnChange(ctx context.Context, name string, sync AddonHandler) {
c.AddGenericHandler(ctx, name, FromAddonHandlerToHandler(sync))
}
func (c *addonController) OnRemove(ctx context.Context, name string, sync AddonHandler) {
removeHandler := generic.NewRemoveHandler(name, c.Updater(), FromAddonHandlerToHandler(sync))
c.AddGenericHandler(ctx, name, removeHandler)
}
func (c *addonController) Enqueue(namespace, name string) {
c.controllerManager.Enqueue(c.gvk, c.informer.Informer(), namespace, name)
}
func (c *addonController) Informer() cache.SharedIndexInformer {
return c.informer.Informer()
}
func (c *addonController) GroupVersionKind() schema.GroupVersionKind {
return c.gvk
}
func (c *addonController) Cache() AddonCache {
return &addonCache{
lister: c.informer.Lister(),
indexer: c.informer.Informer().GetIndexer(),
}
}
func (c *addonController) Create(obj *v1.Addon) (*v1.Addon, error) {
return c.clientGetter.Addons(obj.Namespace).Create(obj)
}
func (c *addonController) Update(obj *v1.Addon) (*v1.Addon, error) {
return c.clientGetter.Addons(obj.Namespace).Update(obj)
}
func (c *addonController) UpdateStatus(obj *v1.Addon) (*v1.Addon, error) {
return c.clientGetter.Addons(obj.Namespace).UpdateStatus(obj)
}
func (c *addonController) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return c.clientGetter.Addons(namespace).Delete(name, options)
}
func (c *addonController) Get(namespace, name string, options metav1.GetOptions) (*v1.Addon, error) {
return c.clientGetter.Addons(namespace).Get(name, options)
}
func (c *addonController) List(namespace string, opts metav1.ListOptions) (*v1.AddonList, error) {
return c.clientGetter.Addons(namespace).List(opts)
}
func (c *addonController) Watch(namespace string, opts metav1.ListOptions) (watch.Interface, error) {
return c.clientGetter.Addons(namespace).Watch(opts)
}
func (c *addonController) Patch(namespace, name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Addon, err error) {
return c.clientGetter.Addons(namespace).Patch(name, pt, data, subresources...)
}
type addonCache struct {
lister listers.AddonLister
indexer cache.Indexer
}
func (c *addonCache) Get(namespace, name string) (*v1.Addon, error) {
return c.lister.Addons(namespace).Get(name)
}
func (c *addonCache) List(namespace string, selector labels.Selector) ([]*v1.Addon, error) {
return c.lister.Addons(namespace).List(selector)
}
func (c *addonCache) AddIndexer(indexName string, indexer AddonIndexer) {
utilruntime.Must(c.indexer.AddIndexers(map[string]cache.IndexFunc{
indexName: func(obj interface{}) (strings []string, e error) {
return indexer(obj.(*v1.Addon))
},
}))
}
func (c *addonCache) GetByIndex(indexName, key string) (result []*v1.Addon, err error) {
objs, err := c.indexer.ByIndex(indexName, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
result = append(result, obj.(*v1.Addon))
}
return result, nil
}

View File

@ -0,0 +1,53 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
v1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
clientset "github.com/rancher/k3s/pkg/generated/clientset/versioned/typed/k3s.cattle.io/v1"
informers "github.com/rancher/k3s/pkg/generated/informers/externalversions/k3s.cattle.io/v1"
"github.com/rancher/wrangler/pkg/generic"
)
type Interface interface {
Addon() AddonController
ListenerConfig() ListenerConfigController
}
func New(controllerManager *generic.ControllerManager, client clientset.K3sV1Interface,
informers informers.Interface) Interface {
return &version{
controllerManager: controllerManager,
client: client,
informers: informers,
}
}
type version struct {
controllerManager *generic.ControllerManager
informers informers.Interface
client clientset.K3sV1Interface
}
func (c *version) Addon() AddonController {
return NewAddonController(v1.SchemeGroupVersion.WithKind("Addon"), c.controllerManager, c.client, c.informers.Addons())
}
func (c *version) ListenerConfig() ListenerConfigController {
return NewListenerConfigController(v1.SchemeGroupVersion.WithKind("ListenerConfig"), c.controllerManager, c.client, c.informers.ListenerConfigs())
}

View File

@ -0,0 +1,242 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
"context"
v1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
clientset "github.com/rancher/k3s/pkg/generated/clientset/versioned/typed/k3s.cattle.io/v1"
informers "github.com/rancher/k3s/pkg/generated/informers/externalversions/k3s.cattle.io/v1"
listers "github.com/rancher/k3s/pkg/generated/listers/k3s.cattle.io/v1"
"github.com/rancher/wrangler/pkg/generic"
"k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
type ListenerConfigHandler func(string, *v1.ListenerConfig) (*v1.ListenerConfig, error)
type ListenerConfigController interface {
ListenerConfigClient
OnChange(ctx context.Context, name string, sync ListenerConfigHandler)
OnRemove(ctx context.Context, name string, sync ListenerConfigHandler)
Enqueue(namespace, name string)
Cache() ListenerConfigCache
Informer() cache.SharedIndexInformer
GroupVersionKind() schema.GroupVersionKind
AddGenericHandler(ctx context.Context, name string, handler generic.Handler)
AddGenericRemoveHandler(ctx context.Context, name string, handler generic.Handler)
Updater() generic.Updater
}
type ListenerConfigClient interface {
Create(*v1.ListenerConfig) (*v1.ListenerConfig, error)
Update(*v1.ListenerConfig) (*v1.ListenerConfig, error)
UpdateStatus(*v1.ListenerConfig) (*v1.ListenerConfig, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
Get(namespace, name string, options metav1.GetOptions) (*v1.ListenerConfig, error)
List(namespace string, opts metav1.ListOptions) (*v1.ListenerConfigList, error)
Watch(namespace string, opts metav1.ListOptions) (watch.Interface, error)
Patch(namespace, name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ListenerConfig, err error)
}
type ListenerConfigCache interface {
Get(namespace, name string) (*v1.ListenerConfig, error)
List(namespace string, selector labels.Selector) ([]*v1.ListenerConfig, error)
AddIndexer(indexName string, indexer ListenerConfigIndexer)
GetByIndex(indexName, key string) ([]*v1.ListenerConfig, error)
}
type ListenerConfigIndexer func(obj *v1.ListenerConfig) ([]string, error)
type listenerConfigController struct {
controllerManager *generic.ControllerManager
clientGetter clientset.ListenerConfigsGetter
informer informers.ListenerConfigInformer
gvk schema.GroupVersionKind
}
func NewListenerConfigController(gvk schema.GroupVersionKind, controllerManager *generic.ControllerManager, clientGetter clientset.ListenerConfigsGetter, informer informers.ListenerConfigInformer) ListenerConfigController {
return &listenerConfigController{
controllerManager: controllerManager,
clientGetter: clientGetter,
informer: informer,
gvk: gvk,
}
}
func FromListenerConfigHandlerToHandler(sync ListenerConfigHandler) generic.Handler {
return func(key string, obj runtime.Object) (ret runtime.Object, err error) {
var v *v1.ListenerConfig
if obj == nil {
v, err = sync(key, nil)
} else {
v, err = sync(key, obj.(*v1.ListenerConfig))
}
if v == nil {
return nil, err
}
return v, err
}
}
func (c *listenerConfigController) Updater() generic.Updater {
return func(obj runtime.Object) (runtime.Object, error) {
newObj, err := c.Update(obj.(*v1.ListenerConfig))
if newObj == nil {
return nil, err
}
return newObj, err
}
}
func UpdateListenerConfigOnChange(updater generic.Updater, handler ListenerConfigHandler) ListenerConfigHandler {
return func(key string, obj *v1.ListenerConfig) (*v1.ListenerConfig, error) {
if obj == nil {
return handler(key, nil)
}
copyObj := obj.DeepCopy()
newObj, err := handler(key, copyObj)
if newObj != nil {
copyObj = newObj
}
if obj.ResourceVersion == copyObj.ResourceVersion && !equality.Semantic.DeepEqual(obj, copyObj) {
newObj, err := updater(copyObj)
if newObj != nil && err == nil {
copyObj = newObj.(*v1.ListenerConfig)
}
}
return copyObj, err
}
}
func (c *listenerConfigController) AddGenericHandler(ctx context.Context, name string, handler generic.Handler) {
c.controllerManager.AddHandler(ctx, c.gvk, c.informer.Informer(), name, handler)
}
func (c *listenerConfigController) AddGenericRemoveHandler(ctx context.Context, name string, handler generic.Handler) {
removeHandler := generic.NewRemoveHandler(name, c.Updater(), handler)
c.controllerManager.AddHandler(ctx, c.gvk, c.informer.Informer(), name, removeHandler)
}
func (c *listenerConfigController) OnChange(ctx context.Context, name string, sync ListenerConfigHandler) {
c.AddGenericHandler(ctx, name, FromListenerConfigHandlerToHandler(sync))
}
func (c *listenerConfigController) OnRemove(ctx context.Context, name string, sync ListenerConfigHandler) {
removeHandler := generic.NewRemoveHandler(name, c.Updater(), FromListenerConfigHandlerToHandler(sync))
c.AddGenericHandler(ctx, name, removeHandler)
}
func (c *listenerConfigController) Enqueue(namespace, name string) {
c.controllerManager.Enqueue(c.gvk, c.informer.Informer(), namespace, name)
}
func (c *listenerConfigController) Informer() cache.SharedIndexInformer {
return c.informer.Informer()
}
func (c *listenerConfigController) GroupVersionKind() schema.GroupVersionKind {
return c.gvk
}
func (c *listenerConfigController) Cache() ListenerConfigCache {
return &listenerConfigCache{
lister: c.informer.Lister(),
indexer: c.informer.Informer().GetIndexer(),
}
}
func (c *listenerConfigController) Create(obj *v1.ListenerConfig) (*v1.ListenerConfig, error) {
return c.clientGetter.ListenerConfigs(obj.Namespace).Create(obj)
}
func (c *listenerConfigController) Update(obj *v1.ListenerConfig) (*v1.ListenerConfig, error) {
return c.clientGetter.ListenerConfigs(obj.Namespace).Update(obj)
}
func (c *listenerConfigController) UpdateStatus(obj *v1.ListenerConfig) (*v1.ListenerConfig, error) {
return c.clientGetter.ListenerConfigs(obj.Namespace).UpdateStatus(obj)
}
func (c *listenerConfigController) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return c.clientGetter.ListenerConfigs(namespace).Delete(name, options)
}
func (c *listenerConfigController) Get(namespace, name string, options metav1.GetOptions) (*v1.ListenerConfig, error) {
return c.clientGetter.ListenerConfigs(namespace).Get(name, options)
}
func (c *listenerConfigController) List(namespace string, opts metav1.ListOptions) (*v1.ListenerConfigList, error) {
return c.clientGetter.ListenerConfigs(namespace).List(opts)
}
func (c *listenerConfigController) Watch(namespace string, opts metav1.ListOptions) (watch.Interface, error) {
return c.clientGetter.ListenerConfigs(namespace).Watch(opts)
}
func (c *listenerConfigController) Patch(namespace, name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ListenerConfig, err error) {
return c.clientGetter.ListenerConfigs(namespace).Patch(name, pt, data, subresources...)
}
type listenerConfigCache struct {
lister listers.ListenerConfigLister
indexer cache.Indexer
}
func (c *listenerConfigCache) Get(namespace, name string) (*v1.ListenerConfig, error) {
return c.lister.ListenerConfigs(namespace).Get(name)
}
func (c *listenerConfigCache) List(namespace string, selector labels.Selector) ([]*v1.ListenerConfig, error) {
return c.lister.ListenerConfigs(namespace).List(selector)
}
func (c *listenerConfigCache) AddIndexer(indexName string, indexer ListenerConfigIndexer) {
utilruntime.Must(c.indexer.AddIndexers(map[string]cache.IndexFunc{
indexName: func(obj interface{}) (strings []string, e error) {
return indexer(obj.(*v1.ListenerConfig))
},
}))
}
func (c *listenerConfigCache) GetByIndex(indexName, key string) (result []*v1.ListenerConfig, err error) {
objs, err := c.indexer.ByIndex(indexName, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
result = append(result, obj.(*v1.ListenerConfig))
}
return result, nil
}

View File

@ -0,0 +1,180 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package externalversions
import (
reflect "reflect"
sync "sync"
time "time"
versioned "github.com/rancher/k3s/pkg/generated/clientset/versioned"
internalinterfaces "github.com/rancher/k3s/pkg/generated/informers/externalversions/internalinterfaces"
k3scattleio "github.com/rancher/k3s/pkg/generated/informers/externalversions/k3s.cattle.io"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
)
// SharedInformerOption defines the functional option type for SharedInformerFactory.
type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory
type sharedInformerFactory struct {
client versioned.Interface
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
lock sync.Mutex
defaultResync time.Duration
customResync map[reflect.Type]time.Duration
informers map[reflect.Type]cache.SharedIndexInformer
// startedInformers is used for tracking which informers have been started.
// This allows Start() to be called multiple times safely.
startedInformers map[reflect.Type]bool
}
// WithCustomResyncConfig sets a custom resync period for the specified informer types.
func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
for k, v := range resyncConfig {
factory.customResync[reflect.TypeOf(k)] = v
}
return factory
}
}
// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory.
func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
factory.tweakListOptions = tweakListOptions
return factory
}
}
// WithNamespace limits the SharedInformerFactory to the specified namespace.
func WithNamespace(namespace string) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
factory.namespace = namespace
return factory
}
}
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces.
func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory {
return NewSharedInformerFactoryWithOptions(client, defaultResync)
}
// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory.
// Listers obtained via this SharedInformerFactory will be subject to the same filters
// as specified here.
// Deprecated: Please use NewSharedInformerFactoryWithOptions instead
func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory {
return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions))
}
// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options.
func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory {
factory := &sharedInformerFactory{
client: client,
namespace: v1.NamespaceAll,
defaultResync: defaultResync,
informers: make(map[reflect.Type]cache.SharedIndexInformer),
startedInformers: make(map[reflect.Type]bool),
customResync: make(map[reflect.Type]time.Duration),
}
// Apply all options
for _, opt := range options {
factory = opt(factory)
}
return factory
}
// Start initializes all requested informers.
func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) {
f.lock.Lock()
defer f.lock.Unlock()
for informerType, informer := range f.informers {
if !f.startedInformers[informerType] {
go informer.Run(stopCh)
f.startedInformers[informerType] = true
}
}
}
// WaitForCacheSync waits for all started informers' cache were synced.
func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool {
informers := func() map[reflect.Type]cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informers := map[reflect.Type]cache.SharedIndexInformer{}
for informerType, informer := range f.informers {
if f.startedInformers[informerType] {
informers[informerType] = informer
}
}
return informers
}()
res := map[reflect.Type]bool{}
for informType, informer := range informers {
res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced)
}
return res
}
// InternalInformerFor returns the SharedIndexInformer for obj using an internal
// client.
func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informerType := reflect.TypeOf(obj)
informer, exists := f.informers[informerType]
if exists {
return informer
}
resyncPeriod, exists := f.customResync[informerType]
if !exists {
resyncPeriod = f.defaultResync
}
informer = newFunc(f.client, resyncPeriod)
f.informers[informerType] = informer
return informer
}
// SharedInformerFactory provides shared informers for resources in all known
// API group versions.
type SharedInformerFactory interface {
internalinterfaces.SharedInformerFactory
ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
K3s() k3scattleio.Interface
}
func (f *sharedInformerFactory) K3s() k3scattleio.Interface {
return k3scattleio.New(f, f.namespace, f.tweakListOptions)
}

View File

@ -0,0 +1,64 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package externalversions
import (
"fmt"
v1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
)
// GenericInformer is type of SharedIndexInformer which will locate and delegate to other
// sharedInformers based on type
type GenericInformer interface {
Informer() cache.SharedIndexInformer
Lister() cache.GenericLister
}
type genericInformer struct {
informer cache.SharedIndexInformer
resource schema.GroupResource
}
// Informer returns the SharedIndexInformer.
func (f *genericInformer) Informer() cache.SharedIndexInformer {
return f.informer
}
// Lister returns the GenericLister.
func (f *genericInformer) Lister() cache.GenericLister {
return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource)
}
// ForResource gives generic access to a shared informer of the matching type
// TODO extend this to unknown resources with a client pool
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource {
// Group=k3s.cattle.io, Version=v1
case v1.SchemeGroupVersion.WithResource("addons"):
return &genericInformer{resource: resource.GroupResource(), informer: f.K3s().V1().Addons().Informer()}, nil
case v1.SchemeGroupVersion.WithResource("listenerconfigs"):
return &genericInformer{resource: resource.GroupResource(), informer: f.K3s().V1().ListenerConfigs().Informer()}, nil
}
return nil, fmt.Errorf("no informer found for %v", resource)
}

View File

@ -0,0 +1,40 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package internalinterfaces
import (
time "time"
versioned "github.com/rancher/k3s/pkg/generated/clientset/versioned"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
cache "k8s.io/client-go/tools/cache"
)
// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer.
type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle
type SharedInformerFactory interface {
Start(stopCh <-chan struct{})
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
}
// TweakListOptionsFunc is a function that transforms a v1.ListOptions.
type TweakListOptionsFunc func(*v1.ListOptions)

View File

@ -0,0 +1,46 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package k3s
import (
internalinterfaces "github.com/rancher/k3s/pkg/generated/informers/externalversions/internalinterfaces"
v1 "github.com/rancher/k3s/pkg/generated/informers/externalversions/k3s.cattle.io/v1"
)
// 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)
}

View File

@ -0,0 +1,89 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
time "time"
k3scattleiov1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
versioned "github.com/rancher/k3s/pkg/generated/clientset/versioned"
internalinterfaces "github.com/rancher/k3s/pkg/generated/informers/externalversions/internalinterfaces"
v1 "github.com/rancher/k3s/pkg/generated/listers/k3s.cattle.io/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"
)
// AddonInformer provides access to a shared informer and lister for
// Addons.
type AddonInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.AddonLister
}
type addonInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewAddonInformer constructs a new informer for Addon 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 NewAddonInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredAddonInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredAddonInformer constructs a new informer for Addon 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 NewFilteredAddonInformer(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.K3sV1().Addons(namespace).List(options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.K3sV1().Addons(namespace).Watch(options)
},
},
&k3scattleiov1.Addon{},
resyncPeriod,
indexers,
)
}
func (f *addonInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredAddonInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *addonInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&k3scattleiov1.Addon{}, f.defaultInformer)
}
func (f *addonInformer) Lister() v1.AddonLister {
return v1.NewAddonLister(f.Informer().GetIndexer())
}

View File

@ -0,0 +1,52 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
internalinterfaces "github.com/rancher/k3s/pkg/generated/informers/externalversions/internalinterfaces"
)
// Interface provides access to all the informers in this group version.
type Interface interface {
// Addons returns a AddonInformer.
Addons() AddonInformer
// ListenerConfigs returns a ListenerConfigInformer.
ListenerConfigs() ListenerConfigInformer
}
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}
}
// Addons returns a AddonInformer.
func (v *version) Addons() AddonInformer {
return &addonInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
// ListenerConfigs returns a ListenerConfigInformer.
func (v *version) ListenerConfigs() ListenerConfigInformer {
return &listenerConfigInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}

View File

@ -0,0 +1,89 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
time "time"
k3scattleiov1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
versioned "github.com/rancher/k3s/pkg/generated/clientset/versioned"
internalinterfaces "github.com/rancher/k3s/pkg/generated/informers/externalversions/internalinterfaces"
v1 "github.com/rancher/k3s/pkg/generated/listers/k3s.cattle.io/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"
)
// ListenerConfigInformer provides access to a shared informer and lister for
// ListenerConfigs.
type ListenerConfigInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.ListenerConfigLister
}
type listenerConfigInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewListenerConfigInformer constructs a new informer for ListenerConfig 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 NewListenerConfigInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredListenerConfigInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredListenerConfigInformer constructs a new informer for ListenerConfig 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 NewFilteredListenerConfigInformer(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.K3sV1().ListenerConfigs(namespace).List(options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.K3sV1().ListenerConfigs(namespace).Watch(options)
},
},
&k3scattleiov1.ListenerConfig{},
resyncPeriod,
indexers,
)
}
func (f *listenerConfigInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredListenerConfigInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *listenerConfigInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&k3scattleiov1.ListenerConfig{}, f.defaultInformer)
}
func (f *listenerConfigInformer) Lister() v1.ListenerConfigLister {
return v1.NewListenerConfigLister(f.Informer().GetIndexer())
}

View File

@ -0,0 +1,94 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
v1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// AddonLister helps list Addons.
type AddonLister interface {
// List lists all Addons in the indexer.
List(selector labels.Selector) (ret []*v1.Addon, err error)
// Addons returns an object that can list and get Addons.
Addons(namespace string) AddonNamespaceLister
AddonListerExpansion
}
// addonLister implements the AddonLister interface.
type addonLister struct {
indexer cache.Indexer
}
// NewAddonLister returns a new AddonLister.
func NewAddonLister(indexer cache.Indexer) AddonLister {
return &addonLister{indexer: indexer}
}
// List lists all Addons in the indexer.
func (s *addonLister) List(selector labels.Selector) (ret []*v1.Addon, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1.Addon))
})
return ret, err
}
// Addons returns an object that can list and get Addons.
func (s *addonLister) Addons(namespace string) AddonNamespaceLister {
return addonNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// AddonNamespaceLister helps list and get Addons.
type AddonNamespaceLister interface {
// List lists all Addons in the indexer for a given namespace.
List(selector labels.Selector) (ret []*v1.Addon, err error)
// Get retrieves the Addon from the indexer for a given namespace and name.
Get(name string) (*v1.Addon, error)
AddonNamespaceListerExpansion
}
// addonNamespaceLister implements the AddonNamespaceLister
// interface.
type addonNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all Addons in the indexer for a given namespace.
func (s addonNamespaceLister) List(selector labels.Selector) (ret []*v1.Addon, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1.Addon))
})
return ret, err
}
// Get retrieves the Addon from the indexer for a given namespace and name.
func (s addonNamespaceLister) Get(name string) (*v1.Addon, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1.Resource("addon"), name)
}
return obj.(*v1.Addon), nil
}

View File

@ -0,0 +1,35 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
// AddonListerExpansion allows custom methods to be added to
// AddonLister.
type AddonListerExpansion interface{}
// AddonNamespaceListerExpansion allows custom methods to be added to
// AddonNamespaceLister.
type AddonNamespaceListerExpansion interface{}
// ListenerConfigListerExpansion allows custom methods to be added to
// ListenerConfigLister.
type ListenerConfigListerExpansion interface{}
// ListenerConfigNamespaceListerExpansion allows custom methods to be added to
// ListenerConfigNamespaceLister.
type ListenerConfigNamespaceListerExpansion interface{}

View File

@ -0,0 +1,94 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
v1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// ListenerConfigLister helps list ListenerConfigs.
type ListenerConfigLister interface {
// List lists all ListenerConfigs in the indexer.
List(selector labels.Selector) (ret []*v1.ListenerConfig, err error)
// ListenerConfigs returns an object that can list and get ListenerConfigs.
ListenerConfigs(namespace string) ListenerConfigNamespaceLister
ListenerConfigListerExpansion
}
// listenerConfigLister implements the ListenerConfigLister interface.
type listenerConfigLister struct {
indexer cache.Indexer
}
// NewListenerConfigLister returns a new ListenerConfigLister.
func NewListenerConfigLister(indexer cache.Indexer) ListenerConfigLister {
return &listenerConfigLister{indexer: indexer}
}
// List lists all ListenerConfigs in the indexer.
func (s *listenerConfigLister) List(selector labels.Selector) (ret []*v1.ListenerConfig, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1.ListenerConfig))
})
return ret, err
}
// ListenerConfigs returns an object that can list and get ListenerConfigs.
func (s *listenerConfigLister) ListenerConfigs(namespace string) ListenerConfigNamespaceLister {
return listenerConfigNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// ListenerConfigNamespaceLister helps list and get ListenerConfigs.
type ListenerConfigNamespaceLister interface {
// List lists all ListenerConfigs in the indexer for a given namespace.
List(selector labels.Selector) (ret []*v1.ListenerConfig, err error)
// Get retrieves the ListenerConfig from the indexer for a given namespace and name.
Get(name string) (*v1.ListenerConfig, error)
ListenerConfigNamespaceListerExpansion
}
// listenerConfigNamespaceLister implements the ListenerConfigNamespaceLister
// interface.
type listenerConfigNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all ListenerConfigs in the indexer for a given namespace.
func (s listenerConfigNamespaceLister) List(selector labels.Selector) (ret []*v1.ListenerConfig, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1.ListenerConfig))
})
return ret, err
}
// Get retrieves the ListenerConfig from the indexer for a given namespace and name.
func (s listenerConfigNamespaceLister) Get(name string) (*v1.ListenerConfig, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1.Resource("listenerconfig"), name)
}
return obj.(*v1.ListenerConfig), nil
}

View File

@ -5,38 +5,39 @@ import (
"strings"
"github.com/pkg/errors"
coreclient "github.com/rancher/k3s/types/apis/core/v1"
coreclient "github.com/rancher/wrangler-api/pkg/generated/controllers/core/v1"
"github.com/sirupsen/logrus"
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)
func Register(ctx context.Context) error {
clients := coreclient.ClientsFrom(ctx)
func Register(ctx context.Context, configMap coreclient.ConfigMapController, nodes coreclient.NodeController) error {
h := &handler{
configCache: clients.ConfigMap.Cache(),
configClient: clients.ConfigMap,
configCache: configMap.Cache(),
configClient: configMap,
}
clients.Node.OnChange(ctx, "node", h.onChange)
clients.Node.OnRemove(ctx, "node", h.onRemove)
nodes.OnChange(ctx, "node", h.onChange)
nodes.OnRemove(ctx, "node", h.onRemove)
return nil
}
type handler struct {
configCache coreclient.ConfigMapClientCache
configCache coreclient.ConfigMapCache
configClient coreclient.ConfigMapClient
}
func (h *handler) onChange(node *core.Node) (runtime.Object, error) {
func (h *handler) onChange(key string, node *core.Node) (*core.Node, error) {
if node == nil {
return nil, nil
}
return h.updateHosts(node, false)
}
func (h *handler) onRemove(node *core.Node) (runtime.Object, error) {
func (h *handler) onRemove(key string, node *core.Node) (*core.Node, error) {
return h.updateHosts(node, true)
}
func (h *handler) updateHosts(node *core.Node, removed bool) (runtime.Object, error) {
func (h *handler) updateHosts(node *core.Node, removed bool) (*core.Node, error) {
var (
newHosts string
nodeAddress string

View File

@ -5,20 +5,19 @@ import (
"time"
"github.com/rancher/k3s/pkg/rootless"
coreClients "github.com/rancher/k3s/types/apis/core/v1"
coreClients "github.com/rancher/wrangler-api/pkg/generated/controllers/core/v1"
"github.com/rootless-containers/rootlesskit/pkg/api/client"
"github.com/rootless-containers/rootlesskit/pkg/port"
"github.com/sirupsen/logrus"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
)
var (
all = "_all_"
)
func Register(ctx context.Context, httpsPort int) error {
func Register(ctx context.Context, serviceController coreClients.ServiceController, httpsPort int) error {
var (
err error
rootlessClient client.Client
@ -28,7 +27,6 @@ func Register(ctx context.Context, httpsPort int) error {
return nil
}
coreClients := coreClients.ClientsFrom(ctx)
for i := 0; i < 30; i++ {
rootlessClient, err = client.New(rootless.Sock)
if err == nil {
@ -44,26 +42,26 @@ func Register(ctx context.Context, httpsPort int) error {
h := &handler{
rootlessClient: rootlessClient,
serviceClient: coreClients.Service,
serviceCache: coreClients.Service.Cache(),
serviceClient: serviceController,
serviceCache: serviceController.Cache(),
httpsPort: httpsPort,
ctx: ctx,
}
coreClients.Service.Interface().Controller().AddHandler(ctx, "rootlessports", h.serviceChanged)
coreClients.Service.Enqueue("", all)
serviceController.OnChange(ctx, "rootlessports", h.serviceChanged)
serviceController.Enqueue("", all)
return nil
}
type handler struct {
rootlessClient client.Client
serviceClient coreClients.ServiceClient
serviceCache coreClients.ServiceClientCache
serviceClient coreClients.ServiceController
serviceCache coreClients.ServiceCache
httpsPort int
ctx context.Context
}
func (h *handler) serviceChanged(key string, svc *v1.Service) (runtime.Object, error) {
func (h *handler) serviceChanged(key string, svc *v1.Service) (*v1.Service, error) {
if key != all {
h.serviceClient.Enqueue("", all)
return svc, nil

70
pkg/server/context.go Normal file
View File

@ -0,0 +1,70 @@
package server
import (
"context"
"github.com/rancher/helm-controller/pkg/generated/controllers/helm.cattle.io"
"github.com/rancher/k3s/pkg/generated/controllers/k3s.cattle.io"
"github.com/rancher/wrangler-api/pkg/generated/controllers/apps"
"github.com/rancher/wrangler-api/pkg/generated/controllers/batch"
"github.com/rancher/wrangler-api/pkg/generated/controllers/core"
"github.com/rancher/wrangler-api/pkg/generated/controllers/rbac"
"github.com/rancher/wrangler/pkg/apply"
"github.com/rancher/wrangler/pkg/crd"
"github.com/rancher/wrangler/pkg/start"
"k8s.io/client-go/rest"
"k8s.io/kubernetes/staging/src/k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/staging/src/k8s.io/client-go/tools/clientcmd"
)
type Context struct {
K3s *k3s.Factory
Helm *helm.Factory
Batch *batch.Factory
Apps *apps.Factory
Auth *rbac.Factory
Core *core.Factory
K8s kubernetes.Interface
Apply apply.Apply
}
func (c *Context) Start(ctx context.Context) error {
return start.All(ctx, 5, c.K3s, c.Helm, c.Apps, c.Auth, c.Batch, c.Core)
}
func newContext(ctx context.Context, cfg string) (*Context, error) {
restConfig, err := clientcmd.BuildConfigFromFlags("", cfg)
if err != nil {
return nil, err
}
if err := crds(ctx, restConfig); err != nil {
return nil, err
}
k8s := kubernetes.NewForConfigOrDie(restConfig)
return &Context{
K3s: k3s.NewFactoryFromConfigOrDie(restConfig),
Helm: helm.NewFactoryFromConfigOrDie(restConfig),
K8s: k8s,
Auth: rbac.NewFactoryFromConfigOrDie(restConfig),
Apps: apps.NewFactoryFromConfigOrDie(restConfig),
Batch: batch.NewFactoryFromConfigOrDie(restConfig),
Core: core.NewFactoryFromConfigOrDie(restConfig),
Apply: apply.New(k8s, apply.NewClientFactory(restConfig)),
}, nil
}
func crds(ctx context.Context, config *rest.Config) error {
factory, err := crd.NewFactoryFromClient(config)
if err != nil {
return err
}
factory.BatchCreateCRDs(ctx, crd.NamespacedTypes(
"ListenerConfig.k3s.cattle.io/v1",
"Addon.k3s.cattle.io/v1",
"HelmChart.helm.cattle.io/v1")...)
return factory.BatchWait()
}

View File

@ -15,9 +15,9 @@ import (
"strings"
"github.com/gorilla/mux"
certutil "github.com/rancher/dynamiclistener/cert"
"github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/k3s/pkg/openapi"
certutil "github.com/rancher/norman/pkg/cert"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/kubernetes/pkg/master"

View File

@ -14,26 +14,20 @@ import (
"time"
"github.com/pkg/errors"
"github.com/rancher/dynamiclistener"
"github.com/rancher/helm-controller/pkg/helm"
"github.com/rancher/k3s/pkg/clientaccess"
"github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/k3s/pkg/daemons/control"
"github.com/rancher/k3s/pkg/datadir"
"github.com/rancher/k3s/pkg/deploy"
"github.com/rancher/k3s/pkg/helm"
"github.com/rancher/k3s/pkg/node"
"github.com/rancher/k3s/pkg/rootlessports"
"github.com/rancher/k3s/pkg/servicelb"
"github.com/rancher/k3s/pkg/static"
"github.com/rancher/k3s/pkg/tls"
appsv1 "github.com/rancher/k3s/types/apis/apps/v1"
batchv1 "github.com/rancher/k3s/types/apis/batch/v1"
corev1 "github.com/rancher/k3s/types/apis/core/v1"
v1 "github.com/rancher/k3s/types/apis/k3s.cattle.io/v1"
rbacv1 "github.com/rancher/k3s/types/apis/rbac.authorization.k8s.io/v1"
"github.com/rancher/norman"
"github.com/rancher/norman/pkg/clientaccess"
"github.com/rancher/norman/pkg/dynamiclistener"
"github.com/rancher/norman/pkg/resolvehome"
"github.com/rancher/norman/types"
"github.com/rancher/wrangler/pkg/leader"
"github.com/rancher/wrangler/pkg/resolvehome"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/util/net"
)
@ -44,7 +38,6 @@ func resolveDataDir(dataDir string) (string, error) {
}
func StartServer(ctx context.Context, config *Config) (string, error) {
if err := setupDataDirAndChdir(&config.ControlConfig); err != nil {
return "", err
}
@ -57,7 +50,7 @@ func StartServer(ctx context.Context, config *Config) (string, error) {
return "", errors.Wrap(err, "starting kubernetes")
}
certs, err := startNorman(ctx, config)
certs, err := startWrangler(ctx, config)
if err != nil {
return "", errors.Wrap(err, "starting tls server")
}
@ -76,7 +69,7 @@ func StartServer(ctx context.Context, config *Config) (string, error) {
return certs, nil
}
func startNorman(ctx context.Context, config *Config) (string, error) {
func startWrangler(ctx context.Context, config *Config) (string, error) {
var (
err error
tlsServer dynamiclistener.ServerInterface
@ -91,76 +84,94 @@ func startNorman(ctx context.Context, config *Config) (string, error) {
return tlsServer.CACert()
})
normanConfig := &norman.Config{
Name: "k3s",
KubeConfig: controlConfig.Runtime.KubeConfigSystem,
Clients: []norman.ClientFactory{
v1.Factory,
appsv1.Factory,
corev1.Factory,
batchv1.Factory,
rbacv1.Factory,
},
Schemas: []*types.Schemas{
v1.Schemas,
},
CRDs: map[*types.APIVersion][]string{
&v1.APIVersion: {
v1.ListenerConfigGroupVersionKind.Kind,
v1.AddonGroupVersionKind.Kind,
v1.HelmChartGroupVersionKind.Kind,
},
},
IgnoredKubeConfigEnv: true,
GlobalSetup: func(ctx context.Context) (context.Context, error) {
tlsServer, err = tls.NewServer(ctx, v1.ClientsFrom(ctx).ListenerConfig, *tlsConfig)
return ctx, err
},
DisableLeaderElection: true,
MasterControllers: []norman.ControllerRegister{
node.Register,
helm.Register,
func(ctx context.Context) error {
return servicelb.Register(ctx, norman.GetServer(ctx).K8sClient, !config.DisableServiceLB,
config.Rootless)
},
func(ctx context.Context) error {
dataDir := filepath.Join(controlConfig.DataDir, "static")
return static.Stage(dataDir)
},
func(ctx context.Context) error {
dataDir := filepath.Join(controlConfig.DataDir, "manifests")
templateVars := map[string]string{"%{CLUSTER_DNS}%": controlConfig.ClusterDNS.String(), "%{CLUSTER_DOMAIN}%": controlConfig.ClusterDomain}
if err := deploy.Stage(dataDir, templateVars, controlConfig.Skips); err != nil {
return err
}
if err := deploy.WatchFiles(ctx, dataDir); err != nil {
return err
}
return nil
},
func(ctx context.Context) error {
if !config.DisableServiceLB && config.Rootless {
return rootlessports.Register(ctx, config.TLSConfig.HTTPSPort)
}
return nil
},
},
}
if _, _, err = normanConfig.Build(ctx, nil); err != nil {
sc, err := newContext(ctx, controlConfig.Runtime.KubeConfigSystem)
if err != nil {
return "", err
}
for {
certs, err := tlsServer.CACert()
if err := stageFiles(ctx, sc, controlConfig); err != nil {
return "", err
}
tlsServer, err = tls.NewServer(ctx, sc.K3s.K3s().V1().ListenerConfig(), *tlsConfig)
if err != nil {
return "", err
}
if err := sc.Start(ctx); err != nil {
return "", err
}
certs := ""
for certs == "" {
certs, err = tlsServer.CACert()
if err != nil {
logrus.Infof("waiting to generate CA certs")
time.Sleep(time.Second)
continue
}
return certs, nil
}
go leader.RunOrDie(ctx, "", "k3s", sc.K8s, func(ctx context.Context) {
if err := masterControllers(ctx, sc, config); err != nil {
panic(err)
}
if err := sc.Start(ctx); err != nil {
panic(err)
}
})
return certs, nil
}
func masterControllers(ctx context.Context, sc *Context, config *Config) error {
if err := node.Register(ctx, sc.Core.Core().V1().ConfigMap(), sc.Core.Core().V1().Node()); err != nil {
return err
}
helm.Register(ctx, sc.Apply,
sc.Helm.Helm().V1().HelmChart(),
sc.Batch.Batch().V1().Job(),
sc.Auth.Rbac().V1().ClusterRoleBinding(),
sc.Core.Core().V1().ServiceAccount())
if err := servicelb.Register(ctx,
sc.K8s,
sc.Apply,
sc.Apps.Apps().V1().DaemonSet(),
sc.Apps.Apps().V1().Deployment(),
sc.Core.Core().V1().Node(),
sc.Core.Core().V1().Pod(),
sc.Core.Core().V1().Service(),
sc.Core.Core().V1().Endpoints(),
!config.DisableServiceLB, config.Rootless); err != nil {
return err
}
if !config.DisableServiceLB && config.Rootless {
return rootlessports.Register(ctx, sc.Core.Core().V1().Service(), config.TLSConfig.HTTPSPort)
}
return nil
}
func stageFiles(ctx context.Context, sc *Context, controlConfig *config.Control) error {
dataDir := filepath.Join(controlConfig.DataDir, "static")
if err := static.Stage(dataDir); err != nil {
return err
}
dataDir = filepath.Join(controlConfig.DataDir, "manifests")
templateVars := map[string]string{
"%{CLUSTER_DNS}%": controlConfig.ClusterDNS.String(),
"%{CLUSTER_DOMAIN}%": controlConfig.ClusterDomain,
}
if err := deploy.Stage(dataDir, templateVars, controlConfig.Skips); err != nil {
return err
}
return deploy.WatchFiles(ctx, sc.Apply, sc.K3s.K3s().V1().Addon(), dataDir)
}
func HomeKubeConfig(write, rootless bool) (string, error) {
@ -198,7 +209,6 @@ func printTokens(certs, advertiseIP string, tlsConfig *dynamiclistener.UserConfi
if len(nodeFile) > 0 {
printToken(tlsConfig.HTTPSPort, advertiseIP, "To join node to cluster:", "agent")
}
}
func writeKubeConfig(certs string, tlsConfig *dynamiclistener.UserConfig, config *Config) {

View File

@ -1,8 +1,8 @@
package server
import (
"github.com/rancher/dynamiclistener"
"github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/norman/pkg/dynamiclistener"
)
type Config struct {

View File

@ -6,12 +6,13 @@ import (
"sort"
"strconv"
appclient "github.com/rancher/k3s/types/apis/apps/v1"
coreclient "github.com/rancher/k3s/types/apis/core/v1"
"github.com/rancher/norman/condition"
"github.com/rancher/norman/pkg/changeset"
"github.com/rancher/norman/pkg/objectset"
"github.com/rancher/norman/types/slice"
appclient "github.com/rancher/wrangler-api/pkg/generated/controllers/apps/v1"
coreclient "github.com/rancher/wrangler-api/pkg/generated/controllers/core/v1"
"github.com/rancher/wrangler/pkg/apply"
"github.com/rancher/wrangler/pkg/condition"
"github.com/rancher/wrangler/pkg/objectset"
"github.com/rancher/wrangler/pkg/relatedresource"
"github.com/rancher/wrangler/pkg/slice"
"github.com/sirupsen/logrus"
apps "k8s.io/api/apps/v1"
core "k8s.io/api/core/v1"
@ -37,31 +38,37 @@ var (
trueVal = true
)
func Register(ctx context.Context, kubernetes kubernetes.Interface, enabled, rootless bool) error {
clients := coreclient.ClientsFrom(ctx)
appClients := appclient.ClientsFrom(ctx)
func Register(ctx context.Context,
kubernetes kubernetes.Interface,
apply apply.Apply,
daemonSetController appclient.DaemonSetController,
deployments appclient.DeploymentController,
nodes coreclient.NodeController,
pods coreclient.PodController,
services coreclient.ServiceController,
endpoints coreclient.EndpointsController,
enabled, rootless bool) error {
h := &handler{
rootless: rootless,
enabled: enabled,
nodeCache: clients.Node.Cache(),
podCache: clients.Pod.Cache(),
deploymentCache: appClients.Deployment.Cache(),
processor: objectset.NewProcessor("svccontroller").
Client(appClients.DaemonSet),
serviceCache: clients.Service.Cache(),
nodeCache: nodes.Cache(),
podCache: pods.Cache(),
deploymentCache: deployments.Cache(),
processor: apply.WithSetID("svccontroller").
WithCacheTypes(daemonSetController),
serviceCache: services.Cache(),
services: kubernetes.CoreV1(),
daemonsets: kubernetes.AppsV1(),
deployments: kubernetes.AppsV1(),
}
clients.Service.OnChange(ctx, "svccontroller", h.onChangeService)
clients.Node.OnChange(ctx, "svccontroller", h.onChangeNode)
changeset.Watch(ctx, "svccontroller-watcher",
services.OnChange(ctx, "svccontroller", h.onChangeService)
nodes.OnChange(ctx, "svccontroller", h.onChangeNode)
relatedresource.Watch(ctx, "svccontroller-watcher",
h.onResourceChange,
clients.Service,
clients.Pod,
clients.Endpoints)
services,
pods,
endpoints)
return nil
}
@ -69,19 +76,19 @@ func Register(ctx context.Context, kubernetes kubernetes.Interface, enabled, roo
type handler struct {
rootless bool
enabled bool
nodeCache coreclient.NodeClientCache
podCache coreclient.PodClientCache
deploymentCache appclient.DeploymentClientCache
processor *objectset.Processor
serviceCache coreclient.ServiceClientCache
nodeCache coreclient.NodeCache
podCache coreclient.PodCache
deploymentCache appclient.DeploymentCache
processor apply.Apply
serviceCache coreclient.ServiceCache
services coregetter.ServicesGetter
daemonsets v1getter.DaemonSetsGetter
deployments v1getter.DeploymentsGetter
}
func (h *handler) onResourceChange(name, namespace string, obj runtime.Object) ([]changeset.Key, error) {
func (h *handler) onResourceChange(name, namespace string, obj runtime.Object) ([]relatedresource.Key, error) {
if ep, ok := obj.(*core.Endpoints); ok {
return []changeset.Key{
return []relatedresource.Key{
{
Name: ep.Name,
Namespace: ep.Namespace,
@ -103,7 +110,7 @@ func (h *handler) onResourceChange(name, namespace string, obj runtime.Object) (
return nil, nil
}
return []changeset.Key{
return []relatedresource.Key{
{
Name: serviceName,
Namespace: pod.Namespace,
@ -111,7 +118,11 @@ func (h *handler) onResourceChange(name, namespace string, obj runtime.Object) (
}, nil
}
func (h *handler) onChangeService(svc *core.Service) (runtime.Object, error) {
func (h *handler) onChangeService(key string, svc *core.Service) (*core.Service, error) {
if svc == nil {
return nil, nil
}
if svc.Spec.Type != core.ServiceTypeLoadBalancer || svc.Spec.ClusterIP == "" ||
svc.Spec.ClusterIP == "None" {
return svc, nil
@ -126,7 +137,10 @@ func (h *handler) onChangeService(svc *core.Service) (runtime.Object, error) {
return nil, err
}
func (h *handler) onChangeNode(node *core.Node) (runtime.Object, error) {
func (h *handler) onChangeNode(key string, node *core.Node) (*core.Node, error) {
if node == nil {
return nil, nil
}
if _, ok := node.Labels[daemonsetNodeLabel]; !ok {
return node, nil
}
@ -195,7 +209,7 @@ func (h *handler) podIPs(pods []*core.Pod) ([]string, error) {
continue
}
node, err := h.nodeCache.Get("", pod.Spec.NodeName)
node, err := h.nodeCache.Get(pod.Spec.NodeName)
if errors.IsNotFound(err) {
continue
} else if err != nil {
@ -227,7 +241,7 @@ func (h *handler) deployPod(svc *core.Service) error {
}
objs := objectset.NewObjectSet()
if !h.enabled {
return h.processor.NewDesiredSet(svc, objs).Apply()
return h.processor.WithOwner(svc).Apply(objs)
}
ds, err := h.newDaemonSet(svc)
@ -237,7 +251,7 @@ func (h *handler) deployPod(svc *core.Service) error {
if ds != nil {
objs.Add(ds)
}
return h.processor.NewDesiredSet(svc, objs).Apply()
return h.processor.WithOwner(svc).Apply(objs)
}
func (h *handler) newDaemonSet(svc *core.Service) (*apps.DaemonSet, error) {
@ -335,7 +349,7 @@ func (h *handler) newDaemonSet(svc *core.Service) (*apps.DaemonSet, error) {
if err != nil {
return nil, err
}
nodesWithLabel, err := h.nodeCache.List("", selector)
nodesWithLabel, err := h.nodeCache.List(selector)
if err != nil {
return nil, err
}

View File

@ -3,11 +3,11 @@ package tls
import (
"context"
v1 "github.com/rancher/k3s/types/apis/k3s.cattle.io/v1"
"github.com/rancher/norman/pkg/dynamiclistener"
"github.com/rancher/dynamiclistener"
v1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
k3sclient "github.com/rancher/k3s/pkg/generated/controllers/k3s.cattle.io/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
const (
@ -15,14 +15,21 @@ const (
name = "tls-config"
)
func NewServer(ctx context.Context, listenerClient v1.ListenerConfigClient, config dynamiclistener.UserConfig) (dynamiclistener.ServerInterface, error) {
func NewServer(ctx context.Context, listenerConfigs k3sclient.ListenerConfigController, config dynamiclistener.UserConfig) (dynamiclistener.ServerInterface, error) {
storage := &listenerConfigStorage{
client: listenerClient,
cache: listenerClient.Cache(),
client: listenerConfigs,
cache: listenerConfigs.Cache(),
}
server, err := dynamiclistener.NewServer(storage, config)
listenerClient.OnChange(ctx, "listen-config", func(obj *v1.ListenerConfig) (runtime.Object, error) {
if err != nil {
return nil, err
}
listenerConfigs.OnChange(ctx, "listen-config", func(key string, obj *v1.ListenerConfig) (*v1.ListenerConfig, error) {
if obj == nil {
return nil, nil
}
return obj, server.Update(fromStorage(obj))
})
@ -30,8 +37,8 @@ func NewServer(ctx context.Context, listenerClient v1.ListenerConfigClient, conf
}
type listenerConfigStorage struct {
cache v1.ListenerConfigClientCache
client v1.ListenerConfigClient
cache k3sclient.ListenerConfigCache
client k3sclient.ListenerConfigClient
}
func (l *listenerConfigStorage) Set(config *dynamiclistener.ListenerStatus) (*dynamiclistener.ListenerStatus, error) {
@ -65,6 +72,9 @@ func (l *listenerConfigStorage) Get() (*dynamiclistener.ListenerStatus, error) {
if errors.IsNotFound(err) {
obj, err = l.client.Get(ns, name, metav1.GetOptions{})
}
if errors.IsNotFound(err) {
return &dynamiclistener.ListenerStatus{}, nil
}
return fromStorage(obj), err
}

View File

@ -1,5 +1,5 @@
/*
Copyright 2016 The Kubernetes Authors.
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,5 +14,3 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// Package maps has common methods for dealing with common map types.
package maps

View File

@ -162,6 +162,9 @@ import:
version: 89fcab3d43de07060e4fd4c1547430ed57e87f24
- package: github.com/lithammer/dedent
version: v1.1.0
- package: github.com/matryer/moq
version: ee5226d43009
repo: https://github.com/rancher/moq.git
- package: github.com/mattn/go-shellwords
version: v1.0.3-20-gf8471b0a71ded0
- package: github.com/mattn/go-sqlite3
@ -216,9 +219,16 @@ import:
version: v0.2.0
- package: github.com/prometheus/procfs
version: 65c1f6f8f0fc1e2185eb9863a3bc751496404259
- package: github.com/rancher/norman
version: 50017efee23caa79542ef685b65a7b783e0a73ca
repo: https://github.com/ibuildthecloud/norman.git
- package: github.com/rancher/dynamiclistener
version: 077eb13a904f2c62496f31b158135d9743526f82
- package: github.com/rancher/helm-controller
version: 4f3b43bfd868bcb74fe847f8df88c482e9b70ff8
- package: github.com/rancher/remotedialer
version: 20ec38853712bb6d348f0db9ac47d34c954c6b00
- package: github.com/rancher/wrangler
version: 4202dbfa88013c19238bb004d82e013f0593493d
- package: github.com/rancher/wrangler-api
version: efe26ac6a9d720e1bfa5a8cc5f8dce5ad598ce26
- package: github.com/robfig/cron
version: v1-53-gdf38d32658d878
- package: github.com/rootless-containers/rootlesskit

View File

@ -1,441 +0,0 @@
package v1
import (
"context"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
v1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
DaemonSetGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "DaemonSet",
}
DaemonSetResource = metav1.APIResource{
Name: "daemonsets",
SingularName: "daemonset",
Namespaced: true,
Kind: DaemonSetGroupVersionKind.Kind,
}
)
func NewDaemonSet(namespace, name string, obj v1.DaemonSet) *v1.DaemonSet {
obj.APIVersion, obj.Kind = DaemonSetGroupVersionKind.ToAPIVersionAndKind()
obj.Name = name
obj.Namespace = namespace
return &obj
}
type DaemonSetList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []v1.DaemonSet
}
type DaemonSetHandlerFunc func(key string, obj *v1.DaemonSet) (runtime.Object, error)
type DaemonSetChangeHandlerFunc func(obj *v1.DaemonSet) (runtime.Object, error)
type DaemonSetLister interface {
List(namespace string, selector labels.Selector) (ret []*v1.DaemonSet, err error)
Get(namespace, name string) (*v1.DaemonSet, error)
}
type DaemonSetController interface {
Generic() controller.GenericController
Informer() cache.SharedIndexInformer
Lister() DaemonSetLister
AddHandler(ctx context.Context, name string, handler DaemonSetHandlerFunc)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler DaemonSetHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type DaemonSetInterface interface {
ObjectClient() *objectclient.ObjectClient
Create(*v1.DaemonSet) (*v1.DaemonSet, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.DaemonSet, error)
Get(name string, opts metav1.GetOptions) (*v1.DaemonSet, error)
Update(*v1.DaemonSet) (*v1.DaemonSet, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*DaemonSetList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() DaemonSetController
AddHandler(ctx context.Context, name string, sync DaemonSetHandlerFunc)
AddLifecycle(ctx context.Context, name string, lifecycle DaemonSetLifecycle)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync DaemonSetHandlerFunc)
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle DaemonSetLifecycle)
}
type daemonSetLister struct {
controller *daemonSetController
}
func (l *daemonSetLister) List(namespace string, selector labels.Selector) (ret []*v1.DaemonSet, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*v1.DaemonSet))
})
return
}
func (l *daemonSetLister) Get(namespace, name string) (*v1.DaemonSet, error) {
var key string
if namespace != "" {
key = namespace + "/" + name
} else {
key = name
}
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: DaemonSetGroupVersionKind.Group,
Resource: "daemonSet",
}, key)
}
return obj.(*v1.DaemonSet), nil
}
type daemonSetController struct {
controller.GenericController
}
func (c *daemonSetController) Generic() controller.GenericController {
return c.GenericController
}
func (c *daemonSetController) Lister() DaemonSetLister {
return &daemonSetLister{
controller: c,
}
}
func (c *daemonSetController) AddHandler(ctx context.Context, name string, handler DaemonSetHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.DaemonSet); ok {
return handler(key, v)
} else {
return nil, nil
}
})
}
func (c *daemonSetController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler DaemonSetHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.DaemonSet); ok && controller.ObjectInCluster(cluster, obj) {
return handler(key, v)
} else {
return nil, nil
}
})
}
type daemonSetFactory struct {
}
func (c daemonSetFactory) Object() runtime.Object {
return &v1.DaemonSet{}
}
func (c daemonSetFactory) List() runtime.Object {
return &DaemonSetList{}
}
func (s *daemonSetClient) Controller() DaemonSetController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.daemonSetControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(DaemonSetGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &daemonSetController{
GenericController: genericController,
}
s.client.daemonSetControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type daemonSetClient struct {
client *Client
ns string
objectClient *objectclient.ObjectClient
controller DaemonSetController
}
func (s *daemonSetClient) ObjectClient() *objectclient.ObjectClient {
return s.objectClient
}
func (s *daemonSetClient) Create(o *v1.DaemonSet) (*v1.DaemonSet, error) {
obj, err := s.objectClient.Create(o)
return obj.(*v1.DaemonSet), err
}
func (s *daemonSetClient) Get(name string, opts metav1.GetOptions) (*v1.DaemonSet, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*v1.DaemonSet), err
}
func (s *daemonSetClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.DaemonSet, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*v1.DaemonSet), err
}
func (s *daemonSetClient) Update(o *v1.DaemonSet) (*v1.DaemonSet, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*v1.DaemonSet), err
}
func (s *daemonSetClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *daemonSetClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *daemonSetClient) List(opts metav1.ListOptions) (*DaemonSetList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*DaemonSetList), err
}
func (s *daemonSetClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *daemonSetClient) Patch(o *v1.DaemonSet, patchType types.PatchType, data []byte, subresources ...string) (*v1.DaemonSet, error) {
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
return obj.(*v1.DaemonSet), err
}
func (s *daemonSetClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *daemonSetClient) AddHandler(ctx context.Context, name string, sync DaemonSetHandlerFunc) {
s.Controller().AddHandler(ctx, name, sync)
}
func (s *daemonSetClient) AddLifecycle(ctx context.Context, name string, lifecycle DaemonSetLifecycle) {
sync := NewDaemonSetLifecycleAdapter(name, false, s, lifecycle)
s.Controller().AddHandler(ctx, name, sync)
}
func (s *daemonSetClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync DaemonSetHandlerFunc) {
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
func (s *daemonSetClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle DaemonSetLifecycle) {
sync := NewDaemonSetLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
type DaemonSetIndexer func(obj *v1.DaemonSet) ([]string, error)
type DaemonSetClientCache interface {
Get(namespace, name string) (*v1.DaemonSet, error)
List(namespace string, selector labels.Selector) ([]*v1.DaemonSet, error)
Index(name string, indexer DaemonSetIndexer)
GetIndexed(name, key string) ([]*v1.DaemonSet, error)
}
type DaemonSetClient interface {
Create(*v1.DaemonSet) (*v1.DaemonSet, error)
Get(namespace, name string, opts metav1.GetOptions) (*v1.DaemonSet, error)
Update(*v1.DaemonSet) (*v1.DaemonSet, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
List(namespace string, opts metav1.ListOptions) (*DaemonSetList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Cache() DaemonSetClientCache
OnCreate(ctx context.Context, name string, sync DaemonSetChangeHandlerFunc)
OnChange(ctx context.Context, name string, sync DaemonSetChangeHandlerFunc)
OnRemove(ctx context.Context, name string, sync DaemonSetChangeHandlerFunc)
Enqueue(namespace, name string)
Generic() controller.GenericController
ObjectClient() *objectclient.ObjectClient
Interface() DaemonSetInterface
}
type daemonSetClientCache struct {
client *daemonSetClient2
}
type daemonSetClient2 struct {
iface DaemonSetInterface
controller DaemonSetController
}
func (n *daemonSetClient2) Interface() DaemonSetInterface {
return n.iface
}
func (n *daemonSetClient2) Generic() controller.GenericController {
return n.iface.Controller().Generic()
}
func (n *daemonSetClient2) ObjectClient() *objectclient.ObjectClient {
return n.Interface().ObjectClient()
}
func (n *daemonSetClient2) Enqueue(namespace, name string) {
n.iface.Controller().Enqueue(namespace, name)
}
func (n *daemonSetClient2) Create(obj *v1.DaemonSet) (*v1.DaemonSet, error) {
return n.iface.Create(obj)
}
func (n *daemonSetClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.DaemonSet, error) {
return n.iface.GetNamespaced(namespace, name, opts)
}
func (n *daemonSetClient2) Update(obj *v1.DaemonSet) (*v1.DaemonSet, error) {
return n.iface.Update(obj)
}
func (n *daemonSetClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return n.iface.DeleteNamespaced(namespace, name, options)
}
func (n *daemonSetClient2) List(namespace string, opts metav1.ListOptions) (*DaemonSetList, error) {
return n.iface.List(opts)
}
func (n *daemonSetClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return n.iface.Watch(opts)
}
func (n *daemonSetClientCache) Get(namespace, name string) (*v1.DaemonSet, error) {
return n.client.controller.Lister().Get(namespace, name)
}
func (n *daemonSetClientCache) List(namespace string, selector labels.Selector) ([]*v1.DaemonSet, error) {
return n.client.controller.Lister().List(namespace, selector)
}
func (n *daemonSetClient2) Cache() DaemonSetClientCache {
n.loadController()
return &daemonSetClientCache{
client: n,
}
}
func (n *daemonSetClient2) OnCreate(ctx context.Context, name string, sync DaemonSetChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-create", &daemonSetLifecycleDelegate{create: sync})
}
func (n *daemonSetClient2) OnChange(ctx context.Context, name string, sync DaemonSetChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-change", &daemonSetLifecycleDelegate{update: sync})
}
func (n *daemonSetClient2) OnRemove(ctx context.Context, name string, sync DaemonSetChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name, &daemonSetLifecycleDelegate{remove: sync})
}
func (n *daemonSetClientCache) Index(name string, indexer DaemonSetIndexer) {
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
name: func(obj interface{}) ([]string, error) {
if v, ok := obj.(*v1.DaemonSet); ok {
return indexer(v)
}
return nil, nil
},
})
if err != nil {
panic(err)
}
}
func (n *daemonSetClientCache) GetIndexed(name, key string) ([]*v1.DaemonSet, error) {
var result []*v1.DaemonSet
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
if v, ok := obj.(*v1.DaemonSet); ok {
result = append(result, v)
}
}
return result, nil
}
func (n *daemonSetClient2) loadController() {
if n.controller == nil {
n.controller = n.iface.Controller()
}
}
type daemonSetLifecycleDelegate struct {
create DaemonSetChangeHandlerFunc
update DaemonSetChangeHandlerFunc
remove DaemonSetChangeHandlerFunc
}
func (n *daemonSetLifecycleDelegate) HasCreate() bool {
return n.create != nil
}
func (n *daemonSetLifecycleDelegate) Create(obj *v1.DaemonSet) (runtime.Object, error) {
if n.create == nil {
return obj, nil
}
return n.create(obj)
}
func (n *daemonSetLifecycleDelegate) HasFinalize() bool {
return n.remove != nil
}
func (n *daemonSetLifecycleDelegate) Remove(obj *v1.DaemonSet) (runtime.Object, error) {
if n.remove == nil {
return obj, nil
}
return n.remove(obj)
}
func (n *daemonSetLifecycleDelegate) Updated(obj *v1.DaemonSet) (runtime.Object, error) {
if n.update == nil {
return obj, nil
}
return n.update(obj)
}

View File

@ -1,63 +0,0 @@
package v1
import (
"github.com/rancher/norman/lifecycle"
v1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/runtime"
)
type DaemonSetLifecycle interface {
Create(obj *v1.DaemonSet) (runtime.Object, error)
Remove(obj *v1.DaemonSet) (runtime.Object, error)
Updated(obj *v1.DaemonSet) (runtime.Object, error)
}
type daemonSetLifecycleAdapter struct {
lifecycle DaemonSetLifecycle
}
func (w *daemonSetLifecycleAdapter) HasCreate() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasCreate()
}
func (w *daemonSetLifecycleAdapter) HasFinalize() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasFinalize()
}
func (w *daemonSetLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*v1.DaemonSet))
if o == nil {
return nil, err
}
return o, err
}
func (w *daemonSetLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*v1.DaemonSet))
if o == nil {
return nil, err
}
return o, err
}
func (w *daemonSetLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*v1.DaemonSet))
if o == nil {
return nil, err
}
return o, err
}
func NewDaemonSetLifecycleAdapter(name string, clusterScoped bool, client DaemonSetInterface, l DaemonSetLifecycle) DaemonSetHandlerFunc {
adapter := &daemonSetLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *v1.DaemonSet) (runtime.Object, error) {
newObj, err := syncFn(key, obj)
if o, ok := newObj.(runtime.Object); ok {
return o, err
}
return nil, err
}
}

View File

@ -1,72 +0,0 @@
package v1
import (
appsv1 "k8s.io/api/apps/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 *DaemonSetList) DeepCopyInto(out *DaemonSetList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]appsv1.DaemonSet, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DaemonSetList.
func (in *DaemonSetList) DeepCopy() *DaemonSetList {
if in == nil {
return nil
}
out := new(DaemonSetList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *DaemonSetList) 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 *DeploymentList) DeepCopyInto(out *DeploymentList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]appsv1.Deployment, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentList.
func (in *DeploymentList) DeepCopy() *DeploymentList {
if in == nil {
return nil
}
out := new(DeploymentList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *DeploymentList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}

View File

@ -1,441 +0,0 @@
package v1
import (
"context"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
v1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
DeploymentGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "Deployment",
}
DeploymentResource = metav1.APIResource{
Name: "deployments",
SingularName: "deployment",
Namespaced: true,
Kind: DeploymentGroupVersionKind.Kind,
}
)
func NewDeployment(namespace, name string, obj v1.Deployment) *v1.Deployment {
obj.APIVersion, obj.Kind = DeploymentGroupVersionKind.ToAPIVersionAndKind()
obj.Name = name
obj.Namespace = namespace
return &obj
}
type DeploymentList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []v1.Deployment
}
type DeploymentHandlerFunc func(key string, obj *v1.Deployment) (runtime.Object, error)
type DeploymentChangeHandlerFunc func(obj *v1.Deployment) (runtime.Object, error)
type DeploymentLister interface {
List(namespace string, selector labels.Selector) (ret []*v1.Deployment, err error)
Get(namespace, name string) (*v1.Deployment, error)
}
type DeploymentController interface {
Generic() controller.GenericController
Informer() cache.SharedIndexInformer
Lister() DeploymentLister
AddHandler(ctx context.Context, name string, handler DeploymentHandlerFunc)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler DeploymentHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type DeploymentInterface interface {
ObjectClient() *objectclient.ObjectClient
Create(*v1.Deployment) (*v1.Deployment, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.Deployment, error)
Get(name string, opts metav1.GetOptions) (*v1.Deployment, error)
Update(*v1.Deployment) (*v1.Deployment, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*DeploymentList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() DeploymentController
AddHandler(ctx context.Context, name string, sync DeploymentHandlerFunc)
AddLifecycle(ctx context.Context, name string, lifecycle DeploymentLifecycle)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync DeploymentHandlerFunc)
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle DeploymentLifecycle)
}
type deploymentLister struct {
controller *deploymentController
}
func (l *deploymentLister) List(namespace string, selector labels.Selector) (ret []*v1.Deployment, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*v1.Deployment))
})
return
}
func (l *deploymentLister) Get(namespace, name string) (*v1.Deployment, error) {
var key string
if namespace != "" {
key = namespace + "/" + name
} else {
key = name
}
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: DeploymentGroupVersionKind.Group,
Resource: "deployment",
}, key)
}
return obj.(*v1.Deployment), nil
}
type deploymentController struct {
controller.GenericController
}
func (c *deploymentController) Generic() controller.GenericController {
return c.GenericController
}
func (c *deploymentController) Lister() DeploymentLister {
return &deploymentLister{
controller: c,
}
}
func (c *deploymentController) AddHandler(ctx context.Context, name string, handler DeploymentHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.Deployment); ok {
return handler(key, v)
} else {
return nil, nil
}
})
}
func (c *deploymentController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler DeploymentHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.Deployment); ok && controller.ObjectInCluster(cluster, obj) {
return handler(key, v)
} else {
return nil, nil
}
})
}
type deploymentFactory struct {
}
func (c deploymentFactory) Object() runtime.Object {
return &v1.Deployment{}
}
func (c deploymentFactory) List() runtime.Object {
return &DeploymentList{}
}
func (s *deploymentClient) Controller() DeploymentController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.deploymentControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(DeploymentGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &deploymentController{
GenericController: genericController,
}
s.client.deploymentControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type deploymentClient struct {
client *Client
ns string
objectClient *objectclient.ObjectClient
controller DeploymentController
}
func (s *deploymentClient) ObjectClient() *objectclient.ObjectClient {
return s.objectClient
}
func (s *deploymentClient) Create(o *v1.Deployment) (*v1.Deployment, error) {
obj, err := s.objectClient.Create(o)
return obj.(*v1.Deployment), err
}
func (s *deploymentClient) Get(name string, opts metav1.GetOptions) (*v1.Deployment, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*v1.Deployment), err
}
func (s *deploymentClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.Deployment, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*v1.Deployment), err
}
func (s *deploymentClient) Update(o *v1.Deployment) (*v1.Deployment, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*v1.Deployment), err
}
func (s *deploymentClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *deploymentClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *deploymentClient) List(opts metav1.ListOptions) (*DeploymentList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*DeploymentList), err
}
func (s *deploymentClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *deploymentClient) Patch(o *v1.Deployment, patchType types.PatchType, data []byte, subresources ...string) (*v1.Deployment, error) {
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
return obj.(*v1.Deployment), err
}
func (s *deploymentClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *deploymentClient) AddHandler(ctx context.Context, name string, sync DeploymentHandlerFunc) {
s.Controller().AddHandler(ctx, name, sync)
}
func (s *deploymentClient) AddLifecycle(ctx context.Context, name string, lifecycle DeploymentLifecycle) {
sync := NewDeploymentLifecycleAdapter(name, false, s, lifecycle)
s.Controller().AddHandler(ctx, name, sync)
}
func (s *deploymentClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync DeploymentHandlerFunc) {
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
func (s *deploymentClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle DeploymentLifecycle) {
sync := NewDeploymentLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
type DeploymentIndexer func(obj *v1.Deployment) ([]string, error)
type DeploymentClientCache interface {
Get(namespace, name string) (*v1.Deployment, error)
List(namespace string, selector labels.Selector) ([]*v1.Deployment, error)
Index(name string, indexer DeploymentIndexer)
GetIndexed(name, key string) ([]*v1.Deployment, error)
}
type DeploymentClient interface {
Create(*v1.Deployment) (*v1.Deployment, error)
Get(namespace, name string, opts metav1.GetOptions) (*v1.Deployment, error)
Update(*v1.Deployment) (*v1.Deployment, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
List(namespace string, opts metav1.ListOptions) (*DeploymentList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Cache() DeploymentClientCache
OnCreate(ctx context.Context, name string, sync DeploymentChangeHandlerFunc)
OnChange(ctx context.Context, name string, sync DeploymentChangeHandlerFunc)
OnRemove(ctx context.Context, name string, sync DeploymentChangeHandlerFunc)
Enqueue(namespace, name string)
Generic() controller.GenericController
ObjectClient() *objectclient.ObjectClient
Interface() DeploymentInterface
}
type deploymentClientCache struct {
client *deploymentClient2
}
type deploymentClient2 struct {
iface DeploymentInterface
controller DeploymentController
}
func (n *deploymentClient2) Interface() DeploymentInterface {
return n.iface
}
func (n *deploymentClient2) Generic() controller.GenericController {
return n.iface.Controller().Generic()
}
func (n *deploymentClient2) ObjectClient() *objectclient.ObjectClient {
return n.Interface().ObjectClient()
}
func (n *deploymentClient2) Enqueue(namespace, name string) {
n.iface.Controller().Enqueue(namespace, name)
}
func (n *deploymentClient2) Create(obj *v1.Deployment) (*v1.Deployment, error) {
return n.iface.Create(obj)
}
func (n *deploymentClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.Deployment, error) {
return n.iface.GetNamespaced(namespace, name, opts)
}
func (n *deploymentClient2) Update(obj *v1.Deployment) (*v1.Deployment, error) {
return n.iface.Update(obj)
}
func (n *deploymentClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return n.iface.DeleteNamespaced(namespace, name, options)
}
func (n *deploymentClient2) List(namespace string, opts metav1.ListOptions) (*DeploymentList, error) {
return n.iface.List(opts)
}
func (n *deploymentClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return n.iface.Watch(opts)
}
func (n *deploymentClientCache) Get(namespace, name string) (*v1.Deployment, error) {
return n.client.controller.Lister().Get(namespace, name)
}
func (n *deploymentClientCache) List(namespace string, selector labels.Selector) ([]*v1.Deployment, error) {
return n.client.controller.Lister().List(namespace, selector)
}
func (n *deploymentClient2) Cache() DeploymentClientCache {
n.loadController()
return &deploymentClientCache{
client: n,
}
}
func (n *deploymentClient2) OnCreate(ctx context.Context, name string, sync DeploymentChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-create", &deploymentLifecycleDelegate{create: sync})
}
func (n *deploymentClient2) OnChange(ctx context.Context, name string, sync DeploymentChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-change", &deploymentLifecycleDelegate{update: sync})
}
func (n *deploymentClient2) OnRemove(ctx context.Context, name string, sync DeploymentChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name, &deploymentLifecycleDelegate{remove: sync})
}
func (n *deploymentClientCache) Index(name string, indexer DeploymentIndexer) {
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
name: func(obj interface{}) ([]string, error) {
if v, ok := obj.(*v1.Deployment); ok {
return indexer(v)
}
return nil, nil
},
})
if err != nil {
panic(err)
}
}
func (n *deploymentClientCache) GetIndexed(name, key string) ([]*v1.Deployment, error) {
var result []*v1.Deployment
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
if v, ok := obj.(*v1.Deployment); ok {
result = append(result, v)
}
}
return result, nil
}
func (n *deploymentClient2) loadController() {
if n.controller == nil {
n.controller = n.iface.Controller()
}
}
type deploymentLifecycleDelegate struct {
create DeploymentChangeHandlerFunc
update DeploymentChangeHandlerFunc
remove DeploymentChangeHandlerFunc
}
func (n *deploymentLifecycleDelegate) HasCreate() bool {
return n.create != nil
}
func (n *deploymentLifecycleDelegate) Create(obj *v1.Deployment) (runtime.Object, error) {
if n.create == nil {
return obj, nil
}
return n.create(obj)
}
func (n *deploymentLifecycleDelegate) HasFinalize() bool {
return n.remove != nil
}
func (n *deploymentLifecycleDelegate) Remove(obj *v1.Deployment) (runtime.Object, error) {
if n.remove == nil {
return obj, nil
}
return n.remove(obj)
}
func (n *deploymentLifecycleDelegate) Updated(obj *v1.Deployment) (runtime.Object, error) {
if n.update == nil {
return obj, nil
}
return n.update(obj)
}

View File

@ -1,63 +0,0 @@
package v1
import (
"github.com/rancher/norman/lifecycle"
v1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/runtime"
)
type DeploymentLifecycle interface {
Create(obj *v1.Deployment) (runtime.Object, error)
Remove(obj *v1.Deployment) (runtime.Object, error)
Updated(obj *v1.Deployment) (runtime.Object, error)
}
type deploymentLifecycleAdapter struct {
lifecycle DeploymentLifecycle
}
func (w *deploymentLifecycleAdapter) HasCreate() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasCreate()
}
func (w *deploymentLifecycleAdapter) HasFinalize() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasFinalize()
}
func (w *deploymentLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*v1.Deployment))
if o == nil {
return nil, err
}
return o, err
}
func (w *deploymentLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*v1.Deployment))
if o == nil {
return nil, err
}
return o, err
}
func (w *deploymentLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*v1.Deployment))
if o == nil {
return nil, err
}
return o, err
}
func NewDeploymentLifecycleAdapter(name string, clusterScoped bool, client DeploymentInterface, l DeploymentLifecycle) DeploymentHandlerFunc {
adapter := &deploymentLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *v1.Deployment) (runtime.Object, error) {
newObj, err := syncFn(key, obj)
if o, ok := newObj.(runtime.Object); ok {
return o, err
}
return nil, err
}
}

View File

@ -1,139 +0,0 @@
package v1
import (
"context"
"sync"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
"github.com/rancher/norman/objectclient/dynamic"
"github.com/rancher/norman/restwatch"
"k8s.io/client-go/rest"
)
type (
contextKeyType struct{}
contextClientsKeyType struct{}
)
type Interface interface {
RESTClient() rest.Interface
controller.Starter
DaemonSetsGetter
DeploymentsGetter
}
type Clients struct {
Interface Interface
DaemonSet DaemonSetClient
Deployment DeploymentClient
}
type Client struct {
sync.Mutex
restClient rest.Interface
starters []controller.Starter
daemonSetControllers map[string]DaemonSetController
deploymentControllers map[string]DeploymentController
}
func Factory(ctx context.Context, config rest.Config) (context.Context, controller.Starter, error) {
c, err := NewForConfig(config)
if err != nil {
return ctx, nil, err
}
cs := NewClientsFromInterface(c)
ctx = context.WithValue(ctx, contextKeyType{}, c)
ctx = context.WithValue(ctx, contextClientsKeyType{}, cs)
return ctx, c, nil
}
func ClientsFrom(ctx context.Context) *Clients {
return ctx.Value(contextClientsKeyType{}).(*Clients)
}
func From(ctx context.Context) Interface {
return ctx.Value(contextKeyType{}).(Interface)
}
func NewClients(config rest.Config) (*Clients, error) {
iface, err := NewForConfig(config)
if err != nil {
return nil, err
}
return NewClientsFromInterface(iface), nil
}
func NewClientsFromInterface(iface Interface) *Clients {
return &Clients{
Interface: iface,
DaemonSet: &daemonSetClient2{
iface: iface.DaemonSets(""),
},
Deployment: &deploymentClient2{
iface: iface.Deployments(""),
},
}
}
func NewForConfig(config rest.Config) (Interface, error) {
if config.NegotiatedSerializer == nil {
config.NegotiatedSerializer = dynamic.NegotiatedSerializer
}
restClient, err := restwatch.UnversionedRESTClientFor(&config)
if err != nil {
return nil, err
}
return &Client{
restClient: restClient,
daemonSetControllers: map[string]DaemonSetController{},
deploymentControllers: map[string]DeploymentController{},
}, nil
}
func (c *Client) RESTClient() rest.Interface {
return c.restClient
}
func (c *Client) Sync(ctx context.Context) error {
return controller.Sync(ctx, c.starters...)
}
func (c *Client) Start(ctx context.Context, threadiness int) error {
return controller.Start(ctx, threadiness, c.starters...)
}
type DaemonSetsGetter interface {
DaemonSets(namespace string) DaemonSetInterface
}
func (c *Client) DaemonSets(namespace string) DaemonSetInterface {
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &DaemonSetResource, DaemonSetGroupVersionKind, daemonSetFactory{})
return &daemonSetClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type DeploymentsGetter interface {
Deployments(namespace string) DeploymentInterface
}
func (c *Client) Deployments(namespace string) DeploymentInterface {
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &DeploymentResource, DeploymentGroupVersionKind, deploymentFactory{})
return &deploymentClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}

View File

@ -1,40 +0,0 @@
package v1
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
const (
GroupName = "apps"
Version = "v1"
)
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: Version}
// Kind takes an unqualified kind and returns a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
)
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
// TODO this gets cleaned up when the types are fixed
scheme.AddKnownTypes(SchemeGroupVersion,
&DaemonSetList{},
&DeploymentList{},
)
return nil
}

View File

@ -1,39 +0,0 @@
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 *JobList) DeepCopyInto(out *JobList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]batchv1.Job, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JobList.
func (in *JobList) DeepCopy() *JobList {
if in == nil {
return nil
}
out := new(JobList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *JobList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}

View File

@ -1,441 +0,0 @@
package v1
import (
"context"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
v1 "k8s.io/api/batch/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
JobGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "Job",
}
JobResource = metav1.APIResource{
Name: "jobs",
SingularName: "job",
Namespaced: true,
Kind: JobGroupVersionKind.Kind,
}
)
func NewJob(namespace, name string, obj v1.Job) *v1.Job {
obj.APIVersion, obj.Kind = JobGroupVersionKind.ToAPIVersionAndKind()
obj.Name = name
obj.Namespace = namespace
return &obj
}
type JobList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []v1.Job
}
type JobHandlerFunc func(key string, obj *v1.Job) (runtime.Object, error)
type JobChangeHandlerFunc func(obj *v1.Job) (runtime.Object, error)
type JobLister interface {
List(namespace string, selector labels.Selector) (ret []*v1.Job, err error)
Get(namespace, name string) (*v1.Job, error)
}
type JobController interface {
Generic() controller.GenericController
Informer() cache.SharedIndexInformer
Lister() JobLister
AddHandler(ctx context.Context, name string, handler JobHandlerFunc)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler JobHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type JobInterface interface {
ObjectClient() *objectclient.ObjectClient
Create(*v1.Job) (*v1.Job, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.Job, error)
Get(name string, opts metav1.GetOptions) (*v1.Job, error)
Update(*v1.Job) (*v1.Job, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*JobList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() JobController
AddHandler(ctx context.Context, name string, sync JobHandlerFunc)
AddLifecycle(ctx context.Context, name string, lifecycle JobLifecycle)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync JobHandlerFunc)
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle JobLifecycle)
}
type jobLister struct {
controller *jobController
}
func (l *jobLister) List(namespace string, selector labels.Selector) (ret []*v1.Job, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*v1.Job))
})
return
}
func (l *jobLister) Get(namespace, name string) (*v1.Job, error) {
var key string
if namespace != "" {
key = namespace + "/" + name
} else {
key = name
}
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: JobGroupVersionKind.Group,
Resource: "job",
}, key)
}
return obj.(*v1.Job), nil
}
type jobController struct {
controller.GenericController
}
func (c *jobController) Generic() controller.GenericController {
return c.GenericController
}
func (c *jobController) Lister() JobLister {
return &jobLister{
controller: c,
}
}
func (c *jobController) AddHandler(ctx context.Context, name string, handler JobHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.Job); ok {
return handler(key, v)
} else {
return nil, nil
}
})
}
func (c *jobController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler JobHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.Job); ok && controller.ObjectInCluster(cluster, obj) {
return handler(key, v)
} else {
return nil, nil
}
})
}
type jobFactory struct {
}
func (c jobFactory) Object() runtime.Object {
return &v1.Job{}
}
func (c jobFactory) List() runtime.Object {
return &JobList{}
}
func (s *jobClient) Controller() JobController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.jobControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(JobGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &jobController{
GenericController: genericController,
}
s.client.jobControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type jobClient struct {
client *Client
ns string
objectClient *objectclient.ObjectClient
controller JobController
}
func (s *jobClient) ObjectClient() *objectclient.ObjectClient {
return s.objectClient
}
func (s *jobClient) Create(o *v1.Job) (*v1.Job, error) {
obj, err := s.objectClient.Create(o)
return obj.(*v1.Job), err
}
func (s *jobClient) Get(name string, opts metav1.GetOptions) (*v1.Job, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*v1.Job), err
}
func (s *jobClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.Job, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*v1.Job), err
}
func (s *jobClient) Update(o *v1.Job) (*v1.Job, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*v1.Job), err
}
func (s *jobClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *jobClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *jobClient) List(opts metav1.ListOptions) (*JobList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*JobList), err
}
func (s *jobClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *jobClient) Patch(o *v1.Job, patchType types.PatchType, data []byte, subresources ...string) (*v1.Job, error) {
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
return obj.(*v1.Job), err
}
func (s *jobClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *jobClient) AddHandler(ctx context.Context, name string, sync JobHandlerFunc) {
s.Controller().AddHandler(ctx, name, sync)
}
func (s *jobClient) AddLifecycle(ctx context.Context, name string, lifecycle JobLifecycle) {
sync := NewJobLifecycleAdapter(name, false, s, lifecycle)
s.Controller().AddHandler(ctx, name, sync)
}
func (s *jobClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync JobHandlerFunc) {
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
func (s *jobClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle JobLifecycle) {
sync := NewJobLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
type JobIndexer func(obj *v1.Job) ([]string, error)
type JobClientCache interface {
Get(namespace, name string) (*v1.Job, error)
List(namespace string, selector labels.Selector) ([]*v1.Job, error)
Index(name string, indexer JobIndexer)
GetIndexed(name, key string) ([]*v1.Job, error)
}
type JobClient interface {
Create(*v1.Job) (*v1.Job, error)
Get(namespace, name string, opts metav1.GetOptions) (*v1.Job, error)
Update(*v1.Job) (*v1.Job, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
List(namespace string, opts metav1.ListOptions) (*JobList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Cache() JobClientCache
OnCreate(ctx context.Context, name string, sync JobChangeHandlerFunc)
OnChange(ctx context.Context, name string, sync JobChangeHandlerFunc)
OnRemove(ctx context.Context, name string, sync JobChangeHandlerFunc)
Enqueue(namespace, name string)
Generic() controller.GenericController
ObjectClient() *objectclient.ObjectClient
Interface() JobInterface
}
type jobClientCache struct {
client *jobClient2
}
type jobClient2 struct {
iface JobInterface
controller JobController
}
func (n *jobClient2) Interface() JobInterface {
return n.iface
}
func (n *jobClient2) Generic() controller.GenericController {
return n.iface.Controller().Generic()
}
func (n *jobClient2) ObjectClient() *objectclient.ObjectClient {
return n.Interface().ObjectClient()
}
func (n *jobClient2) Enqueue(namespace, name string) {
n.iface.Controller().Enqueue(namespace, name)
}
func (n *jobClient2) Create(obj *v1.Job) (*v1.Job, error) {
return n.iface.Create(obj)
}
func (n *jobClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.Job, error) {
return n.iface.GetNamespaced(namespace, name, opts)
}
func (n *jobClient2) Update(obj *v1.Job) (*v1.Job, error) {
return n.iface.Update(obj)
}
func (n *jobClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return n.iface.DeleteNamespaced(namespace, name, options)
}
func (n *jobClient2) List(namespace string, opts metav1.ListOptions) (*JobList, error) {
return n.iface.List(opts)
}
func (n *jobClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return n.iface.Watch(opts)
}
func (n *jobClientCache) Get(namespace, name string) (*v1.Job, error) {
return n.client.controller.Lister().Get(namespace, name)
}
func (n *jobClientCache) List(namespace string, selector labels.Selector) ([]*v1.Job, error) {
return n.client.controller.Lister().List(namespace, selector)
}
func (n *jobClient2) Cache() JobClientCache {
n.loadController()
return &jobClientCache{
client: n,
}
}
func (n *jobClient2) OnCreate(ctx context.Context, name string, sync JobChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-create", &jobLifecycleDelegate{create: sync})
}
func (n *jobClient2) OnChange(ctx context.Context, name string, sync JobChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-change", &jobLifecycleDelegate{update: sync})
}
func (n *jobClient2) OnRemove(ctx context.Context, name string, sync JobChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name, &jobLifecycleDelegate{remove: sync})
}
func (n *jobClientCache) Index(name string, indexer JobIndexer) {
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
name: func(obj interface{}) ([]string, error) {
if v, ok := obj.(*v1.Job); ok {
return indexer(v)
}
return nil, nil
},
})
if err != nil {
panic(err)
}
}
func (n *jobClientCache) GetIndexed(name, key string) ([]*v1.Job, error) {
var result []*v1.Job
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
if v, ok := obj.(*v1.Job); ok {
result = append(result, v)
}
}
return result, nil
}
func (n *jobClient2) loadController() {
if n.controller == nil {
n.controller = n.iface.Controller()
}
}
type jobLifecycleDelegate struct {
create JobChangeHandlerFunc
update JobChangeHandlerFunc
remove JobChangeHandlerFunc
}
func (n *jobLifecycleDelegate) HasCreate() bool {
return n.create != nil
}
func (n *jobLifecycleDelegate) Create(obj *v1.Job) (runtime.Object, error) {
if n.create == nil {
return obj, nil
}
return n.create(obj)
}
func (n *jobLifecycleDelegate) HasFinalize() bool {
return n.remove != nil
}
func (n *jobLifecycleDelegate) Remove(obj *v1.Job) (runtime.Object, error) {
if n.remove == nil {
return obj, nil
}
return n.remove(obj)
}
func (n *jobLifecycleDelegate) Updated(obj *v1.Job) (runtime.Object, error) {
if n.update == nil {
return obj, nil
}
return n.update(obj)
}

View File

@ -1,63 +0,0 @@
package v1
import (
"github.com/rancher/norman/lifecycle"
v1 "k8s.io/api/batch/v1"
"k8s.io/apimachinery/pkg/runtime"
)
type JobLifecycle interface {
Create(obj *v1.Job) (runtime.Object, error)
Remove(obj *v1.Job) (runtime.Object, error)
Updated(obj *v1.Job) (runtime.Object, error)
}
type jobLifecycleAdapter struct {
lifecycle JobLifecycle
}
func (w *jobLifecycleAdapter) HasCreate() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasCreate()
}
func (w *jobLifecycleAdapter) HasFinalize() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasFinalize()
}
func (w *jobLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*v1.Job))
if o == nil {
return nil, err
}
return o, err
}
func (w *jobLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*v1.Job))
if o == nil {
return nil, err
}
return o, err
}
func (w *jobLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*v1.Job))
if o == nil {
return nil, err
}
return o, err
}
func NewJobLifecycleAdapter(name string, clusterScoped bool, client JobInterface, l JobLifecycle) JobHandlerFunc {
adapter := &jobLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *v1.Job) (runtime.Object, error) {
newObj, err := syncFn(key, obj)
if o, ok := newObj.(runtime.Object); ok {
return o, err
}
return nil, err
}
}

View File

@ -1,119 +0,0 @@
package v1
import (
"context"
"sync"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
"github.com/rancher/norman/objectclient/dynamic"
"github.com/rancher/norman/restwatch"
"k8s.io/client-go/rest"
)
type (
contextKeyType struct{}
contextClientsKeyType struct{}
)
type Interface interface {
RESTClient() rest.Interface
controller.Starter
JobsGetter
}
type Clients struct {
Interface Interface
Job JobClient
}
type Client struct {
sync.Mutex
restClient rest.Interface
starters []controller.Starter
jobControllers map[string]JobController
}
func Factory(ctx context.Context, config rest.Config) (context.Context, controller.Starter, error) {
c, err := NewForConfig(config)
if err != nil {
return ctx, nil, err
}
cs := NewClientsFromInterface(c)
ctx = context.WithValue(ctx, contextKeyType{}, c)
ctx = context.WithValue(ctx, contextClientsKeyType{}, cs)
return ctx, c, nil
}
func ClientsFrom(ctx context.Context) *Clients {
return ctx.Value(contextClientsKeyType{}).(*Clients)
}
func From(ctx context.Context) Interface {
return ctx.Value(contextKeyType{}).(Interface)
}
func NewClients(config rest.Config) (*Clients, error) {
iface, err := NewForConfig(config)
if err != nil {
return nil, err
}
return NewClientsFromInterface(iface), nil
}
func NewClientsFromInterface(iface Interface) *Clients {
return &Clients{
Interface: iface,
Job: &jobClient2{
iface: iface.Jobs(""),
},
}
}
func NewForConfig(config rest.Config) (Interface, error) {
if config.NegotiatedSerializer == nil {
config.NegotiatedSerializer = dynamic.NegotiatedSerializer
}
restClient, err := restwatch.UnversionedRESTClientFor(&config)
if err != nil {
return nil, err
}
return &Client{
restClient: restClient,
jobControllers: map[string]JobController{},
}, nil
}
func (c *Client) RESTClient() rest.Interface {
return c.restClient
}
func (c *Client) Sync(ctx context.Context) error {
return controller.Sync(ctx, c.starters...)
}
func (c *Client) Start(ctx context.Context, threadiness int) error {
return controller.Start(ctx, threadiness, c.starters...)
}
type JobsGetter interface {
Jobs(namespace string) JobInterface
}
func (c *Client) Jobs(namespace string) JobInterface {
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &JobResource, JobGroupVersionKind, jobFactory{})
return &jobClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}

View File

@ -1,39 +0,0 @@
package v1
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
const (
GroupName = "batch"
Version = "v1"
)
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: Version}
// Kind takes an unqualified kind and returns a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
)
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
// TODO this gets cleaned up when the types are fixed
scheme.AddKnownTypes(SchemeGroupVersion,
&JobList{},
)
return nil
}

View File

@ -1,441 +0,0 @@
package v1
import (
"context"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
ConfigMapGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "ConfigMap",
}
ConfigMapResource = metav1.APIResource{
Name: "configmaps",
SingularName: "configmap",
Namespaced: true,
Kind: ConfigMapGroupVersionKind.Kind,
}
)
func NewConfigMap(namespace, name string, obj v1.ConfigMap) *v1.ConfigMap {
obj.APIVersion, obj.Kind = ConfigMapGroupVersionKind.ToAPIVersionAndKind()
obj.Name = name
obj.Namespace = namespace
return &obj
}
type ConfigMapList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []v1.ConfigMap
}
type ConfigMapHandlerFunc func(key string, obj *v1.ConfigMap) (runtime.Object, error)
type ConfigMapChangeHandlerFunc func(obj *v1.ConfigMap) (runtime.Object, error)
type ConfigMapLister interface {
List(namespace string, selector labels.Selector) (ret []*v1.ConfigMap, err error)
Get(namespace, name string) (*v1.ConfigMap, error)
}
type ConfigMapController interface {
Generic() controller.GenericController
Informer() cache.SharedIndexInformer
Lister() ConfigMapLister
AddHandler(ctx context.Context, name string, handler ConfigMapHandlerFunc)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler ConfigMapHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type ConfigMapInterface interface {
ObjectClient() *objectclient.ObjectClient
Create(*v1.ConfigMap) (*v1.ConfigMap, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.ConfigMap, error)
Get(name string, opts metav1.GetOptions) (*v1.ConfigMap, error)
Update(*v1.ConfigMap) (*v1.ConfigMap, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*ConfigMapList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() ConfigMapController
AddHandler(ctx context.Context, name string, sync ConfigMapHandlerFunc)
AddLifecycle(ctx context.Context, name string, lifecycle ConfigMapLifecycle)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ConfigMapHandlerFunc)
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ConfigMapLifecycle)
}
type configMapLister struct {
controller *configMapController
}
func (l *configMapLister) List(namespace string, selector labels.Selector) (ret []*v1.ConfigMap, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*v1.ConfigMap))
})
return
}
func (l *configMapLister) Get(namespace, name string) (*v1.ConfigMap, error) {
var key string
if namespace != "" {
key = namespace + "/" + name
} else {
key = name
}
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: ConfigMapGroupVersionKind.Group,
Resource: "configMap",
}, key)
}
return obj.(*v1.ConfigMap), nil
}
type configMapController struct {
controller.GenericController
}
func (c *configMapController) Generic() controller.GenericController {
return c.GenericController
}
func (c *configMapController) Lister() ConfigMapLister {
return &configMapLister{
controller: c,
}
}
func (c *configMapController) AddHandler(ctx context.Context, name string, handler ConfigMapHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.ConfigMap); ok {
return handler(key, v)
} else {
return nil, nil
}
})
}
func (c *configMapController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler ConfigMapHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.ConfigMap); ok && controller.ObjectInCluster(cluster, obj) {
return handler(key, v)
} else {
return nil, nil
}
})
}
type configMapFactory struct {
}
func (c configMapFactory) Object() runtime.Object {
return &v1.ConfigMap{}
}
func (c configMapFactory) List() runtime.Object {
return &ConfigMapList{}
}
func (s *configMapClient) Controller() ConfigMapController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.configMapControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(ConfigMapGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &configMapController{
GenericController: genericController,
}
s.client.configMapControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type configMapClient struct {
client *Client
ns string
objectClient *objectclient.ObjectClient
controller ConfigMapController
}
func (s *configMapClient) ObjectClient() *objectclient.ObjectClient {
return s.objectClient
}
func (s *configMapClient) Create(o *v1.ConfigMap) (*v1.ConfigMap, error) {
obj, err := s.objectClient.Create(o)
return obj.(*v1.ConfigMap), err
}
func (s *configMapClient) Get(name string, opts metav1.GetOptions) (*v1.ConfigMap, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*v1.ConfigMap), err
}
func (s *configMapClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.ConfigMap, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*v1.ConfigMap), err
}
func (s *configMapClient) Update(o *v1.ConfigMap) (*v1.ConfigMap, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*v1.ConfigMap), err
}
func (s *configMapClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *configMapClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *configMapClient) List(opts metav1.ListOptions) (*ConfigMapList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*ConfigMapList), err
}
func (s *configMapClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *configMapClient) Patch(o *v1.ConfigMap, patchType types.PatchType, data []byte, subresources ...string) (*v1.ConfigMap, error) {
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
return obj.(*v1.ConfigMap), err
}
func (s *configMapClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *configMapClient) AddHandler(ctx context.Context, name string, sync ConfigMapHandlerFunc) {
s.Controller().AddHandler(ctx, name, sync)
}
func (s *configMapClient) AddLifecycle(ctx context.Context, name string, lifecycle ConfigMapLifecycle) {
sync := NewConfigMapLifecycleAdapter(name, false, s, lifecycle)
s.Controller().AddHandler(ctx, name, sync)
}
func (s *configMapClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ConfigMapHandlerFunc) {
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
func (s *configMapClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ConfigMapLifecycle) {
sync := NewConfigMapLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
type ConfigMapIndexer func(obj *v1.ConfigMap) ([]string, error)
type ConfigMapClientCache interface {
Get(namespace, name string) (*v1.ConfigMap, error)
List(namespace string, selector labels.Selector) ([]*v1.ConfigMap, error)
Index(name string, indexer ConfigMapIndexer)
GetIndexed(name, key string) ([]*v1.ConfigMap, error)
}
type ConfigMapClient interface {
Create(*v1.ConfigMap) (*v1.ConfigMap, error)
Get(namespace, name string, opts metav1.GetOptions) (*v1.ConfigMap, error)
Update(*v1.ConfigMap) (*v1.ConfigMap, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
List(namespace string, opts metav1.ListOptions) (*ConfigMapList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Cache() ConfigMapClientCache
OnCreate(ctx context.Context, name string, sync ConfigMapChangeHandlerFunc)
OnChange(ctx context.Context, name string, sync ConfigMapChangeHandlerFunc)
OnRemove(ctx context.Context, name string, sync ConfigMapChangeHandlerFunc)
Enqueue(namespace, name string)
Generic() controller.GenericController
ObjectClient() *objectclient.ObjectClient
Interface() ConfigMapInterface
}
type configMapClientCache struct {
client *configMapClient2
}
type configMapClient2 struct {
iface ConfigMapInterface
controller ConfigMapController
}
func (n *configMapClient2) Interface() ConfigMapInterface {
return n.iface
}
func (n *configMapClient2) Generic() controller.GenericController {
return n.iface.Controller().Generic()
}
func (n *configMapClient2) ObjectClient() *objectclient.ObjectClient {
return n.Interface().ObjectClient()
}
func (n *configMapClient2) Enqueue(namespace, name string) {
n.iface.Controller().Enqueue(namespace, name)
}
func (n *configMapClient2) Create(obj *v1.ConfigMap) (*v1.ConfigMap, error) {
return n.iface.Create(obj)
}
func (n *configMapClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.ConfigMap, error) {
return n.iface.GetNamespaced(namespace, name, opts)
}
func (n *configMapClient2) Update(obj *v1.ConfigMap) (*v1.ConfigMap, error) {
return n.iface.Update(obj)
}
func (n *configMapClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return n.iface.DeleteNamespaced(namespace, name, options)
}
func (n *configMapClient2) List(namespace string, opts metav1.ListOptions) (*ConfigMapList, error) {
return n.iface.List(opts)
}
func (n *configMapClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return n.iface.Watch(opts)
}
func (n *configMapClientCache) Get(namespace, name string) (*v1.ConfigMap, error) {
return n.client.controller.Lister().Get(namespace, name)
}
func (n *configMapClientCache) List(namespace string, selector labels.Selector) ([]*v1.ConfigMap, error) {
return n.client.controller.Lister().List(namespace, selector)
}
func (n *configMapClient2) Cache() ConfigMapClientCache {
n.loadController()
return &configMapClientCache{
client: n,
}
}
func (n *configMapClient2) OnCreate(ctx context.Context, name string, sync ConfigMapChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-create", &configMapLifecycleDelegate{create: sync})
}
func (n *configMapClient2) OnChange(ctx context.Context, name string, sync ConfigMapChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-change", &configMapLifecycleDelegate{update: sync})
}
func (n *configMapClient2) OnRemove(ctx context.Context, name string, sync ConfigMapChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name, &configMapLifecycleDelegate{remove: sync})
}
func (n *configMapClientCache) Index(name string, indexer ConfigMapIndexer) {
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
name: func(obj interface{}) ([]string, error) {
if v, ok := obj.(*v1.ConfigMap); ok {
return indexer(v)
}
return nil, nil
},
})
if err != nil {
panic(err)
}
}
func (n *configMapClientCache) GetIndexed(name, key string) ([]*v1.ConfigMap, error) {
var result []*v1.ConfigMap
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
if v, ok := obj.(*v1.ConfigMap); ok {
result = append(result, v)
}
}
return result, nil
}
func (n *configMapClient2) loadController() {
if n.controller == nil {
n.controller = n.iface.Controller()
}
}
type configMapLifecycleDelegate struct {
create ConfigMapChangeHandlerFunc
update ConfigMapChangeHandlerFunc
remove ConfigMapChangeHandlerFunc
}
func (n *configMapLifecycleDelegate) HasCreate() bool {
return n.create != nil
}
func (n *configMapLifecycleDelegate) Create(obj *v1.ConfigMap) (runtime.Object, error) {
if n.create == nil {
return obj, nil
}
return n.create(obj)
}
func (n *configMapLifecycleDelegate) HasFinalize() bool {
return n.remove != nil
}
func (n *configMapLifecycleDelegate) Remove(obj *v1.ConfigMap) (runtime.Object, error) {
if n.remove == nil {
return obj, nil
}
return n.remove(obj)
}
func (n *configMapLifecycleDelegate) Updated(obj *v1.ConfigMap) (runtime.Object, error) {
if n.update == nil {
return obj, nil
}
return n.update(obj)
}

View File

@ -1,63 +0,0 @@
package v1
import (
"github.com/rancher/norman/lifecycle"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)
type ConfigMapLifecycle interface {
Create(obj *v1.ConfigMap) (runtime.Object, error)
Remove(obj *v1.ConfigMap) (runtime.Object, error)
Updated(obj *v1.ConfigMap) (runtime.Object, error)
}
type configMapLifecycleAdapter struct {
lifecycle ConfigMapLifecycle
}
func (w *configMapLifecycleAdapter) HasCreate() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasCreate()
}
func (w *configMapLifecycleAdapter) HasFinalize() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasFinalize()
}
func (w *configMapLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*v1.ConfigMap))
if o == nil {
return nil, err
}
return o, err
}
func (w *configMapLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*v1.ConfigMap))
if o == nil {
return nil, err
}
return o, err
}
func (w *configMapLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*v1.ConfigMap))
if o == nil {
return nil, err
}
return o, err
}
func NewConfigMapLifecycleAdapter(name string, clusterScoped bool, client ConfigMapInterface, l ConfigMapLifecycle) ConfigMapHandlerFunc {
adapter := &configMapLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *v1.ConfigMap) (runtime.Object, error) {
newObj, err := syncFn(key, obj)
if o, ok := newObj.(runtime.Object); ok {
return o, err
}
return nil, err
}
}

View File

@ -1,204 +0,0 @@
package v1
import (
corev1 "k8s.io/api/core/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ConfigMapList) DeepCopyInto(out *ConfigMapList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]corev1.ConfigMap, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigMapList.
func (in *ConfigMapList) DeepCopy() *ConfigMapList {
if in == nil {
return nil
}
out := new(ConfigMapList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ConfigMapList) 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 *EndpointsList) DeepCopyInto(out *EndpointsList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]corev1.Endpoints, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointsList.
func (in *EndpointsList) DeepCopy() *EndpointsList {
if in == nil {
return nil
}
out := new(EndpointsList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *EndpointsList) 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 *NodeList) DeepCopyInto(out *NodeList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]corev1.Node, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeList.
func (in *NodeList) DeepCopy() *NodeList {
if in == nil {
return nil
}
out := new(NodeList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *NodeList) 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 *PodList) DeepCopyInto(out *PodList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]corev1.Pod, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodList.
func (in *PodList) DeepCopy() *PodList {
if in == nil {
return nil
}
out := new(PodList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *PodList) 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 *ServiceAccountList) DeepCopyInto(out *ServiceAccountList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]corev1.ServiceAccount, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceAccountList.
func (in *ServiceAccountList) DeepCopy() *ServiceAccountList {
if in == nil {
return nil
}
out := new(ServiceAccountList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ServiceAccountList) 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 *ServiceList) DeepCopyInto(out *ServiceList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]corev1.Service, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceList.
func (in *ServiceList) DeepCopy() *ServiceList {
if in == nil {
return nil
}
out := new(ServiceList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ServiceList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}

View File

@ -1,441 +0,0 @@
package v1
import (
"context"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
EndpointsGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "Endpoints",
}
EndpointsResource = metav1.APIResource{
Name: "endpoints",
SingularName: "endpoints",
Namespaced: true,
Kind: EndpointsGroupVersionKind.Kind,
}
)
func NewEndpoints(namespace, name string, obj v1.Endpoints) *v1.Endpoints {
obj.APIVersion, obj.Kind = EndpointsGroupVersionKind.ToAPIVersionAndKind()
obj.Name = name
obj.Namespace = namespace
return &obj
}
type EndpointsList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []v1.Endpoints
}
type EndpointsHandlerFunc func(key string, obj *v1.Endpoints) (runtime.Object, error)
type EndpointsChangeHandlerFunc func(obj *v1.Endpoints) (runtime.Object, error)
type EndpointsLister interface {
List(namespace string, selector labels.Selector) (ret []*v1.Endpoints, err error)
Get(namespace, name string) (*v1.Endpoints, error)
}
type EndpointsController interface {
Generic() controller.GenericController
Informer() cache.SharedIndexInformer
Lister() EndpointsLister
AddHandler(ctx context.Context, name string, handler EndpointsHandlerFunc)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler EndpointsHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type EndpointsInterface interface {
ObjectClient() *objectclient.ObjectClient
Create(*v1.Endpoints) (*v1.Endpoints, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.Endpoints, error)
Get(name string, opts metav1.GetOptions) (*v1.Endpoints, error)
Update(*v1.Endpoints) (*v1.Endpoints, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*EndpointsList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() EndpointsController
AddHandler(ctx context.Context, name string, sync EndpointsHandlerFunc)
AddLifecycle(ctx context.Context, name string, lifecycle EndpointsLifecycle)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync EndpointsHandlerFunc)
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle EndpointsLifecycle)
}
type endpointsLister struct {
controller *endpointsController
}
func (l *endpointsLister) List(namespace string, selector labels.Selector) (ret []*v1.Endpoints, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*v1.Endpoints))
})
return
}
func (l *endpointsLister) Get(namespace, name string) (*v1.Endpoints, error) {
var key string
if namespace != "" {
key = namespace + "/" + name
} else {
key = name
}
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: EndpointsGroupVersionKind.Group,
Resource: "endpoints",
}, key)
}
return obj.(*v1.Endpoints), nil
}
type endpointsController struct {
controller.GenericController
}
func (c *endpointsController) Generic() controller.GenericController {
return c.GenericController
}
func (c *endpointsController) Lister() EndpointsLister {
return &endpointsLister{
controller: c,
}
}
func (c *endpointsController) AddHandler(ctx context.Context, name string, handler EndpointsHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.Endpoints); ok {
return handler(key, v)
} else {
return nil, nil
}
})
}
func (c *endpointsController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler EndpointsHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.Endpoints); ok && controller.ObjectInCluster(cluster, obj) {
return handler(key, v)
} else {
return nil, nil
}
})
}
type endpointsFactory struct {
}
func (c endpointsFactory) Object() runtime.Object {
return &v1.Endpoints{}
}
func (c endpointsFactory) List() runtime.Object {
return &EndpointsList{}
}
func (s *endpointsClient) Controller() EndpointsController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.endpointsControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(EndpointsGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &endpointsController{
GenericController: genericController,
}
s.client.endpointsControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type endpointsClient struct {
client *Client
ns string
objectClient *objectclient.ObjectClient
controller EndpointsController
}
func (s *endpointsClient) ObjectClient() *objectclient.ObjectClient {
return s.objectClient
}
func (s *endpointsClient) Create(o *v1.Endpoints) (*v1.Endpoints, error) {
obj, err := s.objectClient.Create(o)
return obj.(*v1.Endpoints), err
}
func (s *endpointsClient) Get(name string, opts metav1.GetOptions) (*v1.Endpoints, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*v1.Endpoints), err
}
func (s *endpointsClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.Endpoints, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*v1.Endpoints), err
}
func (s *endpointsClient) Update(o *v1.Endpoints) (*v1.Endpoints, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*v1.Endpoints), err
}
func (s *endpointsClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *endpointsClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *endpointsClient) List(opts metav1.ListOptions) (*EndpointsList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*EndpointsList), err
}
func (s *endpointsClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *endpointsClient) Patch(o *v1.Endpoints, patchType types.PatchType, data []byte, subresources ...string) (*v1.Endpoints, error) {
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
return obj.(*v1.Endpoints), err
}
func (s *endpointsClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *endpointsClient) AddHandler(ctx context.Context, name string, sync EndpointsHandlerFunc) {
s.Controller().AddHandler(ctx, name, sync)
}
func (s *endpointsClient) AddLifecycle(ctx context.Context, name string, lifecycle EndpointsLifecycle) {
sync := NewEndpointsLifecycleAdapter(name, false, s, lifecycle)
s.Controller().AddHandler(ctx, name, sync)
}
func (s *endpointsClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync EndpointsHandlerFunc) {
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
func (s *endpointsClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle EndpointsLifecycle) {
sync := NewEndpointsLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
type EndpointsIndexer func(obj *v1.Endpoints) ([]string, error)
type EndpointsClientCache interface {
Get(namespace, name string) (*v1.Endpoints, error)
List(namespace string, selector labels.Selector) ([]*v1.Endpoints, error)
Index(name string, indexer EndpointsIndexer)
GetIndexed(name, key string) ([]*v1.Endpoints, error)
}
type EndpointsClient interface {
Create(*v1.Endpoints) (*v1.Endpoints, error)
Get(namespace, name string, opts metav1.GetOptions) (*v1.Endpoints, error)
Update(*v1.Endpoints) (*v1.Endpoints, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
List(namespace string, opts metav1.ListOptions) (*EndpointsList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Cache() EndpointsClientCache
OnCreate(ctx context.Context, name string, sync EndpointsChangeHandlerFunc)
OnChange(ctx context.Context, name string, sync EndpointsChangeHandlerFunc)
OnRemove(ctx context.Context, name string, sync EndpointsChangeHandlerFunc)
Enqueue(namespace, name string)
Generic() controller.GenericController
ObjectClient() *objectclient.ObjectClient
Interface() EndpointsInterface
}
type endpointsClientCache struct {
client *endpointsClient2
}
type endpointsClient2 struct {
iface EndpointsInterface
controller EndpointsController
}
func (n *endpointsClient2) Interface() EndpointsInterface {
return n.iface
}
func (n *endpointsClient2) Generic() controller.GenericController {
return n.iface.Controller().Generic()
}
func (n *endpointsClient2) ObjectClient() *objectclient.ObjectClient {
return n.Interface().ObjectClient()
}
func (n *endpointsClient2) Enqueue(namespace, name string) {
n.iface.Controller().Enqueue(namespace, name)
}
func (n *endpointsClient2) Create(obj *v1.Endpoints) (*v1.Endpoints, error) {
return n.iface.Create(obj)
}
func (n *endpointsClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.Endpoints, error) {
return n.iface.GetNamespaced(namespace, name, opts)
}
func (n *endpointsClient2) Update(obj *v1.Endpoints) (*v1.Endpoints, error) {
return n.iface.Update(obj)
}
func (n *endpointsClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return n.iface.DeleteNamespaced(namespace, name, options)
}
func (n *endpointsClient2) List(namespace string, opts metav1.ListOptions) (*EndpointsList, error) {
return n.iface.List(opts)
}
func (n *endpointsClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return n.iface.Watch(opts)
}
func (n *endpointsClientCache) Get(namespace, name string) (*v1.Endpoints, error) {
return n.client.controller.Lister().Get(namespace, name)
}
func (n *endpointsClientCache) List(namespace string, selector labels.Selector) ([]*v1.Endpoints, error) {
return n.client.controller.Lister().List(namespace, selector)
}
func (n *endpointsClient2) Cache() EndpointsClientCache {
n.loadController()
return &endpointsClientCache{
client: n,
}
}
func (n *endpointsClient2) OnCreate(ctx context.Context, name string, sync EndpointsChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-create", &endpointsLifecycleDelegate{create: sync})
}
func (n *endpointsClient2) OnChange(ctx context.Context, name string, sync EndpointsChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-change", &endpointsLifecycleDelegate{update: sync})
}
func (n *endpointsClient2) OnRemove(ctx context.Context, name string, sync EndpointsChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name, &endpointsLifecycleDelegate{remove: sync})
}
func (n *endpointsClientCache) Index(name string, indexer EndpointsIndexer) {
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
name: func(obj interface{}) ([]string, error) {
if v, ok := obj.(*v1.Endpoints); ok {
return indexer(v)
}
return nil, nil
},
})
if err != nil {
panic(err)
}
}
func (n *endpointsClientCache) GetIndexed(name, key string) ([]*v1.Endpoints, error) {
var result []*v1.Endpoints
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
if v, ok := obj.(*v1.Endpoints); ok {
result = append(result, v)
}
}
return result, nil
}
func (n *endpointsClient2) loadController() {
if n.controller == nil {
n.controller = n.iface.Controller()
}
}
type endpointsLifecycleDelegate struct {
create EndpointsChangeHandlerFunc
update EndpointsChangeHandlerFunc
remove EndpointsChangeHandlerFunc
}
func (n *endpointsLifecycleDelegate) HasCreate() bool {
return n.create != nil
}
func (n *endpointsLifecycleDelegate) Create(obj *v1.Endpoints) (runtime.Object, error) {
if n.create == nil {
return obj, nil
}
return n.create(obj)
}
func (n *endpointsLifecycleDelegate) HasFinalize() bool {
return n.remove != nil
}
func (n *endpointsLifecycleDelegate) Remove(obj *v1.Endpoints) (runtime.Object, error) {
if n.remove == nil {
return obj, nil
}
return n.remove(obj)
}
func (n *endpointsLifecycleDelegate) Updated(obj *v1.Endpoints) (runtime.Object, error) {
if n.update == nil {
return obj, nil
}
return n.update(obj)
}

View File

@ -1,63 +0,0 @@
package v1
import (
"github.com/rancher/norman/lifecycle"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)
type EndpointsLifecycle interface {
Create(obj *v1.Endpoints) (runtime.Object, error)
Remove(obj *v1.Endpoints) (runtime.Object, error)
Updated(obj *v1.Endpoints) (runtime.Object, error)
}
type endpointsLifecycleAdapter struct {
lifecycle EndpointsLifecycle
}
func (w *endpointsLifecycleAdapter) HasCreate() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasCreate()
}
func (w *endpointsLifecycleAdapter) HasFinalize() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasFinalize()
}
func (w *endpointsLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*v1.Endpoints))
if o == nil {
return nil, err
}
return o, err
}
func (w *endpointsLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*v1.Endpoints))
if o == nil {
return nil, err
}
return o, err
}
func (w *endpointsLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*v1.Endpoints))
if o == nil {
return nil, err
}
return o, err
}
func NewEndpointsLifecycleAdapter(name string, clusterScoped bool, client EndpointsInterface, l EndpointsLifecycle) EndpointsHandlerFunc {
adapter := &endpointsLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *v1.Endpoints) (runtime.Object, error) {
newObj, err := syncFn(key, obj)
if o, ok := newObj.(runtime.Object); ok {
return o, err
}
return nil, err
}
}

View File

@ -1,219 +0,0 @@
package v1
import (
"context"
"sync"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
"github.com/rancher/norman/objectclient/dynamic"
"github.com/rancher/norman/restwatch"
"k8s.io/client-go/rest"
)
type (
contextKeyType struct{}
contextClientsKeyType struct{}
)
type Interface interface {
RESTClient() rest.Interface
controller.Starter
NodesGetter
ServiceAccountsGetter
EndpointsGetter
ServicesGetter
PodsGetter
ConfigMapsGetter
}
type Clients struct {
Interface Interface
Node NodeClient
ServiceAccount ServiceAccountClient
Endpoints EndpointsClient
Service ServiceClient
Pod PodClient
ConfigMap ConfigMapClient
}
type Client struct {
sync.Mutex
restClient rest.Interface
starters []controller.Starter
nodeControllers map[string]NodeController
serviceAccountControllers map[string]ServiceAccountController
endpointsControllers map[string]EndpointsController
serviceControllers map[string]ServiceController
podControllers map[string]PodController
configMapControllers map[string]ConfigMapController
}
func Factory(ctx context.Context, config rest.Config) (context.Context, controller.Starter, error) {
c, err := NewForConfig(config)
if err != nil {
return ctx, nil, err
}
cs := NewClientsFromInterface(c)
ctx = context.WithValue(ctx, contextKeyType{}, c)
ctx = context.WithValue(ctx, contextClientsKeyType{}, cs)
return ctx, c, nil
}
func ClientsFrom(ctx context.Context) *Clients {
return ctx.Value(contextClientsKeyType{}).(*Clients)
}
func From(ctx context.Context) Interface {
return ctx.Value(contextKeyType{}).(Interface)
}
func NewClients(config rest.Config) (*Clients, error) {
iface, err := NewForConfig(config)
if err != nil {
return nil, err
}
return NewClientsFromInterface(iface), nil
}
func NewClientsFromInterface(iface Interface) *Clients {
return &Clients{
Interface: iface,
Node: &nodeClient2{
iface: iface.Nodes(""),
},
ServiceAccount: &serviceAccountClient2{
iface: iface.ServiceAccounts(""),
},
Endpoints: &endpointsClient2{
iface: iface.Endpoints(""),
},
Service: &serviceClient2{
iface: iface.Services(""),
},
Pod: &podClient2{
iface: iface.Pods(""),
},
ConfigMap: &configMapClient2{
iface: iface.ConfigMaps(""),
},
}
}
func NewForConfig(config rest.Config) (Interface, error) {
if config.NegotiatedSerializer == nil {
config.NegotiatedSerializer = dynamic.NegotiatedSerializer
}
restClient, err := restwatch.UnversionedRESTClientFor(&config)
if err != nil {
return nil, err
}
return &Client{
restClient: restClient,
nodeControllers: map[string]NodeController{},
serviceAccountControllers: map[string]ServiceAccountController{},
endpointsControllers: map[string]EndpointsController{},
serviceControllers: map[string]ServiceController{},
podControllers: map[string]PodController{},
configMapControllers: map[string]ConfigMapController{},
}, nil
}
func (c *Client) RESTClient() rest.Interface {
return c.restClient
}
func (c *Client) Sync(ctx context.Context) error {
return controller.Sync(ctx, c.starters...)
}
func (c *Client) Start(ctx context.Context, threadiness int) error {
return controller.Start(ctx, threadiness, c.starters...)
}
type NodesGetter interface {
Nodes(namespace string) NodeInterface
}
func (c *Client) Nodes(namespace string) NodeInterface {
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &NodeResource, NodeGroupVersionKind, nodeFactory{})
return &nodeClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type ServiceAccountsGetter interface {
ServiceAccounts(namespace string) ServiceAccountInterface
}
func (c *Client) ServiceAccounts(namespace string) ServiceAccountInterface {
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &ServiceAccountResource, ServiceAccountGroupVersionKind, serviceAccountFactory{})
return &serviceAccountClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type EndpointsGetter interface {
Endpoints(namespace string) EndpointsInterface
}
func (c *Client) Endpoints(namespace string) EndpointsInterface {
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &EndpointsResource, EndpointsGroupVersionKind, endpointsFactory{})
return &endpointsClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type ServicesGetter interface {
Services(namespace string) ServiceInterface
}
func (c *Client) Services(namespace string) ServiceInterface {
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &ServiceResource, ServiceGroupVersionKind, serviceFactory{})
return &serviceClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type PodsGetter interface {
Pods(namespace string) PodInterface
}
func (c *Client) Pods(namespace string) PodInterface {
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &PodResource, PodGroupVersionKind, podFactory{})
return &podClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type ConfigMapsGetter interface {
ConfigMaps(namespace string) ConfigMapInterface
}
func (c *Client) ConfigMaps(namespace string) ConfigMapInterface {
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &ConfigMapResource, ConfigMapGroupVersionKind, configMapFactory{})
return &configMapClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}

View File

@ -1,440 +0,0 @@
package v1
import (
"context"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
NodeGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "Node",
}
NodeResource = metav1.APIResource{
Name: "nodes",
SingularName: "node",
Namespaced: false,
Kind: NodeGroupVersionKind.Kind,
}
)
func NewNode(namespace, name string, obj v1.Node) *v1.Node {
obj.APIVersion, obj.Kind = NodeGroupVersionKind.ToAPIVersionAndKind()
obj.Name = name
obj.Namespace = namespace
return &obj
}
type NodeList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []v1.Node
}
type NodeHandlerFunc func(key string, obj *v1.Node) (runtime.Object, error)
type NodeChangeHandlerFunc func(obj *v1.Node) (runtime.Object, error)
type NodeLister interface {
List(namespace string, selector labels.Selector) (ret []*v1.Node, err error)
Get(namespace, name string) (*v1.Node, error)
}
type NodeController interface {
Generic() controller.GenericController
Informer() cache.SharedIndexInformer
Lister() NodeLister
AddHandler(ctx context.Context, name string, handler NodeHandlerFunc)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler NodeHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type NodeInterface interface {
ObjectClient() *objectclient.ObjectClient
Create(*v1.Node) (*v1.Node, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.Node, error)
Get(name string, opts metav1.GetOptions) (*v1.Node, error)
Update(*v1.Node) (*v1.Node, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*NodeList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() NodeController
AddHandler(ctx context.Context, name string, sync NodeHandlerFunc)
AddLifecycle(ctx context.Context, name string, lifecycle NodeLifecycle)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync NodeHandlerFunc)
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle NodeLifecycle)
}
type nodeLister struct {
controller *nodeController
}
func (l *nodeLister) List(namespace string, selector labels.Selector) (ret []*v1.Node, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*v1.Node))
})
return
}
func (l *nodeLister) Get(namespace, name string) (*v1.Node, error) {
var key string
if namespace != "" {
key = namespace + "/" + name
} else {
key = name
}
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: NodeGroupVersionKind.Group,
Resource: "node",
}, key)
}
return obj.(*v1.Node), nil
}
type nodeController struct {
controller.GenericController
}
func (c *nodeController) Generic() controller.GenericController {
return c.GenericController
}
func (c *nodeController) Lister() NodeLister {
return &nodeLister{
controller: c,
}
}
func (c *nodeController) AddHandler(ctx context.Context, name string, handler NodeHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.Node); ok {
return handler(key, v)
} else {
return nil, nil
}
})
}
func (c *nodeController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler NodeHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.Node); ok && controller.ObjectInCluster(cluster, obj) {
return handler(key, v)
} else {
return nil, nil
}
})
}
type nodeFactory struct {
}
func (c nodeFactory) Object() runtime.Object {
return &v1.Node{}
}
func (c nodeFactory) List() runtime.Object {
return &NodeList{}
}
func (s *nodeClient) Controller() NodeController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.nodeControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(NodeGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &nodeController{
GenericController: genericController,
}
s.client.nodeControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type nodeClient struct {
client *Client
ns string
objectClient *objectclient.ObjectClient
controller NodeController
}
func (s *nodeClient) ObjectClient() *objectclient.ObjectClient {
return s.objectClient
}
func (s *nodeClient) Create(o *v1.Node) (*v1.Node, error) {
obj, err := s.objectClient.Create(o)
return obj.(*v1.Node), err
}
func (s *nodeClient) Get(name string, opts metav1.GetOptions) (*v1.Node, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*v1.Node), err
}
func (s *nodeClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.Node, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*v1.Node), err
}
func (s *nodeClient) Update(o *v1.Node) (*v1.Node, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*v1.Node), err
}
func (s *nodeClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *nodeClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *nodeClient) List(opts metav1.ListOptions) (*NodeList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*NodeList), err
}
func (s *nodeClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *nodeClient) Patch(o *v1.Node, patchType types.PatchType, data []byte, subresources ...string) (*v1.Node, error) {
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
return obj.(*v1.Node), err
}
func (s *nodeClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *nodeClient) AddHandler(ctx context.Context, name string, sync NodeHandlerFunc) {
s.Controller().AddHandler(ctx, name, sync)
}
func (s *nodeClient) AddLifecycle(ctx context.Context, name string, lifecycle NodeLifecycle) {
sync := NewNodeLifecycleAdapter(name, false, s, lifecycle)
s.Controller().AddHandler(ctx, name, sync)
}
func (s *nodeClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync NodeHandlerFunc) {
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
func (s *nodeClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle NodeLifecycle) {
sync := NewNodeLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
type NodeIndexer func(obj *v1.Node) ([]string, error)
type NodeClientCache interface {
Get(namespace, name string) (*v1.Node, error)
List(namespace string, selector labels.Selector) ([]*v1.Node, error)
Index(name string, indexer NodeIndexer)
GetIndexed(name, key string) ([]*v1.Node, error)
}
type NodeClient interface {
Create(*v1.Node) (*v1.Node, error)
Get(namespace, name string, opts metav1.GetOptions) (*v1.Node, error)
Update(*v1.Node) (*v1.Node, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
List(namespace string, opts metav1.ListOptions) (*NodeList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Cache() NodeClientCache
OnCreate(ctx context.Context, name string, sync NodeChangeHandlerFunc)
OnChange(ctx context.Context, name string, sync NodeChangeHandlerFunc)
OnRemove(ctx context.Context, name string, sync NodeChangeHandlerFunc)
Enqueue(namespace, name string)
Generic() controller.GenericController
ObjectClient() *objectclient.ObjectClient
Interface() NodeInterface
}
type nodeClientCache struct {
client *nodeClient2
}
type nodeClient2 struct {
iface NodeInterface
controller NodeController
}
func (n *nodeClient2) Interface() NodeInterface {
return n.iface
}
func (n *nodeClient2) Generic() controller.GenericController {
return n.iface.Controller().Generic()
}
func (n *nodeClient2) ObjectClient() *objectclient.ObjectClient {
return n.Interface().ObjectClient()
}
func (n *nodeClient2) Enqueue(namespace, name string) {
n.iface.Controller().Enqueue(namespace, name)
}
func (n *nodeClient2) Create(obj *v1.Node) (*v1.Node, error) {
return n.iface.Create(obj)
}
func (n *nodeClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.Node, error) {
return n.iface.GetNamespaced(namespace, name, opts)
}
func (n *nodeClient2) Update(obj *v1.Node) (*v1.Node, error) {
return n.iface.Update(obj)
}
func (n *nodeClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return n.iface.DeleteNamespaced(namespace, name, options)
}
func (n *nodeClient2) List(namespace string, opts metav1.ListOptions) (*NodeList, error) {
return n.iface.List(opts)
}
func (n *nodeClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return n.iface.Watch(opts)
}
func (n *nodeClientCache) Get(namespace, name string) (*v1.Node, error) {
return n.client.controller.Lister().Get(namespace, name)
}
func (n *nodeClientCache) List(namespace string, selector labels.Selector) ([]*v1.Node, error) {
return n.client.controller.Lister().List(namespace, selector)
}
func (n *nodeClient2) Cache() NodeClientCache {
n.loadController()
return &nodeClientCache{
client: n,
}
}
func (n *nodeClient2) OnCreate(ctx context.Context, name string, sync NodeChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-create", &nodeLifecycleDelegate{create: sync})
}
func (n *nodeClient2) OnChange(ctx context.Context, name string, sync NodeChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-change", &nodeLifecycleDelegate{update: sync})
}
func (n *nodeClient2) OnRemove(ctx context.Context, name string, sync NodeChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name, &nodeLifecycleDelegate{remove: sync})
}
func (n *nodeClientCache) Index(name string, indexer NodeIndexer) {
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
name: func(obj interface{}) ([]string, error) {
if v, ok := obj.(*v1.Node); ok {
return indexer(v)
}
return nil, nil
},
})
if err != nil {
panic(err)
}
}
func (n *nodeClientCache) GetIndexed(name, key string) ([]*v1.Node, error) {
var result []*v1.Node
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
if v, ok := obj.(*v1.Node); ok {
result = append(result, v)
}
}
return result, nil
}
func (n *nodeClient2) loadController() {
if n.controller == nil {
n.controller = n.iface.Controller()
}
}
type nodeLifecycleDelegate struct {
create NodeChangeHandlerFunc
update NodeChangeHandlerFunc
remove NodeChangeHandlerFunc
}
func (n *nodeLifecycleDelegate) HasCreate() bool {
return n.create != nil
}
func (n *nodeLifecycleDelegate) Create(obj *v1.Node) (runtime.Object, error) {
if n.create == nil {
return obj, nil
}
return n.create(obj)
}
func (n *nodeLifecycleDelegate) HasFinalize() bool {
return n.remove != nil
}
func (n *nodeLifecycleDelegate) Remove(obj *v1.Node) (runtime.Object, error) {
if n.remove == nil {
return obj, nil
}
return n.remove(obj)
}
func (n *nodeLifecycleDelegate) Updated(obj *v1.Node) (runtime.Object, error) {
if n.update == nil {
return obj, nil
}
return n.update(obj)
}

View File

@ -1,63 +0,0 @@
package v1
import (
"github.com/rancher/norman/lifecycle"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)
type NodeLifecycle interface {
Create(obj *v1.Node) (runtime.Object, error)
Remove(obj *v1.Node) (runtime.Object, error)
Updated(obj *v1.Node) (runtime.Object, error)
}
type nodeLifecycleAdapter struct {
lifecycle NodeLifecycle
}
func (w *nodeLifecycleAdapter) HasCreate() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasCreate()
}
func (w *nodeLifecycleAdapter) HasFinalize() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasFinalize()
}
func (w *nodeLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*v1.Node))
if o == nil {
return nil, err
}
return o, err
}
func (w *nodeLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*v1.Node))
if o == nil {
return nil, err
}
return o, err
}
func (w *nodeLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*v1.Node))
if o == nil {
return nil, err
}
return o, err
}
func NewNodeLifecycleAdapter(name string, clusterScoped bool, client NodeInterface, l NodeLifecycle) NodeHandlerFunc {
adapter := &nodeLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *v1.Node) (runtime.Object, error) {
newObj, err := syncFn(key, obj)
if o, ok := newObj.(runtime.Object); ok {
return o, err
}
return nil, err
}
}

View File

@ -1,441 +0,0 @@
package v1
import (
"context"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
PodGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "Pod",
}
PodResource = metav1.APIResource{
Name: "pods",
SingularName: "pod",
Namespaced: true,
Kind: PodGroupVersionKind.Kind,
}
)
func NewPod(namespace, name string, obj v1.Pod) *v1.Pod {
obj.APIVersion, obj.Kind = PodGroupVersionKind.ToAPIVersionAndKind()
obj.Name = name
obj.Namespace = namespace
return &obj
}
type PodList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []v1.Pod
}
type PodHandlerFunc func(key string, obj *v1.Pod) (runtime.Object, error)
type PodChangeHandlerFunc func(obj *v1.Pod) (runtime.Object, error)
type PodLister interface {
List(namespace string, selector labels.Selector) (ret []*v1.Pod, err error)
Get(namespace, name string) (*v1.Pod, error)
}
type PodController interface {
Generic() controller.GenericController
Informer() cache.SharedIndexInformer
Lister() PodLister
AddHandler(ctx context.Context, name string, handler PodHandlerFunc)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler PodHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type PodInterface interface {
ObjectClient() *objectclient.ObjectClient
Create(*v1.Pod) (*v1.Pod, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.Pod, error)
Get(name string, opts metav1.GetOptions) (*v1.Pod, error)
Update(*v1.Pod) (*v1.Pod, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*PodList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() PodController
AddHandler(ctx context.Context, name string, sync PodHandlerFunc)
AddLifecycle(ctx context.Context, name string, lifecycle PodLifecycle)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync PodHandlerFunc)
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle PodLifecycle)
}
type podLister struct {
controller *podController
}
func (l *podLister) List(namespace string, selector labels.Selector) (ret []*v1.Pod, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*v1.Pod))
})
return
}
func (l *podLister) Get(namespace, name string) (*v1.Pod, error) {
var key string
if namespace != "" {
key = namespace + "/" + name
} else {
key = name
}
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: PodGroupVersionKind.Group,
Resource: "pod",
}, key)
}
return obj.(*v1.Pod), nil
}
type podController struct {
controller.GenericController
}
func (c *podController) Generic() controller.GenericController {
return c.GenericController
}
func (c *podController) Lister() PodLister {
return &podLister{
controller: c,
}
}
func (c *podController) AddHandler(ctx context.Context, name string, handler PodHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.Pod); ok {
return handler(key, v)
} else {
return nil, nil
}
})
}
func (c *podController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler PodHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.Pod); ok && controller.ObjectInCluster(cluster, obj) {
return handler(key, v)
} else {
return nil, nil
}
})
}
type podFactory struct {
}
func (c podFactory) Object() runtime.Object {
return &v1.Pod{}
}
func (c podFactory) List() runtime.Object {
return &PodList{}
}
func (s *podClient) Controller() PodController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.podControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(PodGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &podController{
GenericController: genericController,
}
s.client.podControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type podClient struct {
client *Client
ns string
objectClient *objectclient.ObjectClient
controller PodController
}
func (s *podClient) ObjectClient() *objectclient.ObjectClient {
return s.objectClient
}
func (s *podClient) Create(o *v1.Pod) (*v1.Pod, error) {
obj, err := s.objectClient.Create(o)
return obj.(*v1.Pod), err
}
func (s *podClient) Get(name string, opts metav1.GetOptions) (*v1.Pod, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*v1.Pod), err
}
func (s *podClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.Pod, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*v1.Pod), err
}
func (s *podClient) Update(o *v1.Pod) (*v1.Pod, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*v1.Pod), err
}
func (s *podClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *podClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *podClient) List(opts metav1.ListOptions) (*PodList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*PodList), err
}
func (s *podClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *podClient) Patch(o *v1.Pod, patchType types.PatchType, data []byte, subresources ...string) (*v1.Pod, error) {
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
return obj.(*v1.Pod), err
}
func (s *podClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *podClient) AddHandler(ctx context.Context, name string, sync PodHandlerFunc) {
s.Controller().AddHandler(ctx, name, sync)
}
func (s *podClient) AddLifecycle(ctx context.Context, name string, lifecycle PodLifecycle) {
sync := NewPodLifecycleAdapter(name, false, s, lifecycle)
s.Controller().AddHandler(ctx, name, sync)
}
func (s *podClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync PodHandlerFunc) {
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
func (s *podClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle PodLifecycle) {
sync := NewPodLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
type PodIndexer func(obj *v1.Pod) ([]string, error)
type PodClientCache interface {
Get(namespace, name string) (*v1.Pod, error)
List(namespace string, selector labels.Selector) ([]*v1.Pod, error)
Index(name string, indexer PodIndexer)
GetIndexed(name, key string) ([]*v1.Pod, error)
}
type PodClient interface {
Create(*v1.Pod) (*v1.Pod, error)
Get(namespace, name string, opts metav1.GetOptions) (*v1.Pod, error)
Update(*v1.Pod) (*v1.Pod, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
List(namespace string, opts metav1.ListOptions) (*PodList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Cache() PodClientCache
OnCreate(ctx context.Context, name string, sync PodChangeHandlerFunc)
OnChange(ctx context.Context, name string, sync PodChangeHandlerFunc)
OnRemove(ctx context.Context, name string, sync PodChangeHandlerFunc)
Enqueue(namespace, name string)
Generic() controller.GenericController
ObjectClient() *objectclient.ObjectClient
Interface() PodInterface
}
type podClientCache struct {
client *podClient2
}
type podClient2 struct {
iface PodInterface
controller PodController
}
func (n *podClient2) Interface() PodInterface {
return n.iface
}
func (n *podClient2) Generic() controller.GenericController {
return n.iface.Controller().Generic()
}
func (n *podClient2) ObjectClient() *objectclient.ObjectClient {
return n.Interface().ObjectClient()
}
func (n *podClient2) Enqueue(namespace, name string) {
n.iface.Controller().Enqueue(namespace, name)
}
func (n *podClient2) Create(obj *v1.Pod) (*v1.Pod, error) {
return n.iface.Create(obj)
}
func (n *podClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.Pod, error) {
return n.iface.GetNamespaced(namespace, name, opts)
}
func (n *podClient2) Update(obj *v1.Pod) (*v1.Pod, error) {
return n.iface.Update(obj)
}
func (n *podClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return n.iface.DeleteNamespaced(namespace, name, options)
}
func (n *podClient2) List(namespace string, opts metav1.ListOptions) (*PodList, error) {
return n.iface.List(opts)
}
func (n *podClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return n.iface.Watch(opts)
}
func (n *podClientCache) Get(namespace, name string) (*v1.Pod, error) {
return n.client.controller.Lister().Get(namespace, name)
}
func (n *podClientCache) List(namespace string, selector labels.Selector) ([]*v1.Pod, error) {
return n.client.controller.Lister().List(namespace, selector)
}
func (n *podClient2) Cache() PodClientCache {
n.loadController()
return &podClientCache{
client: n,
}
}
func (n *podClient2) OnCreate(ctx context.Context, name string, sync PodChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-create", &podLifecycleDelegate{create: sync})
}
func (n *podClient2) OnChange(ctx context.Context, name string, sync PodChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-change", &podLifecycleDelegate{update: sync})
}
func (n *podClient2) OnRemove(ctx context.Context, name string, sync PodChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name, &podLifecycleDelegate{remove: sync})
}
func (n *podClientCache) Index(name string, indexer PodIndexer) {
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
name: func(obj interface{}) ([]string, error) {
if v, ok := obj.(*v1.Pod); ok {
return indexer(v)
}
return nil, nil
},
})
if err != nil {
panic(err)
}
}
func (n *podClientCache) GetIndexed(name, key string) ([]*v1.Pod, error) {
var result []*v1.Pod
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
if v, ok := obj.(*v1.Pod); ok {
result = append(result, v)
}
}
return result, nil
}
func (n *podClient2) loadController() {
if n.controller == nil {
n.controller = n.iface.Controller()
}
}
type podLifecycleDelegate struct {
create PodChangeHandlerFunc
update PodChangeHandlerFunc
remove PodChangeHandlerFunc
}
func (n *podLifecycleDelegate) HasCreate() bool {
return n.create != nil
}
func (n *podLifecycleDelegate) Create(obj *v1.Pod) (runtime.Object, error) {
if n.create == nil {
return obj, nil
}
return n.create(obj)
}
func (n *podLifecycleDelegate) HasFinalize() bool {
return n.remove != nil
}
func (n *podLifecycleDelegate) Remove(obj *v1.Pod) (runtime.Object, error) {
if n.remove == nil {
return obj, nil
}
return n.remove(obj)
}
func (n *podLifecycleDelegate) Updated(obj *v1.Pod) (runtime.Object, error) {
if n.update == nil {
return obj, nil
}
return n.update(obj)
}

View File

@ -1,63 +0,0 @@
package v1
import (
"github.com/rancher/norman/lifecycle"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)
type PodLifecycle interface {
Create(obj *v1.Pod) (runtime.Object, error)
Remove(obj *v1.Pod) (runtime.Object, error)
Updated(obj *v1.Pod) (runtime.Object, error)
}
type podLifecycleAdapter struct {
lifecycle PodLifecycle
}
func (w *podLifecycleAdapter) HasCreate() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasCreate()
}
func (w *podLifecycleAdapter) HasFinalize() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasFinalize()
}
func (w *podLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*v1.Pod))
if o == nil {
return nil, err
}
return o, err
}
func (w *podLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*v1.Pod))
if o == nil {
return nil, err
}
return o, err
}
func (w *podLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*v1.Pod))
if o == nil {
return nil, err
}
return o, err
}
func NewPodLifecycleAdapter(name string, clusterScoped bool, client PodInterface, l PodLifecycle) PodHandlerFunc {
adapter := &podLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *v1.Pod) (runtime.Object, error) {
newObj, err := syncFn(key, obj)
if o, ok := newObj.(runtime.Object); ok {
return o, err
}
return nil, err
}
}

View File

@ -1,44 +0,0 @@
package v1
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
const (
GroupName = ""
Version = "v1"
)
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: Version}
// Kind takes an unqualified kind and returns a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
)
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
// TODO this gets cleaned up when the types are fixed
scheme.AddKnownTypes(SchemeGroupVersion,
&NodeList{},
&ServiceAccountList{},
&EndpointsList{},
&ServiceList{},
&PodList{},
&ConfigMapList{},
)
return nil
}

View File

@ -1,441 +0,0 @@
package v1
import (
"context"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
ServiceAccountGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "ServiceAccount",
}
ServiceAccountResource = metav1.APIResource{
Name: "serviceaccounts",
SingularName: "serviceaccount",
Namespaced: true,
Kind: ServiceAccountGroupVersionKind.Kind,
}
)
func NewServiceAccount(namespace, name string, obj v1.ServiceAccount) *v1.ServiceAccount {
obj.APIVersion, obj.Kind = ServiceAccountGroupVersionKind.ToAPIVersionAndKind()
obj.Name = name
obj.Namespace = namespace
return &obj
}
type ServiceAccountList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []v1.ServiceAccount
}
type ServiceAccountHandlerFunc func(key string, obj *v1.ServiceAccount) (runtime.Object, error)
type ServiceAccountChangeHandlerFunc func(obj *v1.ServiceAccount) (runtime.Object, error)
type ServiceAccountLister interface {
List(namespace string, selector labels.Selector) (ret []*v1.ServiceAccount, err error)
Get(namespace, name string) (*v1.ServiceAccount, error)
}
type ServiceAccountController interface {
Generic() controller.GenericController
Informer() cache.SharedIndexInformer
Lister() ServiceAccountLister
AddHandler(ctx context.Context, name string, handler ServiceAccountHandlerFunc)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler ServiceAccountHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type ServiceAccountInterface interface {
ObjectClient() *objectclient.ObjectClient
Create(*v1.ServiceAccount) (*v1.ServiceAccount, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.ServiceAccount, error)
Get(name string, opts metav1.GetOptions) (*v1.ServiceAccount, error)
Update(*v1.ServiceAccount) (*v1.ServiceAccount, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*ServiceAccountList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() ServiceAccountController
AddHandler(ctx context.Context, name string, sync ServiceAccountHandlerFunc)
AddLifecycle(ctx context.Context, name string, lifecycle ServiceAccountLifecycle)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ServiceAccountHandlerFunc)
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ServiceAccountLifecycle)
}
type serviceAccountLister struct {
controller *serviceAccountController
}
func (l *serviceAccountLister) List(namespace string, selector labels.Selector) (ret []*v1.ServiceAccount, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*v1.ServiceAccount))
})
return
}
func (l *serviceAccountLister) Get(namespace, name string) (*v1.ServiceAccount, error) {
var key string
if namespace != "" {
key = namespace + "/" + name
} else {
key = name
}
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: ServiceAccountGroupVersionKind.Group,
Resource: "serviceAccount",
}, key)
}
return obj.(*v1.ServiceAccount), nil
}
type serviceAccountController struct {
controller.GenericController
}
func (c *serviceAccountController) Generic() controller.GenericController {
return c.GenericController
}
func (c *serviceAccountController) Lister() ServiceAccountLister {
return &serviceAccountLister{
controller: c,
}
}
func (c *serviceAccountController) AddHandler(ctx context.Context, name string, handler ServiceAccountHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.ServiceAccount); ok {
return handler(key, v)
} else {
return nil, nil
}
})
}
func (c *serviceAccountController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler ServiceAccountHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.ServiceAccount); ok && controller.ObjectInCluster(cluster, obj) {
return handler(key, v)
} else {
return nil, nil
}
})
}
type serviceAccountFactory struct {
}
func (c serviceAccountFactory) Object() runtime.Object {
return &v1.ServiceAccount{}
}
func (c serviceAccountFactory) List() runtime.Object {
return &ServiceAccountList{}
}
func (s *serviceAccountClient) Controller() ServiceAccountController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.serviceAccountControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(ServiceAccountGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &serviceAccountController{
GenericController: genericController,
}
s.client.serviceAccountControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type serviceAccountClient struct {
client *Client
ns string
objectClient *objectclient.ObjectClient
controller ServiceAccountController
}
func (s *serviceAccountClient) ObjectClient() *objectclient.ObjectClient {
return s.objectClient
}
func (s *serviceAccountClient) Create(o *v1.ServiceAccount) (*v1.ServiceAccount, error) {
obj, err := s.objectClient.Create(o)
return obj.(*v1.ServiceAccount), err
}
func (s *serviceAccountClient) Get(name string, opts metav1.GetOptions) (*v1.ServiceAccount, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*v1.ServiceAccount), err
}
func (s *serviceAccountClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.ServiceAccount, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*v1.ServiceAccount), err
}
func (s *serviceAccountClient) Update(o *v1.ServiceAccount) (*v1.ServiceAccount, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*v1.ServiceAccount), err
}
func (s *serviceAccountClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *serviceAccountClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *serviceAccountClient) List(opts metav1.ListOptions) (*ServiceAccountList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*ServiceAccountList), err
}
func (s *serviceAccountClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *serviceAccountClient) Patch(o *v1.ServiceAccount, patchType types.PatchType, data []byte, subresources ...string) (*v1.ServiceAccount, error) {
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
return obj.(*v1.ServiceAccount), err
}
func (s *serviceAccountClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *serviceAccountClient) AddHandler(ctx context.Context, name string, sync ServiceAccountHandlerFunc) {
s.Controller().AddHandler(ctx, name, sync)
}
func (s *serviceAccountClient) AddLifecycle(ctx context.Context, name string, lifecycle ServiceAccountLifecycle) {
sync := NewServiceAccountLifecycleAdapter(name, false, s, lifecycle)
s.Controller().AddHandler(ctx, name, sync)
}
func (s *serviceAccountClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ServiceAccountHandlerFunc) {
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
func (s *serviceAccountClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ServiceAccountLifecycle) {
sync := NewServiceAccountLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
type ServiceAccountIndexer func(obj *v1.ServiceAccount) ([]string, error)
type ServiceAccountClientCache interface {
Get(namespace, name string) (*v1.ServiceAccount, error)
List(namespace string, selector labels.Selector) ([]*v1.ServiceAccount, error)
Index(name string, indexer ServiceAccountIndexer)
GetIndexed(name, key string) ([]*v1.ServiceAccount, error)
}
type ServiceAccountClient interface {
Create(*v1.ServiceAccount) (*v1.ServiceAccount, error)
Get(namespace, name string, opts metav1.GetOptions) (*v1.ServiceAccount, error)
Update(*v1.ServiceAccount) (*v1.ServiceAccount, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
List(namespace string, opts metav1.ListOptions) (*ServiceAccountList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Cache() ServiceAccountClientCache
OnCreate(ctx context.Context, name string, sync ServiceAccountChangeHandlerFunc)
OnChange(ctx context.Context, name string, sync ServiceAccountChangeHandlerFunc)
OnRemove(ctx context.Context, name string, sync ServiceAccountChangeHandlerFunc)
Enqueue(namespace, name string)
Generic() controller.GenericController
ObjectClient() *objectclient.ObjectClient
Interface() ServiceAccountInterface
}
type serviceAccountClientCache struct {
client *serviceAccountClient2
}
type serviceAccountClient2 struct {
iface ServiceAccountInterface
controller ServiceAccountController
}
func (n *serviceAccountClient2) Interface() ServiceAccountInterface {
return n.iface
}
func (n *serviceAccountClient2) Generic() controller.GenericController {
return n.iface.Controller().Generic()
}
func (n *serviceAccountClient2) ObjectClient() *objectclient.ObjectClient {
return n.Interface().ObjectClient()
}
func (n *serviceAccountClient2) Enqueue(namespace, name string) {
n.iface.Controller().Enqueue(namespace, name)
}
func (n *serviceAccountClient2) Create(obj *v1.ServiceAccount) (*v1.ServiceAccount, error) {
return n.iface.Create(obj)
}
func (n *serviceAccountClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.ServiceAccount, error) {
return n.iface.GetNamespaced(namespace, name, opts)
}
func (n *serviceAccountClient2) Update(obj *v1.ServiceAccount) (*v1.ServiceAccount, error) {
return n.iface.Update(obj)
}
func (n *serviceAccountClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return n.iface.DeleteNamespaced(namespace, name, options)
}
func (n *serviceAccountClient2) List(namespace string, opts metav1.ListOptions) (*ServiceAccountList, error) {
return n.iface.List(opts)
}
func (n *serviceAccountClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return n.iface.Watch(opts)
}
func (n *serviceAccountClientCache) Get(namespace, name string) (*v1.ServiceAccount, error) {
return n.client.controller.Lister().Get(namespace, name)
}
func (n *serviceAccountClientCache) List(namespace string, selector labels.Selector) ([]*v1.ServiceAccount, error) {
return n.client.controller.Lister().List(namespace, selector)
}
func (n *serviceAccountClient2) Cache() ServiceAccountClientCache {
n.loadController()
return &serviceAccountClientCache{
client: n,
}
}
func (n *serviceAccountClient2) OnCreate(ctx context.Context, name string, sync ServiceAccountChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-create", &serviceAccountLifecycleDelegate{create: sync})
}
func (n *serviceAccountClient2) OnChange(ctx context.Context, name string, sync ServiceAccountChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-change", &serviceAccountLifecycleDelegate{update: sync})
}
func (n *serviceAccountClient2) OnRemove(ctx context.Context, name string, sync ServiceAccountChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name, &serviceAccountLifecycleDelegate{remove: sync})
}
func (n *serviceAccountClientCache) Index(name string, indexer ServiceAccountIndexer) {
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
name: func(obj interface{}) ([]string, error) {
if v, ok := obj.(*v1.ServiceAccount); ok {
return indexer(v)
}
return nil, nil
},
})
if err != nil {
panic(err)
}
}
func (n *serviceAccountClientCache) GetIndexed(name, key string) ([]*v1.ServiceAccount, error) {
var result []*v1.ServiceAccount
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
if v, ok := obj.(*v1.ServiceAccount); ok {
result = append(result, v)
}
}
return result, nil
}
func (n *serviceAccountClient2) loadController() {
if n.controller == nil {
n.controller = n.iface.Controller()
}
}
type serviceAccountLifecycleDelegate struct {
create ServiceAccountChangeHandlerFunc
update ServiceAccountChangeHandlerFunc
remove ServiceAccountChangeHandlerFunc
}
func (n *serviceAccountLifecycleDelegate) HasCreate() bool {
return n.create != nil
}
func (n *serviceAccountLifecycleDelegate) Create(obj *v1.ServiceAccount) (runtime.Object, error) {
if n.create == nil {
return obj, nil
}
return n.create(obj)
}
func (n *serviceAccountLifecycleDelegate) HasFinalize() bool {
return n.remove != nil
}
func (n *serviceAccountLifecycleDelegate) Remove(obj *v1.ServiceAccount) (runtime.Object, error) {
if n.remove == nil {
return obj, nil
}
return n.remove(obj)
}
func (n *serviceAccountLifecycleDelegate) Updated(obj *v1.ServiceAccount) (runtime.Object, error) {
if n.update == nil {
return obj, nil
}
return n.update(obj)
}

View File

@ -1,63 +0,0 @@
package v1
import (
"github.com/rancher/norman/lifecycle"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)
type ServiceAccountLifecycle interface {
Create(obj *v1.ServiceAccount) (runtime.Object, error)
Remove(obj *v1.ServiceAccount) (runtime.Object, error)
Updated(obj *v1.ServiceAccount) (runtime.Object, error)
}
type serviceAccountLifecycleAdapter struct {
lifecycle ServiceAccountLifecycle
}
func (w *serviceAccountLifecycleAdapter) HasCreate() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasCreate()
}
func (w *serviceAccountLifecycleAdapter) HasFinalize() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasFinalize()
}
func (w *serviceAccountLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*v1.ServiceAccount))
if o == nil {
return nil, err
}
return o, err
}
func (w *serviceAccountLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*v1.ServiceAccount))
if o == nil {
return nil, err
}
return o, err
}
func (w *serviceAccountLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*v1.ServiceAccount))
if o == nil {
return nil, err
}
return o, err
}
func NewServiceAccountLifecycleAdapter(name string, clusterScoped bool, client ServiceAccountInterface, l ServiceAccountLifecycle) ServiceAccountHandlerFunc {
adapter := &serviceAccountLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *v1.ServiceAccount) (runtime.Object, error) {
newObj, err := syncFn(key, obj)
if o, ok := newObj.(runtime.Object); ok {
return o, err
}
return nil, err
}
}

View File

@ -1,441 +0,0 @@
package v1
import (
"context"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
ServiceGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "Service",
}
ServiceResource = metav1.APIResource{
Name: "services",
SingularName: "service",
Namespaced: true,
Kind: ServiceGroupVersionKind.Kind,
}
)
func NewService(namespace, name string, obj v1.Service) *v1.Service {
obj.APIVersion, obj.Kind = ServiceGroupVersionKind.ToAPIVersionAndKind()
obj.Name = name
obj.Namespace = namespace
return &obj
}
type ServiceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []v1.Service
}
type ServiceHandlerFunc func(key string, obj *v1.Service) (runtime.Object, error)
type ServiceChangeHandlerFunc func(obj *v1.Service) (runtime.Object, error)
type ServiceLister interface {
List(namespace string, selector labels.Selector) (ret []*v1.Service, err error)
Get(namespace, name string) (*v1.Service, error)
}
type ServiceController interface {
Generic() controller.GenericController
Informer() cache.SharedIndexInformer
Lister() ServiceLister
AddHandler(ctx context.Context, name string, handler ServiceHandlerFunc)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler ServiceHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type ServiceInterface interface {
ObjectClient() *objectclient.ObjectClient
Create(*v1.Service) (*v1.Service, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.Service, error)
Get(name string, opts metav1.GetOptions) (*v1.Service, error)
Update(*v1.Service) (*v1.Service, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*ServiceList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() ServiceController
AddHandler(ctx context.Context, name string, sync ServiceHandlerFunc)
AddLifecycle(ctx context.Context, name string, lifecycle ServiceLifecycle)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ServiceHandlerFunc)
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ServiceLifecycle)
}
type serviceLister struct {
controller *serviceController
}
func (l *serviceLister) List(namespace string, selector labels.Selector) (ret []*v1.Service, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*v1.Service))
})
return
}
func (l *serviceLister) Get(namespace, name string) (*v1.Service, error) {
var key string
if namespace != "" {
key = namespace + "/" + name
} else {
key = name
}
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: ServiceGroupVersionKind.Group,
Resource: "service",
}, key)
}
return obj.(*v1.Service), nil
}
type serviceController struct {
controller.GenericController
}
func (c *serviceController) Generic() controller.GenericController {
return c.GenericController
}
func (c *serviceController) Lister() ServiceLister {
return &serviceLister{
controller: c,
}
}
func (c *serviceController) AddHandler(ctx context.Context, name string, handler ServiceHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.Service); ok {
return handler(key, v)
} else {
return nil, nil
}
})
}
func (c *serviceController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler ServiceHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v1.Service); ok && controller.ObjectInCluster(cluster, obj) {
return handler(key, v)
} else {
return nil, nil
}
})
}
type serviceFactory struct {
}
func (c serviceFactory) Object() runtime.Object {
return &v1.Service{}
}
func (c serviceFactory) List() runtime.Object {
return &ServiceList{}
}
func (s *serviceClient) Controller() ServiceController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.serviceControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(ServiceGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &serviceController{
GenericController: genericController,
}
s.client.serviceControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type serviceClient struct {
client *Client
ns string
objectClient *objectclient.ObjectClient
controller ServiceController
}
func (s *serviceClient) ObjectClient() *objectclient.ObjectClient {
return s.objectClient
}
func (s *serviceClient) Create(o *v1.Service) (*v1.Service, error) {
obj, err := s.objectClient.Create(o)
return obj.(*v1.Service), err
}
func (s *serviceClient) Get(name string, opts metav1.GetOptions) (*v1.Service, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*v1.Service), err
}
func (s *serviceClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.Service, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*v1.Service), err
}
func (s *serviceClient) Update(o *v1.Service) (*v1.Service, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*v1.Service), err
}
func (s *serviceClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *serviceClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *serviceClient) List(opts metav1.ListOptions) (*ServiceList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*ServiceList), err
}
func (s *serviceClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *serviceClient) Patch(o *v1.Service, patchType types.PatchType, data []byte, subresources ...string) (*v1.Service, error) {
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
return obj.(*v1.Service), err
}
func (s *serviceClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *serviceClient) AddHandler(ctx context.Context, name string, sync ServiceHandlerFunc) {
s.Controller().AddHandler(ctx, name, sync)
}
func (s *serviceClient) AddLifecycle(ctx context.Context, name string, lifecycle ServiceLifecycle) {
sync := NewServiceLifecycleAdapter(name, false, s, lifecycle)
s.Controller().AddHandler(ctx, name, sync)
}
func (s *serviceClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ServiceHandlerFunc) {
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
func (s *serviceClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ServiceLifecycle) {
sync := NewServiceLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
type ServiceIndexer func(obj *v1.Service) ([]string, error)
type ServiceClientCache interface {
Get(namespace, name string) (*v1.Service, error)
List(namespace string, selector labels.Selector) ([]*v1.Service, error)
Index(name string, indexer ServiceIndexer)
GetIndexed(name, key string) ([]*v1.Service, error)
}
type ServiceClient interface {
Create(*v1.Service) (*v1.Service, error)
Get(namespace, name string, opts metav1.GetOptions) (*v1.Service, error)
Update(*v1.Service) (*v1.Service, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
List(namespace string, opts metav1.ListOptions) (*ServiceList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Cache() ServiceClientCache
OnCreate(ctx context.Context, name string, sync ServiceChangeHandlerFunc)
OnChange(ctx context.Context, name string, sync ServiceChangeHandlerFunc)
OnRemove(ctx context.Context, name string, sync ServiceChangeHandlerFunc)
Enqueue(namespace, name string)
Generic() controller.GenericController
ObjectClient() *objectclient.ObjectClient
Interface() ServiceInterface
}
type serviceClientCache struct {
client *serviceClient2
}
type serviceClient2 struct {
iface ServiceInterface
controller ServiceController
}
func (n *serviceClient2) Interface() ServiceInterface {
return n.iface
}
func (n *serviceClient2) Generic() controller.GenericController {
return n.iface.Controller().Generic()
}
func (n *serviceClient2) ObjectClient() *objectclient.ObjectClient {
return n.Interface().ObjectClient()
}
func (n *serviceClient2) Enqueue(namespace, name string) {
n.iface.Controller().Enqueue(namespace, name)
}
func (n *serviceClient2) Create(obj *v1.Service) (*v1.Service, error) {
return n.iface.Create(obj)
}
func (n *serviceClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.Service, error) {
return n.iface.GetNamespaced(namespace, name, opts)
}
func (n *serviceClient2) Update(obj *v1.Service) (*v1.Service, error) {
return n.iface.Update(obj)
}
func (n *serviceClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return n.iface.DeleteNamespaced(namespace, name, options)
}
func (n *serviceClient2) List(namespace string, opts metav1.ListOptions) (*ServiceList, error) {
return n.iface.List(opts)
}
func (n *serviceClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return n.iface.Watch(opts)
}
func (n *serviceClientCache) Get(namespace, name string) (*v1.Service, error) {
return n.client.controller.Lister().Get(namespace, name)
}
func (n *serviceClientCache) List(namespace string, selector labels.Selector) ([]*v1.Service, error) {
return n.client.controller.Lister().List(namespace, selector)
}
func (n *serviceClient2) Cache() ServiceClientCache {
n.loadController()
return &serviceClientCache{
client: n,
}
}
func (n *serviceClient2) OnCreate(ctx context.Context, name string, sync ServiceChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-create", &serviceLifecycleDelegate{create: sync})
}
func (n *serviceClient2) OnChange(ctx context.Context, name string, sync ServiceChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-change", &serviceLifecycleDelegate{update: sync})
}
func (n *serviceClient2) OnRemove(ctx context.Context, name string, sync ServiceChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name, &serviceLifecycleDelegate{remove: sync})
}
func (n *serviceClientCache) Index(name string, indexer ServiceIndexer) {
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
name: func(obj interface{}) ([]string, error) {
if v, ok := obj.(*v1.Service); ok {
return indexer(v)
}
return nil, nil
},
})
if err != nil {
panic(err)
}
}
func (n *serviceClientCache) GetIndexed(name, key string) ([]*v1.Service, error) {
var result []*v1.Service
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
if v, ok := obj.(*v1.Service); ok {
result = append(result, v)
}
}
return result, nil
}
func (n *serviceClient2) loadController() {
if n.controller == nil {
n.controller = n.iface.Controller()
}
}
type serviceLifecycleDelegate struct {
create ServiceChangeHandlerFunc
update ServiceChangeHandlerFunc
remove ServiceChangeHandlerFunc
}
func (n *serviceLifecycleDelegate) HasCreate() bool {
return n.create != nil
}
func (n *serviceLifecycleDelegate) Create(obj *v1.Service) (runtime.Object, error) {
if n.create == nil {
return obj, nil
}
return n.create(obj)
}
func (n *serviceLifecycleDelegate) HasFinalize() bool {
return n.remove != nil
}
func (n *serviceLifecycleDelegate) Remove(obj *v1.Service) (runtime.Object, error) {
if n.remove == nil {
return obj, nil
}
return n.remove(obj)
}
func (n *serviceLifecycleDelegate) Updated(obj *v1.Service) (runtime.Object, error) {
if n.update == nil {
return obj, nil
}
return n.update(obj)
}

View File

@ -1,63 +0,0 @@
package v1
import (
"github.com/rancher/norman/lifecycle"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)
type ServiceLifecycle interface {
Create(obj *v1.Service) (runtime.Object, error)
Remove(obj *v1.Service) (runtime.Object, error)
Updated(obj *v1.Service) (runtime.Object, error)
}
type serviceLifecycleAdapter struct {
lifecycle ServiceLifecycle
}
func (w *serviceLifecycleAdapter) HasCreate() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasCreate()
}
func (w *serviceLifecycleAdapter) HasFinalize() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasFinalize()
}
func (w *serviceLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*v1.Service))
if o == nil {
return nil, err
}
return o, err
}
func (w *serviceLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*v1.Service))
if o == nil {
return nil, err
}
return o, err
}
func (w *serviceLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*v1.Service))
if o == nil {
return nil, err
}
return o, err
}
func NewServiceLifecycleAdapter(name string, clusterScoped bool, client ServiceInterface, l ServiceLifecycle) ServiceHandlerFunc {
adapter := &serviceLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *v1.Service) (runtime.Object, error) {
newObj, err := syncFn(key, obj)
if o, ok := newObj.(runtime.Object); ok {
return o, err
}
return nil, err
}
}

View File

@ -1,19 +0,0 @@
package v1
import (
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/factory"
)
var (
APIVersion = types.APIVersion{
Version: "v1",
Group: "k3s.cattle.io",
Path: "/v1-k3s",
}
Schemas = factory.Schemas(&APIVersion).
MustImport(&APIVersion, Addon{}).
MustImport(&APIVersion, HelmChart{}).
MustImport(&APIVersion, ListenerConfig{})
)

View File

@ -1,440 +0,0 @@
package v1
import (
"context"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
AddonGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "Addon",
}
AddonResource = metav1.APIResource{
Name: "addons",
SingularName: "addon",
Namespaced: true,
Kind: AddonGroupVersionKind.Kind,
}
)
func NewAddon(namespace, name string, obj Addon) *Addon {
obj.APIVersion, obj.Kind = AddonGroupVersionKind.ToAPIVersionAndKind()
obj.Name = name
obj.Namespace = namespace
return &obj
}
type AddonList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Addon
}
type AddonHandlerFunc func(key string, obj *Addon) (runtime.Object, error)
type AddonChangeHandlerFunc func(obj *Addon) (runtime.Object, error)
type AddonLister interface {
List(namespace string, selector labels.Selector) (ret []*Addon, err error)
Get(namespace, name string) (*Addon, error)
}
type AddonController interface {
Generic() controller.GenericController
Informer() cache.SharedIndexInformer
Lister() AddonLister
AddHandler(ctx context.Context, name string, handler AddonHandlerFunc)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler AddonHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type AddonInterface interface {
ObjectClient() *objectclient.ObjectClient
Create(*Addon) (*Addon, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*Addon, error)
Get(name string, opts metav1.GetOptions) (*Addon, error)
Update(*Addon) (*Addon, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*AddonList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() AddonController
AddHandler(ctx context.Context, name string, sync AddonHandlerFunc)
AddLifecycle(ctx context.Context, name string, lifecycle AddonLifecycle)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync AddonHandlerFunc)
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle AddonLifecycle)
}
type addonLister struct {
controller *addonController
}
func (l *addonLister) List(namespace string, selector labels.Selector) (ret []*Addon, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*Addon))
})
return
}
func (l *addonLister) Get(namespace, name string) (*Addon, error) {
var key string
if namespace != "" {
key = namespace + "/" + name
} else {
key = name
}
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: AddonGroupVersionKind.Group,
Resource: "addon",
}, key)
}
return obj.(*Addon), nil
}
type addonController struct {
controller.GenericController
}
func (c *addonController) Generic() controller.GenericController {
return c.GenericController
}
func (c *addonController) Lister() AddonLister {
return &addonLister{
controller: c,
}
}
func (c *addonController) AddHandler(ctx context.Context, name string, handler AddonHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*Addon); ok {
return handler(key, v)
} else {
return nil, nil
}
})
}
func (c *addonController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler AddonHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*Addon); ok && controller.ObjectInCluster(cluster, obj) {
return handler(key, v)
} else {
return nil, nil
}
})
}
type addonFactory struct {
}
func (c addonFactory) Object() runtime.Object {
return &Addon{}
}
func (c addonFactory) List() runtime.Object {
return &AddonList{}
}
func (s *addonClient) Controller() AddonController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.addonControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(AddonGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &addonController{
GenericController: genericController,
}
s.client.addonControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type addonClient struct {
client *Client
ns string
objectClient *objectclient.ObjectClient
controller AddonController
}
func (s *addonClient) ObjectClient() *objectclient.ObjectClient {
return s.objectClient
}
func (s *addonClient) Create(o *Addon) (*Addon, error) {
obj, err := s.objectClient.Create(o)
return obj.(*Addon), err
}
func (s *addonClient) Get(name string, opts metav1.GetOptions) (*Addon, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*Addon), err
}
func (s *addonClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*Addon, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*Addon), err
}
func (s *addonClient) Update(o *Addon) (*Addon, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*Addon), err
}
func (s *addonClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *addonClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *addonClient) List(opts metav1.ListOptions) (*AddonList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*AddonList), err
}
func (s *addonClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *addonClient) Patch(o *Addon, patchType types.PatchType, data []byte, subresources ...string) (*Addon, error) {
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
return obj.(*Addon), err
}
func (s *addonClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *addonClient) AddHandler(ctx context.Context, name string, sync AddonHandlerFunc) {
s.Controller().AddHandler(ctx, name, sync)
}
func (s *addonClient) AddLifecycle(ctx context.Context, name string, lifecycle AddonLifecycle) {
sync := NewAddonLifecycleAdapter(name, false, s, lifecycle)
s.Controller().AddHandler(ctx, name, sync)
}
func (s *addonClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync AddonHandlerFunc) {
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
func (s *addonClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle AddonLifecycle) {
sync := NewAddonLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
type AddonIndexer func(obj *Addon) ([]string, error)
type AddonClientCache interface {
Get(namespace, name string) (*Addon, error)
List(namespace string, selector labels.Selector) ([]*Addon, error)
Index(name string, indexer AddonIndexer)
GetIndexed(name, key string) ([]*Addon, error)
}
type AddonClient interface {
Create(*Addon) (*Addon, error)
Get(namespace, name string, opts metav1.GetOptions) (*Addon, error)
Update(*Addon) (*Addon, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
List(namespace string, opts metav1.ListOptions) (*AddonList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Cache() AddonClientCache
OnCreate(ctx context.Context, name string, sync AddonChangeHandlerFunc)
OnChange(ctx context.Context, name string, sync AddonChangeHandlerFunc)
OnRemove(ctx context.Context, name string, sync AddonChangeHandlerFunc)
Enqueue(namespace, name string)
Generic() controller.GenericController
ObjectClient() *objectclient.ObjectClient
Interface() AddonInterface
}
type addonClientCache struct {
client *addonClient2
}
type addonClient2 struct {
iface AddonInterface
controller AddonController
}
func (n *addonClient2) Interface() AddonInterface {
return n.iface
}
func (n *addonClient2) Generic() controller.GenericController {
return n.iface.Controller().Generic()
}
func (n *addonClient2) ObjectClient() *objectclient.ObjectClient {
return n.Interface().ObjectClient()
}
func (n *addonClient2) Enqueue(namespace, name string) {
n.iface.Controller().Enqueue(namespace, name)
}
func (n *addonClient2) Create(obj *Addon) (*Addon, error) {
return n.iface.Create(obj)
}
func (n *addonClient2) Get(namespace, name string, opts metav1.GetOptions) (*Addon, error) {
return n.iface.GetNamespaced(namespace, name, opts)
}
func (n *addonClient2) Update(obj *Addon) (*Addon, error) {
return n.iface.Update(obj)
}
func (n *addonClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return n.iface.DeleteNamespaced(namespace, name, options)
}
func (n *addonClient2) List(namespace string, opts metav1.ListOptions) (*AddonList, error) {
return n.iface.List(opts)
}
func (n *addonClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return n.iface.Watch(opts)
}
func (n *addonClientCache) Get(namespace, name string) (*Addon, error) {
return n.client.controller.Lister().Get(namespace, name)
}
func (n *addonClientCache) List(namespace string, selector labels.Selector) ([]*Addon, error) {
return n.client.controller.Lister().List(namespace, selector)
}
func (n *addonClient2) Cache() AddonClientCache {
n.loadController()
return &addonClientCache{
client: n,
}
}
func (n *addonClient2) OnCreate(ctx context.Context, name string, sync AddonChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-create", &addonLifecycleDelegate{create: sync})
}
func (n *addonClient2) OnChange(ctx context.Context, name string, sync AddonChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-change", &addonLifecycleDelegate{update: sync})
}
func (n *addonClient2) OnRemove(ctx context.Context, name string, sync AddonChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name, &addonLifecycleDelegate{remove: sync})
}
func (n *addonClientCache) Index(name string, indexer AddonIndexer) {
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
name: func(obj interface{}) ([]string, error) {
if v, ok := obj.(*Addon); ok {
return indexer(v)
}
return nil, nil
},
})
if err != nil {
panic(err)
}
}
func (n *addonClientCache) GetIndexed(name, key string) ([]*Addon, error) {
var result []*Addon
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
if v, ok := obj.(*Addon); ok {
result = append(result, v)
}
}
return result, nil
}
func (n *addonClient2) loadController() {
if n.controller == nil {
n.controller = n.iface.Controller()
}
}
type addonLifecycleDelegate struct {
create AddonChangeHandlerFunc
update AddonChangeHandlerFunc
remove AddonChangeHandlerFunc
}
func (n *addonLifecycleDelegate) HasCreate() bool {
return n.create != nil
}
func (n *addonLifecycleDelegate) Create(obj *Addon) (runtime.Object, error) {
if n.create == nil {
return obj, nil
}
return n.create(obj)
}
func (n *addonLifecycleDelegate) HasFinalize() bool {
return n.remove != nil
}
func (n *addonLifecycleDelegate) Remove(obj *Addon) (runtime.Object, error) {
if n.remove == nil {
return obj, nil
}
return n.remove(obj)
}
func (n *addonLifecycleDelegate) Updated(obj *Addon) (runtime.Object, error) {
if n.update == nil {
return obj, nil
}
return n.update(obj)
}

View File

@ -1,62 +0,0 @@
package v1
import (
"github.com/rancher/norman/lifecycle"
"k8s.io/apimachinery/pkg/runtime"
)
type AddonLifecycle interface {
Create(obj *Addon) (runtime.Object, error)
Remove(obj *Addon) (runtime.Object, error)
Updated(obj *Addon) (runtime.Object, error)
}
type addonLifecycleAdapter struct {
lifecycle AddonLifecycle
}
func (w *addonLifecycleAdapter) HasCreate() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasCreate()
}
func (w *addonLifecycleAdapter) HasFinalize() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasFinalize()
}
func (w *addonLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*Addon))
if o == nil {
return nil, err
}
return o, err
}
func (w *addonLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*Addon))
if o == nil {
return nil, err
}
return o, err
}
func (w *addonLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*Addon))
if o == nil {
return nil, err
}
return o, err
}
func NewAddonLifecycleAdapter(name string, clusterScoped bool, client AddonInterface, l AddonLifecycle) AddonHandlerFunc {
adapter := &addonLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *Addon) (runtime.Object, error) {
newObj, err := syncFn(key, obj)
if o, ok := newObj.(runtime.Object); ok {
return o, err
}
return nil, err
}
}

View File

@ -1,440 +0,0 @@
package v1
import (
"context"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
HelmChartGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "HelmChart",
}
HelmChartResource = metav1.APIResource{
Name: "helmcharts",
SingularName: "helmchart",
Namespaced: true,
Kind: HelmChartGroupVersionKind.Kind,
}
)
func NewHelmChart(namespace, name string, obj HelmChart) *HelmChart {
obj.APIVersion, obj.Kind = HelmChartGroupVersionKind.ToAPIVersionAndKind()
obj.Name = name
obj.Namespace = namespace
return &obj
}
type HelmChartList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []HelmChart
}
type HelmChartHandlerFunc func(key string, obj *HelmChart) (runtime.Object, error)
type HelmChartChangeHandlerFunc func(obj *HelmChart) (runtime.Object, error)
type HelmChartLister interface {
List(namespace string, selector labels.Selector) (ret []*HelmChart, err error)
Get(namespace, name string) (*HelmChart, error)
}
type HelmChartController interface {
Generic() controller.GenericController
Informer() cache.SharedIndexInformer
Lister() HelmChartLister
AddHandler(ctx context.Context, name string, handler HelmChartHandlerFunc)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler HelmChartHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type HelmChartInterface interface {
ObjectClient() *objectclient.ObjectClient
Create(*HelmChart) (*HelmChart, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*HelmChart, error)
Get(name string, opts metav1.GetOptions) (*HelmChart, error)
Update(*HelmChart) (*HelmChart, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*HelmChartList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() HelmChartController
AddHandler(ctx context.Context, name string, sync HelmChartHandlerFunc)
AddLifecycle(ctx context.Context, name string, lifecycle HelmChartLifecycle)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync HelmChartHandlerFunc)
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle HelmChartLifecycle)
}
type helmChartLister struct {
controller *helmChartController
}
func (l *helmChartLister) List(namespace string, selector labels.Selector) (ret []*HelmChart, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*HelmChart))
})
return
}
func (l *helmChartLister) Get(namespace, name string) (*HelmChart, error) {
var key string
if namespace != "" {
key = namespace + "/" + name
} else {
key = name
}
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: HelmChartGroupVersionKind.Group,
Resource: "helmChart",
}, key)
}
return obj.(*HelmChart), nil
}
type helmChartController struct {
controller.GenericController
}
func (c *helmChartController) Generic() controller.GenericController {
return c.GenericController
}
func (c *helmChartController) Lister() HelmChartLister {
return &helmChartLister{
controller: c,
}
}
func (c *helmChartController) AddHandler(ctx context.Context, name string, handler HelmChartHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*HelmChart); ok {
return handler(key, v)
} else {
return nil, nil
}
})
}
func (c *helmChartController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler HelmChartHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*HelmChart); ok && controller.ObjectInCluster(cluster, obj) {
return handler(key, v)
} else {
return nil, nil
}
})
}
type helmChartFactory struct {
}
func (c helmChartFactory) Object() runtime.Object {
return &HelmChart{}
}
func (c helmChartFactory) List() runtime.Object {
return &HelmChartList{}
}
func (s *helmChartClient) Controller() HelmChartController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.helmChartControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(HelmChartGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &helmChartController{
GenericController: genericController,
}
s.client.helmChartControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type helmChartClient struct {
client *Client
ns string
objectClient *objectclient.ObjectClient
controller HelmChartController
}
func (s *helmChartClient) ObjectClient() *objectclient.ObjectClient {
return s.objectClient
}
func (s *helmChartClient) Create(o *HelmChart) (*HelmChart, error) {
obj, err := s.objectClient.Create(o)
return obj.(*HelmChart), err
}
func (s *helmChartClient) Get(name string, opts metav1.GetOptions) (*HelmChart, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*HelmChart), err
}
func (s *helmChartClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*HelmChart, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*HelmChart), err
}
func (s *helmChartClient) Update(o *HelmChart) (*HelmChart, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*HelmChart), err
}
func (s *helmChartClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *helmChartClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *helmChartClient) List(opts metav1.ListOptions) (*HelmChartList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*HelmChartList), err
}
func (s *helmChartClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *helmChartClient) Patch(o *HelmChart, patchType types.PatchType, data []byte, subresources ...string) (*HelmChart, error) {
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
return obj.(*HelmChart), err
}
func (s *helmChartClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *helmChartClient) AddHandler(ctx context.Context, name string, sync HelmChartHandlerFunc) {
s.Controller().AddHandler(ctx, name, sync)
}
func (s *helmChartClient) AddLifecycle(ctx context.Context, name string, lifecycle HelmChartLifecycle) {
sync := NewHelmChartLifecycleAdapter(name, false, s, lifecycle)
s.Controller().AddHandler(ctx, name, sync)
}
func (s *helmChartClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync HelmChartHandlerFunc) {
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
func (s *helmChartClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle HelmChartLifecycle) {
sync := NewHelmChartLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
type HelmChartIndexer func(obj *HelmChart) ([]string, error)
type HelmChartClientCache interface {
Get(namespace, name string) (*HelmChart, error)
List(namespace string, selector labels.Selector) ([]*HelmChart, error)
Index(name string, indexer HelmChartIndexer)
GetIndexed(name, key string) ([]*HelmChart, error)
}
type HelmChartClient interface {
Create(*HelmChart) (*HelmChart, error)
Get(namespace, name string, opts metav1.GetOptions) (*HelmChart, error)
Update(*HelmChart) (*HelmChart, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
List(namespace string, opts metav1.ListOptions) (*HelmChartList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Cache() HelmChartClientCache
OnCreate(ctx context.Context, name string, sync HelmChartChangeHandlerFunc)
OnChange(ctx context.Context, name string, sync HelmChartChangeHandlerFunc)
OnRemove(ctx context.Context, name string, sync HelmChartChangeHandlerFunc)
Enqueue(namespace, name string)
Generic() controller.GenericController
ObjectClient() *objectclient.ObjectClient
Interface() HelmChartInterface
}
type helmChartClientCache struct {
client *helmChartClient2
}
type helmChartClient2 struct {
iface HelmChartInterface
controller HelmChartController
}
func (n *helmChartClient2) Interface() HelmChartInterface {
return n.iface
}
func (n *helmChartClient2) Generic() controller.GenericController {
return n.iface.Controller().Generic()
}
func (n *helmChartClient2) ObjectClient() *objectclient.ObjectClient {
return n.Interface().ObjectClient()
}
func (n *helmChartClient2) Enqueue(namespace, name string) {
n.iface.Controller().Enqueue(namespace, name)
}
func (n *helmChartClient2) Create(obj *HelmChart) (*HelmChart, error) {
return n.iface.Create(obj)
}
func (n *helmChartClient2) Get(namespace, name string, opts metav1.GetOptions) (*HelmChart, error) {
return n.iface.GetNamespaced(namespace, name, opts)
}
func (n *helmChartClient2) Update(obj *HelmChart) (*HelmChart, error) {
return n.iface.Update(obj)
}
func (n *helmChartClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return n.iface.DeleteNamespaced(namespace, name, options)
}
func (n *helmChartClient2) List(namespace string, opts metav1.ListOptions) (*HelmChartList, error) {
return n.iface.List(opts)
}
func (n *helmChartClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return n.iface.Watch(opts)
}
func (n *helmChartClientCache) Get(namespace, name string) (*HelmChart, error) {
return n.client.controller.Lister().Get(namespace, name)
}
func (n *helmChartClientCache) List(namespace string, selector labels.Selector) ([]*HelmChart, error) {
return n.client.controller.Lister().List(namespace, selector)
}
func (n *helmChartClient2) Cache() HelmChartClientCache {
n.loadController()
return &helmChartClientCache{
client: n,
}
}
func (n *helmChartClient2) OnCreate(ctx context.Context, name string, sync HelmChartChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-create", &helmChartLifecycleDelegate{create: sync})
}
func (n *helmChartClient2) OnChange(ctx context.Context, name string, sync HelmChartChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-change", &helmChartLifecycleDelegate{update: sync})
}
func (n *helmChartClient2) OnRemove(ctx context.Context, name string, sync HelmChartChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name, &helmChartLifecycleDelegate{remove: sync})
}
func (n *helmChartClientCache) Index(name string, indexer HelmChartIndexer) {
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
name: func(obj interface{}) ([]string, error) {
if v, ok := obj.(*HelmChart); ok {
return indexer(v)
}
return nil, nil
},
})
if err != nil {
panic(err)
}
}
func (n *helmChartClientCache) GetIndexed(name, key string) ([]*HelmChart, error) {
var result []*HelmChart
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
if v, ok := obj.(*HelmChart); ok {
result = append(result, v)
}
}
return result, nil
}
func (n *helmChartClient2) loadController() {
if n.controller == nil {
n.controller = n.iface.Controller()
}
}
type helmChartLifecycleDelegate struct {
create HelmChartChangeHandlerFunc
update HelmChartChangeHandlerFunc
remove HelmChartChangeHandlerFunc
}
func (n *helmChartLifecycleDelegate) HasCreate() bool {
return n.create != nil
}
func (n *helmChartLifecycleDelegate) Create(obj *HelmChart) (runtime.Object, error) {
if n.create == nil {
return obj, nil
}
return n.create(obj)
}
func (n *helmChartLifecycleDelegate) HasFinalize() bool {
return n.remove != nil
}
func (n *helmChartLifecycleDelegate) Remove(obj *HelmChart) (runtime.Object, error) {
if n.remove == nil {
return obj, nil
}
return n.remove(obj)
}
func (n *helmChartLifecycleDelegate) Updated(obj *HelmChart) (runtime.Object, error) {
if n.update == nil {
return obj, nil
}
return n.update(obj)
}

View File

@ -1,62 +0,0 @@
package v1
import (
"github.com/rancher/norman/lifecycle"
"k8s.io/apimachinery/pkg/runtime"
)
type HelmChartLifecycle interface {
Create(obj *HelmChart) (runtime.Object, error)
Remove(obj *HelmChart) (runtime.Object, error)
Updated(obj *HelmChart) (runtime.Object, error)
}
type helmChartLifecycleAdapter struct {
lifecycle HelmChartLifecycle
}
func (w *helmChartLifecycleAdapter) HasCreate() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasCreate()
}
func (w *helmChartLifecycleAdapter) HasFinalize() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasFinalize()
}
func (w *helmChartLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*HelmChart))
if o == nil {
return nil, err
}
return o, err
}
func (w *helmChartLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*HelmChart))
if o == nil {
return nil, err
}
return o, err
}
func (w *helmChartLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*HelmChart))
if o == nil {
return nil, err
}
return o, err
}
func NewHelmChartLifecycleAdapter(name string, clusterScoped bool, client HelmChartInterface, l HelmChartLifecycle) HelmChartHandlerFunc {
adapter := &helmChartLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *HelmChart) (runtime.Object, error) {
newObj, err := syncFn(key, obj)
if o, ok := newObj.(runtime.Object); ok {
return o, err
}
return nil, err
}
}

View File

@ -1,159 +0,0 @@
package v1
import (
"context"
"sync"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
"github.com/rancher/norman/objectclient/dynamic"
"github.com/rancher/norman/restwatch"
"k8s.io/client-go/rest"
)
type (
contextKeyType struct{}
contextClientsKeyType struct{}
)
type Interface interface {
RESTClient() rest.Interface
controller.Starter
AddonsGetter
HelmChartsGetter
ListenerConfigsGetter
}
type Clients struct {
Interface Interface
Addon AddonClient
HelmChart HelmChartClient
ListenerConfig ListenerConfigClient
}
type Client struct {
sync.Mutex
restClient rest.Interface
starters []controller.Starter
addonControllers map[string]AddonController
helmChartControllers map[string]HelmChartController
listenerConfigControllers map[string]ListenerConfigController
}
func Factory(ctx context.Context, config rest.Config) (context.Context, controller.Starter, error) {
c, err := NewForConfig(config)
if err != nil {
return ctx, nil, err
}
cs := NewClientsFromInterface(c)
ctx = context.WithValue(ctx, contextKeyType{}, c)
ctx = context.WithValue(ctx, contextClientsKeyType{}, cs)
return ctx, c, nil
}
func ClientsFrom(ctx context.Context) *Clients {
return ctx.Value(contextClientsKeyType{}).(*Clients)
}
func From(ctx context.Context) Interface {
return ctx.Value(contextKeyType{}).(Interface)
}
func NewClients(config rest.Config) (*Clients, error) {
iface, err := NewForConfig(config)
if err != nil {
return nil, err
}
return NewClientsFromInterface(iface), nil
}
func NewClientsFromInterface(iface Interface) *Clients {
return &Clients{
Interface: iface,
Addon: &addonClient2{
iface: iface.Addons(""),
},
HelmChart: &helmChartClient2{
iface: iface.HelmCharts(""),
},
ListenerConfig: &listenerConfigClient2{
iface: iface.ListenerConfigs(""),
},
}
}
func NewForConfig(config rest.Config) (Interface, error) {
if config.NegotiatedSerializer == nil {
config.NegotiatedSerializer = dynamic.NegotiatedSerializer
}
restClient, err := restwatch.UnversionedRESTClientFor(&config)
if err != nil {
return nil, err
}
return &Client{
restClient: restClient,
addonControllers: map[string]AddonController{},
helmChartControllers: map[string]HelmChartController{},
listenerConfigControllers: map[string]ListenerConfigController{},
}, nil
}
func (c *Client) RESTClient() rest.Interface {
return c.restClient
}
func (c *Client) Sync(ctx context.Context) error {
return controller.Sync(ctx, c.starters...)
}
func (c *Client) Start(ctx context.Context, threadiness int) error {
return controller.Start(ctx, threadiness, c.starters...)
}
type AddonsGetter interface {
Addons(namespace string) AddonInterface
}
func (c *Client) Addons(namespace string) AddonInterface {
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &AddonResource, AddonGroupVersionKind, addonFactory{})
return &addonClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type HelmChartsGetter interface {
HelmCharts(namespace string) HelmChartInterface
}
func (c *Client) HelmCharts(namespace string) HelmChartInterface {
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &HelmChartResource, HelmChartGroupVersionKind, helmChartFactory{})
return &helmChartClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type ListenerConfigsGetter interface {
ListenerConfigs(namespace string) ListenerConfigInterface
}
func (c *Client) ListenerConfigs(namespace string) ListenerConfigInterface {
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &ListenerConfigResource, ListenerConfigGroupVersionKind, listenerConfigFactory{})
return &listenerConfigClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}

View File

@ -1,440 +0,0 @@
package v1
import (
"context"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
ListenerConfigGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "ListenerConfig",
}
ListenerConfigResource = metav1.APIResource{
Name: "listenerconfigs",
SingularName: "listenerconfig",
Namespaced: true,
Kind: ListenerConfigGroupVersionKind.Kind,
}
)
func NewListenerConfig(namespace, name string, obj ListenerConfig) *ListenerConfig {
obj.APIVersion, obj.Kind = ListenerConfigGroupVersionKind.ToAPIVersionAndKind()
obj.Name = name
obj.Namespace = namespace
return &obj
}
type ListenerConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ListenerConfig
}
type ListenerConfigHandlerFunc func(key string, obj *ListenerConfig) (runtime.Object, error)
type ListenerConfigChangeHandlerFunc func(obj *ListenerConfig) (runtime.Object, error)
type ListenerConfigLister interface {
List(namespace string, selector labels.Selector) (ret []*ListenerConfig, err error)
Get(namespace, name string) (*ListenerConfig, error)
}
type ListenerConfigController interface {
Generic() controller.GenericController
Informer() cache.SharedIndexInformer
Lister() ListenerConfigLister
AddHandler(ctx context.Context, name string, handler ListenerConfigHandlerFunc)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler ListenerConfigHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type ListenerConfigInterface interface {
ObjectClient() *objectclient.ObjectClient
Create(*ListenerConfig) (*ListenerConfig, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*ListenerConfig, error)
Get(name string, opts metav1.GetOptions) (*ListenerConfig, error)
Update(*ListenerConfig) (*ListenerConfig, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*ListenerConfigList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() ListenerConfigController
AddHandler(ctx context.Context, name string, sync ListenerConfigHandlerFunc)
AddLifecycle(ctx context.Context, name string, lifecycle ListenerConfigLifecycle)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ListenerConfigHandlerFunc)
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ListenerConfigLifecycle)
}
type listenerConfigLister struct {
controller *listenerConfigController
}
func (l *listenerConfigLister) List(namespace string, selector labels.Selector) (ret []*ListenerConfig, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*ListenerConfig))
})
return
}
func (l *listenerConfigLister) Get(namespace, name string) (*ListenerConfig, error) {
var key string
if namespace != "" {
key = namespace + "/" + name
} else {
key = name
}
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: ListenerConfigGroupVersionKind.Group,
Resource: "listenerConfig",
}, key)
}
return obj.(*ListenerConfig), nil
}
type listenerConfigController struct {
controller.GenericController
}
func (c *listenerConfigController) Generic() controller.GenericController {
return c.GenericController
}
func (c *listenerConfigController) Lister() ListenerConfigLister {
return &listenerConfigLister{
controller: c,
}
}
func (c *listenerConfigController) AddHandler(ctx context.Context, name string, handler ListenerConfigHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*ListenerConfig); ok {
return handler(key, v)
} else {
return nil, nil
}
})
}
func (c *listenerConfigController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler ListenerConfigHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*ListenerConfig); ok && controller.ObjectInCluster(cluster, obj) {
return handler(key, v)
} else {
return nil, nil
}
})
}
type listenerConfigFactory struct {
}
func (c listenerConfigFactory) Object() runtime.Object {
return &ListenerConfig{}
}
func (c listenerConfigFactory) List() runtime.Object {
return &ListenerConfigList{}
}
func (s *listenerConfigClient) Controller() ListenerConfigController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.listenerConfigControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(ListenerConfigGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &listenerConfigController{
GenericController: genericController,
}
s.client.listenerConfigControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type listenerConfigClient struct {
client *Client
ns string
objectClient *objectclient.ObjectClient
controller ListenerConfigController
}
func (s *listenerConfigClient) ObjectClient() *objectclient.ObjectClient {
return s.objectClient
}
func (s *listenerConfigClient) Create(o *ListenerConfig) (*ListenerConfig, error) {
obj, err := s.objectClient.Create(o)
return obj.(*ListenerConfig), err
}
func (s *listenerConfigClient) Get(name string, opts metav1.GetOptions) (*ListenerConfig, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*ListenerConfig), err
}
func (s *listenerConfigClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*ListenerConfig, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*ListenerConfig), err
}
func (s *listenerConfigClient) Update(o *ListenerConfig) (*ListenerConfig, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*ListenerConfig), err
}
func (s *listenerConfigClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *listenerConfigClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *listenerConfigClient) List(opts metav1.ListOptions) (*ListenerConfigList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*ListenerConfigList), err
}
func (s *listenerConfigClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *listenerConfigClient) Patch(o *ListenerConfig, patchType types.PatchType, data []byte, subresources ...string) (*ListenerConfig, error) {
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
return obj.(*ListenerConfig), err
}
func (s *listenerConfigClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *listenerConfigClient) AddHandler(ctx context.Context, name string, sync ListenerConfigHandlerFunc) {
s.Controller().AddHandler(ctx, name, sync)
}
func (s *listenerConfigClient) AddLifecycle(ctx context.Context, name string, lifecycle ListenerConfigLifecycle) {
sync := NewListenerConfigLifecycleAdapter(name, false, s, lifecycle)
s.Controller().AddHandler(ctx, name, sync)
}
func (s *listenerConfigClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ListenerConfigHandlerFunc) {
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
func (s *listenerConfigClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ListenerConfigLifecycle) {
sync := NewListenerConfigLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
type ListenerConfigIndexer func(obj *ListenerConfig) ([]string, error)
type ListenerConfigClientCache interface {
Get(namespace, name string) (*ListenerConfig, error)
List(namespace string, selector labels.Selector) ([]*ListenerConfig, error)
Index(name string, indexer ListenerConfigIndexer)
GetIndexed(name, key string) ([]*ListenerConfig, error)
}
type ListenerConfigClient interface {
Create(*ListenerConfig) (*ListenerConfig, error)
Get(namespace, name string, opts metav1.GetOptions) (*ListenerConfig, error)
Update(*ListenerConfig) (*ListenerConfig, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
List(namespace string, opts metav1.ListOptions) (*ListenerConfigList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Cache() ListenerConfigClientCache
OnCreate(ctx context.Context, name string, sync ListenerConfigChangeHandlerFunc)
OnChange(ctx context.Context, name string, sync ListenerConfigChangeHandlerFunc)
OnRemove(ctx context.Context, name string, sync ListenerConfigChangeHandlerFunc)
Enqueue(namespace, name string)
Generic() controller.GenericController
ObjectClient() *objectclient.ObjectClient
Interface() ListenerConfigInterface
}
type listenerConfigClientCache struct {
client *listenerConfigClient2
}
type listenerConfigClient2 struct {
iface ListenerConfigInterface
controller ListenerConfigController
}
func (n *listenerConfigClient2) Interface() ListenerConfigInterface {
return n.iface
}
func (n *listenerConfigClient2) Generic() controller.GenericController {
return n.iface.Controller().Generic()
}
func (n *listenerConfigClient2) ObjectClient() *objectclient.ObjectClient {
return n.Interface().ObjectClient()
}
func (n *listenerConfigClient2) Enqueue(namespace, name string) {
n.iface.Controller().Enqueue(namespace, name)
}
func (n *listenerConfigClient2) Create(obj *ListenerConfig) (*ListenerConfig, error) {
return n.iface.Create(obj)
}
func (n *listenerConfigClient2) Get(namespace, name string, opts metav1.GetOptions) (*ListenerConfig, error) {
return n.iface.GetNamespaced(namespace, name, opts)
}
func (n *listenerConfigClient2) Update(obj *ListenerConfig) (*ListenerConfig, error) {
return n.iface.Update(obj)
}
func (n *listenerConfigClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return n.iface.DeleteNamespaced(namespace, name, options)
}
func (n *listenerConfigClient2) List(namespace string, opts metav1.ListOptions) (*ListenerConfigList, error) {
return n.iface.List(opts)
}
func (n *listenerConfigClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return n.iface.Watch(opts)
}
func (n *listenerConfigClientCache) Get(namespace, name string) (*ListenerConfig, error) {
return n.client.controller.Lister().Get(namespace, name)
}
func (n *listenerConfigClientCache) List(namespace string, selector labels.Selector) ([]*ListenerConfig, error) {
return n.client.controller.Lister().List(namespace, selector)
}
func (n *listenerConfigClient2) Cache() ListenerConfigClientCache {
n.loadController()
return &listenerConfigClientCache{
client: n,
}
}
func (n *listenerConfigClient2) OnCreate(ctx context.Context, name string, sync ListenerConfigChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-create", &listenerConfigLifecycleDelegate{create: sync})
}
func (n *listenerConfigClient2) OnChange(ctx context.Context, name string, sync ListenerConfigChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-change", &listenerConfigLifecycleDelegate{update: sync})
}
func (n *listenerConfigClient2) OnRemove(ctx context.Context, name string, sync ListenerConfigChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name, &listenerConfigLifecycleDelegate{remove: sync})
}
func (n *listenerConfigClientCache) Index(name string, indexer ListenerConfigIndexer) {
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
name: func(obj interface{}) ([]string, error) {
if v, ok := obj.(*ListenerConfig); ok {
return indexer(v)
}
return nil, nil
},
})
if err != nil {
panic(err)
}
}
func (n *listenerConfigClientCache) GetIndexed(name, key string) ([]*ListenerConfig, error) {
var result []*ListenerConfig
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
if v, ok := obj.(*ListenerConfig); ok {
result = append(result, v)
}
}
return result, nil
}
func (n *listenerConfigClient2) loadController() {
if n.controller == nil {
n.controller = n.iface.Controller()
}
}
type listenerConfigLifecycleDelegate struct {
create ListenerConfigChangeHandlerFunc
update ListenerConfigChangeHandlerFunc
remove ListenerConfigChangeHandlerFunc
}
func (n *listenerConfigLifecycleDelegate) HasCreate() bool {
return n.create != nil
}
func (n *listenerConfigLifecycleDelegate) Create(obj *ListenerConfig) (runtime.Object, error) {
if n.create == nil {
return obj, nil
}
return n.create(obj)
}
func (n *listenerConfigLifecycleDelegate) HasFinalize() bool {
return n.remove != nil
}
func (n *listenerConfigLifecycleDelegate) Remove(obj *ListenerConfig) (runtime.Object, error) {
if n.remove == nil {
return obj, nil
}
return n.remove(obj)
}
func (n *listenerConfigLifecycleDelegate) Updated(obj *ListenerConfig) (runtime.Object, error) {
if n.update == nil {
return obj, nil
}
return n.update(obj)
}

View File

@ -1,62 +0,0 @@
package v1
import (
"github.com/rancher/norman/lifecycle"
"k8s.io/apimachinery/pkg/runtime"
)
type ListenerConfigLifecycle interface {
Create(obj *ListenerConfig) (runtime.Object, error)
Remove(obj *ListenerConfig) (runtime.Object, error)
Updated(obj *ListenerConfig) (runtime.Object, error)
}
type listenerConfigLifecycleAdapter struct {
lifecycle ListenerConfigLifecycle
}
func (w *listenerConfigLifecycleAdapter) HasCreate() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasCreate()
}
func (w *listenerConfigLifecycleAdapter) HasFinalize() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasFinalize()
}
func (w *listenerConfigLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*ListenerConfig))
if o == nil {
return nil, err
}
return o, err
}
func (w *listenerConfigLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*ListenerConfig))
if o == nil {
return nil, err
}
return o, err
}
func (w *listenerConfigLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*ListenerConfig))
if o == nil {
return nil, err
}
return o, err
}
func NewListenerConfigLifecycleAdapter(name string, clusterScoped bool, client ListenerConfigInterface, l ListenerConfigLifecycle) ListenerConfigHandlerFunc {
adapter := &listenerConfigLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *ListenerConfig) (runtime.Object, error) {
newObj, err := syncFn(key, obj)
if o, ok := newObj.(runtime.Object); ok {
return o, err
}
return nil, err
}
}

View File

@ -1,44 +0,0 @@
package v1
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
const (
GroupName = "k3s.cattle.io"
Version = "v1"
)
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: Version}
// Kind takes an unqualified kind and returns a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
)
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
// TODO this gets cleaned up when the types are fixed
scheme.AddKnownTypes(SchemeGroupVersion,
&Addon{},
&AddonList{},
&HelmChart{},
&HelmChartList{},
&ListenerConfig{},
&ListenerConfigList{},
)
return nil
}

Some files were not shown because too many files have changed in this diff Show More