k3s/vendor/github.com/rancher/norman/pkg/objectset/desiredset.go

56 lines
1.6 KiB
Go
Raw Normal View History

2019-01-22 20:53:35 +00:00
package objectset
import (
"github.com/rancher/norman/objectclient"
"github.com/rancher/norman/pkg/objectset/injectors"
"github.com/rancher/norman/types"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/discovery"
"k8s.io/client-go/rest"
)
type DesiredSet struct {
discoveredClients map[schema.GroupVersionKind]*objectclient.ObjectClient
2019-03-07 19:56:57 +00:00
namespaced map[schema.GroupVersionKind]bool
2019-01-22 20:53:35 +00:00
discovery discovery.DiscoveryInterface
restConfig rest.Config
remove bool
setID string
objs *ObjectSet
codeVersion string
clients map[schema.GroupVersionKind]Client
2019-01-31 22:42:07 +00:00
patchers map[schema.GroupVersionKind]Patcher
2019-01-22 20:53:35 +00:00
owner runtime.Object
injectors []injectors.ConfigInjector
errs []error
}
2019-03-07 19:56:57 +00:00
func (o *DesiredSet) AddDiscoveredClient(gvk schema.GroupVersionKind, client *objectclient.ObjectClient, namespaced bool) {
2019-01-22 20:53:35 +00:00
if o.discoveredClients == nil {
o.discoveredClients = map[schema.GroupVersionKind]*objectclient.ObjectClient{}
}
o.discoveredClients[gvk] = client
2019-03-07 19:56:57 +00:00
if o.namespaced == nil {
o.namespaced = map[schema.GroupVersionKind]bool{}
}
o.namespaced[gvk] = namespaced
2019-01-22 20:53:35 +00:00
}
func (o *DesiredSet) DiscoveredClients() map[schema.GroupVersionKind]*objectclient.ObjectClient {
return o.discoveredClients
}
func (o *DesiredSet) AddInjector(inj injectors.ConfigInjector) {
o.injectors = append(o.injectors, inj)
}
func (o *DesiredSet) err(err error) error {
o.errs = append(o.errs, err)
return o.Err()
}
func (o *DesiredSet) Err() error {
return types.NewErrors(append(o.objs.errs, o.errs...)...)
}