Skip to content

Commit

Permalink
Merge pull request kubernetes#8 from deads2k/gen
Browse files Browse the repository at this point in the history
Use types from openshift/api
  • Loading branch information
deads2k authored Oct 27, 2017
2 parents 77ba4a9 + f71dcc2 commit 2b31c3e
Show file tree
Hide file tree
Showing 5,325 changed files with 2,077,652 additions and 51 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
12 changes: 12 additions & 0 deletions .travis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: go

go:
- 1.8

script:
- PERMISSIVE_GO=y make build

notifications:
irc: "chat.freenode.net#openshift-dev"

sudo: false
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
all: generate build
all: build
.PHONY: all

build:
Expand All @@ -13,6 +13,7 @@ build:
go build github.com/openshift/client-go/route/...
go build github.com/openshift/client-go/security/...
go build github.com/openshift/client-go/template/...
go build github.com/openshift/client-go/user/...
.PHONY: build

generate:
Expand Down
82 changes: 82 additions & 0 deletions apps/clientset/versioned/clientset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package versioned

import (
glog "github.com/golang/glog"
appsv1 "github.com/openshift/client-go/apps/clientset/versioned/typed/apps/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
AppsV1() appsv1.AppsV1Interface
// Deprecated: please explicitly pick a version if possible.
Apps() appsv1.AppsV1Interface
}

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

// AppsV1 retrieves the AppsV1Client
func (c *Clientset) AppsV1() appsv1.AppsV1Interface {
return c.appsV1
}

// Deprecated: Apps retrieves the default version of AppsClient.
// Please explicitly pick a version.
func (c *Clientset) Apps() appsv1.AppsV1Interface {
return c.appsV1
}

// 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.appsV1, err = appsv1.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}

cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
if err != nil {
glog.Errorf("failed to create the DiscoveryClient: %v", err)
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.appsV1 = appsv1.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.appsV1 = appsv1.New(c)

cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs
}
4 changes: 4 additions & 0 deletions apps/clientset/versioned/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This package is generated by client-gen with custom arguments.

// This package has the automatically generated clientset.
package versioned
55 changes: 55 additions & 0 deletions apps/clientset/versioned/fake/clientset_generated.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package fake

import (
clientset "github.com/openshift/client-go/apps/clientset/versioned"
appsv1 "github.com/openshift/client-go/apps/clientset/versioned/typed/apps/v1"
fakeappsv1 "github.com/openshift/client-go/apps/clientset/versioned/typed/apps/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)
}
}

fakePtr := testing.Fake{}
fakePtr.AddReactor("*", "*", testing.ObjectReaction(o))
fakePtr.AddWatchReactor("*", testing.DefaultWatchReactor(watch.NewFake(), nil))

return &Clientset{fakePtr, &fakediscovery.FakeDiscovery{Fake: &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 {
testing.Fake
discovery *fakediscovery.FakeDiscovery
}

func (c *Clientset) Discovery() discovery.DiscoveryInterface {
return c.discovery
}

var _ clientset.Interface = &Clientset{}

// AppsV1 retrieves the AppsV1Client
func (c *Clientset) AppsV1() appsv1.AppsV1Interface {
return &fakeappsv1.FakeAppsV1{Fake: &c.Fake}
}

// Apps retrieves the AppsV1Client
func (c *Clientset) Apps() appsv1.AppsV1Interface {
return &fakeappsv1.FakeAppsV1{Fake: &c.Fake}
}
4 changes: 4 additions & 0 deletions apps/clientset/versioned/fake/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This package is generated by client-gen with custom arguments.

// This package has the automatically generated fake clientset.
package fake
37 changes: 37 additions & 0 deletions apps/clientset/versioned/fake/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package fake

import (
appsv1 "github.com/openshift/api/apps/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"
)

var scheme = runtime.NewScheme()
var codecs = serializer.NewCodecFactory(scheme)
var parameterCodec = runtime.NewParameterCodec(scheme)

func init() {
v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
AddToScheme(scheme)
}

// 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/kuberentes/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.
func AddToScheme(scheme *runtime.Scheme) {
appsv1.AddToScheme(scheme)

}
4 changes: 4 additions & 0 deletions apps/clientset/versioned/scheme/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This package is generated by client-gen with custom arguments.

// This package contains the scheme of the automatically generated clientset.
package scheme
37 changes: 37 additions & 0 deletions apps/clientset/versioned/scheme/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package scheme

import (
appsv1 "github.com/openshift/api/apps/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"
)

var Scheme = runtime.NewScheme()
var Codecs = serializer.NewCodecFactory(Scheme)
var ParameterCodec = runtime.NewParameterCodec(Scheme)

func init() {
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
AddToScheme(Scheme)
}

// 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/kuberentes/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.
func AddToScheme(scheme *runtime.Scheme) {
appsv1.AddToScheme(scheme)

}
72 changes: 72 additions & 0 deletions apps/clientset/versioned/typed/apps/v1/apps_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package v1

import (
v1 "github.com/openshift/api/apps/v1"
"github.com/openshift/client-go/apps/clientset/versioned/scheme"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
rest "k8s.io/client-go/rest"
)

type AppsV1Interface interface {
RESTClient() rest.Interface
DeploymentConfigsGetter
}

// AppsV1Client is used to interact with features provided by the apps.openshift.io group.
type AppsV1Client struct {
restClient rest.Interface
}

func (c *AppsV1Client) DeploymentConfigs(namespace string) DeploymentConfigInterface {
return newDeploymentConfigs(c, namespace)
}

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

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

// New creates a new AppsV1Client for the given RESTClient.
func New(c rest.Interface) *AppsV1Client {
return &AppsV1Client{c}
}

func setConfigDefaults(config *rest.Config) error {
gv := v1.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = 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 *AppsV1Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}
Loading

0 comments on commit 2b31c3e

Please sign in to comment.