Skip to content

Commit

Permalink
Generated clientset
Browse files Browse the repository at this point in the history
  • Loading branch information
soltysh committed Nov 1, 2016
1 parent ab858ac commit f7027fd
Show file tree
Hide file tree
Showing 110 changed files with 4,896 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package release_v1_4

import (
"github.com/golang/glog"
v1core "github.com/openshift/origin/pkg/authorization/client/clientset_generated/release_v1_4/typed/core/v1"
restclient "k8s.io/kubernetes/pkg/client/restclient"
discovery "k8s.io/kubernetes/pkg/client/typed/discovery"
"k8s.io/kubernetes/pkg/util/flowcontrol"
)

type Interface interface {
Discovery() discovery.DiscoveryInterface
Core() v1core.CoreInterface
}

// Clientset contains the clients for groups. Each group has exactly one
// version included in a Clientset.
type Clientset struct {
*discovery.DiscoveryClient
*v1core.CoreClient
}

// Core retrieves the CoreClient
func (c *Clientset) Core() v1core.CoreInterface {
if c == nil {
return nil
}
return c.CoreClient
}

// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
return c.DiscoveryClient
}

// NewForConfig creates a new Clientset for the given config.
func NewForConfig(c *restclient.Config) (*Clientset, error) {
configShallowCopy := *c
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
}
var clientset Clientset
var err error
clientset.CoreClient, err = v1core.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}

clientset.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
if err != nil {
glog.Errorf("failed to create the DiscoveryClient: %v", err)
return nil, err
}
return &clientset, nil
}

// NewForConfigOrDie creates a new Clientset for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *restclient.Config) *Clientset {
var clientset Clientset
clientset.CoreClient = v1core.NewForConfigOrDie(c)

clientset.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &clientset
}

// New creates a new Clientset for the given RESTClient.
func New(c *restclient.RESTClient) *Clientset {
var clientset Clientset
clientset.CoreClient = v1core.New(c)

clientset.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &clientset
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This package is generated by client-gen with arguments: --clientset-api-path=/oapi --clientset-name=release_v1_4 --clientset-path=github.com/openshift/origin/pkg/authorization/client/clientset_generated --go-header-file=hack/boilerplate.txt --input=[api/v1] --input-base=github.com/openshift/origin/pkg/authorization/api --output-base=../../..

// This package has the automatically generated clientset.
package release_v1_4
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package fake

import (
clientset "github.com/openshift/origin/pkg/authorization/client/clientset_generated/release_v1_4"
v1core "github.com/openshift/origin/pkg/authorization/client/clientset_generated/release_v1_4/typed/core/v1"
fakev1core "github.com/openshift/origin/pkg/authorization/client/clientset_generated/release_v1_4/typed/core/v1/fake"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/client/testing/core"
"k8s.io/kubernetes/pkg/client/typed/discovery"
fakediscovery "k8s.io/kubernetes/pkg/client/typed/discovery/fake"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch"
)

// 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 := core.NewObjectTracker(api.Scheme, api.Codecs.UniversalDecoder())
for _, obj := range objects {
if err := o.Add(obj); err != nil {
panic(err)
}
}

fakePtr := core.Fake{}
fakePtr.AddReactor("*", "*", core.ObjectReaction(o, registered.RESTMapper()))

fakePtr.AddWatchReactor("*", core.DefaultWatchReactor(watch.NewFake(), nil))

return &Clientset{fakePtr}
}

// 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 {
core.Fake
}

func (c *Clientset) Discovery() discovery.DiscoveryInterface {
return &fakediscovery.FakeDiscovery{Fake: &c.Fake}
}

var _ clientset.Interface = &Clientset{}

// Core retrieves the CoreClient
func (c *Clientset) Core() v1core.CoreInterface {
return &fakev1core.FakeCore{Fake: &c.Fake}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This package is generated by client-gen with arguments: --clientset-api-path=/oapi --clientset-name=release_v1_4 --clientset-path=github.com/openshift/origin/pkg/authorization/client/clientset_generated --go-header-file=hack/boilerplate.txt --input=[api/v1] --input-base=github.com/openshift/origin/pkg/authorization/api --output-base=../../..

// This package has the automatically generated fake clientset.
package fake
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package v1

import (
api "k8s.io/kubernetes/pkg/api"
registered "k8s.io/kubernetes/pkg/apimachinery/registered"
restclient "k8s.io/kubernetes/pkg/client/restclient"
serializer "k8s.io/kubernetes/pkg/runtime/serializer"
)

type CoreInterface interface {
GetRESTClient() *restclient.RESTClient
PoliciesGetter
}

// CoreClient is used to interact with features provided by the Core group.
type CoreClient struct {
*restclient.RESTClient
}

func (c *CoreClient) Policies(namespace string) PolicyInterface {
return newPolicies(c, namespace)
}

// NewForConfig creates a new CoreClient for the given config.
func NewForConfig(c *restclient.Config) (*CoreClient, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := restclient.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &CoreClient{client}, nil
}

// NewForConfigOrDie creates a new CoreClient for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *restclient.Config) *CoreClient {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}

// New creates a new CoreClient for the given RESTClient.
func New(c *restclient.RESTClient) *CoreClient {
return &CoreClient{c}
}

func setConfigDefaults(config *restclient.Config) error {
// if core group is not registered, return an error
g, err := registered.Group("")
if err != nil {
return err
}
config.APIPath = "/oapi"
if config.UserAgent == "" {
config.UserAgent = restclient.DefaultKubernetesUserAgent()
}
// TODO: Unconditionally set the config.Version, until we fix the config.
//if config.Version == "" {
copyGroupVersion := g.GroupVersion
config.GroupVersion = &copyGroupVersion
//}

config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: api.Codecs}

return nil
}

// GetRESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *CoreClient) GetRESTClient() *restclient.RESTClient {
if c == nil {
return nil
}
return c.RESTClient
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This package is generated by client-gen with arguments: --clientset-api-path=/oapi --clientset-name=release_v1_4 --clientset-path=github.com/openshift/origin/pkg/authorization/client/clientset_generated --go-header-file=hack/boilerplate.txt --input=[api/v1] --input-base=github.com/openshift/origin/pkg/authorization/api --output-base=../../..

// This package has the automatically generated typed clients.
package v1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This package is generated by client-gen with arguments: --clientset-api-path=/oapi --clientset-name=release_v1_4 --clientset-path=github.com/openshift/origin/pkg/authorization/client/clientset_generated --go-header-file=hack/boilerplate.txt --input=[api/v1] --input-base=github.com/openshift/origin/pkg/authorization/api --output-base=../../..

// Package fake has the automatically generated clients.
package fake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package fake

import (
v1 "github.com/openshift/origin/pkg/authorization/client/clientset_generated/release_v1_4/typed/core/v1"
restclient "k8s.io/kubernetes/pkg/client/restclient"
core "k8s.io/kubernetes/pkg/client/testing/core"
)

type FakeCore struct {
*core.Fake
}

func (c *FakeCore) Policies(namespace string) v1.PolicyInterface {
return &FakePolicies{c, namespace}
}

// GetRESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeCore) GetRESTClient() *restclient.RESTClient {
return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package fake

import (
v1 "github.com/openshift/origin/pkg/authorization/api/v1"
api "k8s.io/kubernetes/pkg/api"
unversioned "k8s.io/kubernetes/pkg/api/unversioned"
core "k8s.io/kubernetes/pkg/client/testing/core"
labels "k8s.io/kubernetes/pkg/labels"
watch "k8s.io/kubernetes/pkg/watch"
)

// FakePolicies implements PolicyInterface
type FakePolicies struct {
Fake *FakeCore
ns string
}

var policiesResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "policies"}

func (c *FakePolicies) Create(policy *v1.Policy) (result *v1.Policy, err error) {
obj, err := c.Fake.
Invokes(core.NewCreateAction(policiesResource, c.ns, policy), &v1.Policy{})

if obj == nil {
return nil, err
}
return obj.(*v1.Policy), err
}

func (c *FakePolicies) Update(policy *v1.Policy) (result *v1.Policy, err error) {
obj, err := c.Fake.
Invokes(core.NewUpdateAction(policiesResource, c.ns, policy), &v1.Policy{})

if obj == nil {
return nil, err
}
return obj.(*v1.Policy), err
}

func (c *FakePolicies) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction(policiesResource, c.ns, name), &v1.Policy{})

return err
}

func (c *FakePolicies) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
action := core.NewDeleteCollectionAction(policiesResource, c.ns, listOptions)

_, err := c.Fake.Invokes(action, &v1.PolicyList{})
return err
}

func (c *FakePolicies) Get(name string) (result *v1.Policy, err error) {
obj, err := c.Fake.
Invokes(core.NewGetAction(policiesResource, c.ns, name), &v1.Policy{})

if obj == nil {
return nil, err
}
return obj.(*v1.Policy), err
}

func (c *FakePolicies) List(opts api.ListOptions) (result *v1.PolicyList, err error) {
obj, err := c.Fake.
Invokes(core.NewListAction(policiesResource, c.ns, opts), &v1.PolicyList{})

if obj == nil {
return nil, err
}

label := opts.LabelSelector
if label == nil {
label = labels.Everything()
}
list := &v1.PolicyList{}
for _, item := range obj.(*v1.PolicyList).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 policies.
func (c *FakePolicies) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(core.NewWatchAction(policiesResource, c.ns, opts))

}

// Patch applies the patch and returns the patched policy.
func (c *FakePolicies) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Policy, err error) {
obj, err := c.Fake.
Invokes(core.NewPatchSubresourceAction(policiesResource, c.ns, name, data, subresources...), &v1.Policy{})

if obj == nil {
return nil, err
}
return obj.(*v1.Policy), err
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package v1

type PolicyExpansion interface{}

0 comments on commit f7027fd

Please sign in to comment.