Update godeps

This commit is contained in:
Prashanth Balasubramanian 2016-06-21 11:58:43 -07:00
parent 423433bc5f
commit 701c5a0e30
482 changed files with 86915 additions and 19741 deletions

View file

@ -18,6 +18,7 @@ package internalclientset
import (
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
unversionedbatch "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/batch/unversioned"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/unversioned"
unversionedextensions "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/extensions/unversioned"
"k8s.io/kubernetes/pkg/client/typed/discovery"
@ -39,7 +40,11 @@ func FromUnversionedClient(c *unversioned.Client) *internalclientset.Clientset {
} else {
clientset.ExtensionsClient = unversionedextensions.New(nil)
}
if c != nil && c.BatchClient != nil {
clientset.BatchClient = unversionedbatch.New(c.BatchClient.RESTClient)
} else {
clientset.BatchClient = unversionedbatch.New(nil)
}
if c != nil && c.DiscoveryClient != nil {
clientset.DiscoveryClient = discovery.NewDiscoveryClient(c.DiscoveryClient.RESTClient)
} else {

View file

@ -33,7 +33,7 @@ type AutoscalingClient struct {
}
func (c *AutoscalingClient) HorizontalPodAutoscalers(namespace string) HorizontalPodAutoscalerInterface {
return newHorizontalPodAutoscalersV1(c, namespace)
return newHorizontalPodAutoscalers(c, namespace)
}
func NewAutoscaling(c *restclient.Config) (*AutoscalingClient, error) {

View file

@ -18,13 +18,16 @@ package unversioned
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
"k8s.io/kubernetes/pkg/client/restclient"
)
type BatchInterface interface {
JobsNamespacer
ScheduledJobsNamespacer
}
// BatchClient is used to interact with Kubernetes batch features.
@ -36,9 +39,25 @@ func (c *BatchClient) Jobs(namespace string) JobInterface {
return newJobsV1(c, namespace)
}
func (c *BatchClient) ScheduledJobs(namespace string) ScheduledJobInterface {
return newScheduledJobs(c, namespace)
}
func NewBatch(c *restclient.Config) (*BatchClient, error) {
config := *c
if err := setBatchDefaults(&config); err != nil {
if err := setBatchDefaults(&config, nil); err != nil {
return nil, err
}
client, err := restclient.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &BatchClient{client}, nil
}
func NewBatchV2Alpha1(c *restclient.Config) (*BatchClient, error) {
config := *c
if err := setBatchDefaults(&config, &v2alpha1.SchemeGroupVersion); err != nil {
return nil, err
}
client, err := restclient.RESTClientFor(&config)
@ -49,14 +68,22 @@ func NewBatch(c *restclient.Config) (*BatchClient, error) {
}
func NewBatchOrDie(c *restclient.Config) *BatchClient {
client, err := NewBatch(c)
var (
client *BatchClient
err error
)
if c.ContentConfig.GroupVersion != nil && *c.ContentConfig.GroupVersion == v2alpha1.SchemeGroupVersion {
client, err = NewBatchV2Alpha1(c)
} else {
client, err = NewBatch(c)
}
if err != nil {
panic(err)
}
return client
}
func setBatchDefaults(config *restclient.Config) error {
func setBatchDefaults(config *restclient.Config, gv *unversioned.GroupVersion) error {
// if batch group is not registered, return an error
g, err := registered.Group(batch.GroupName)
if err != nil {
@ -69,6 +96,9 @@ func setBatchDefaults(config *restclient.Config) error {
// TODO: Unconditionally set the config.Version, until we fix the config.
//if config.Version == "" {
copyGroupVersion := g.GroupVersion
if gv != nil {
copyGroupVersion = *gv
}
config.GroupVersion = &copyGroupVersion
//}

View file

@ -47,6 +47,7 @@ type Interface interface {
Autoscaling() AutoscalingInterface
Batch() BatchInterface
Extensions() ExtensionsInterface
Rbac() RbacInterface
Discovery() discovery.DiscoveryInterface
}
@ -120,6 +121,8 @@ type Client struct {
*BatchClient
*ExtensionsClient
*AppsClient
*PolicyClient
*RbacClient
*discovery.DiscoveryClient
}
@ -161,6 +164,10 @@ func (c *Client) Apps() AppsInterface {
return c.AppsClient
}
func (c *Client) Rbac() RbacInterface {
return c.RbacClient
}
func (c *Client) Discovery() discovery.DiscoveryInterface {
return c.DiscoveryClient
}

View file

@ -43,7 +43,7 @@ var Versions = []string{"v1"}
var Codec runtime.Codec
func init() {
yamlSerializer := json.NewYAMLSerializer(json.DefaultMetaFactory, api.Scheme, runtime.ObjectTyperToTyper(api.Scheme))
yamlSerializer := json.NewYAMLSerializer(json.DefaultMetaFactory, api.Scheme, api.Scheme)
Codec = versioning.NewCodecForScheme(
api.Scheme,
yamlSerializer,

View file

@ -35,9 +35,9 @@ func init() {
}
func (obj *Config) GetObjectKind() unversioned.ObjectKind { return obj }
func (obj *Config) SetGroupVersionKind(gvk *unversioned.GroupVersionKind) {
func (obj *Config) SetGroupVersionKind(gvk unversioned.GroupVersionKind) {
obj.APIVersion, obj.Kind = gvk.ToAPIVersionAndKind()
}
func (obj *Config) GroupVersionKind() *unversioned.GroupVersionKind {
func (obj *Config) GroupVersionKind() unversioned.GroupVersionKind {
return unversioned.FromAPIVersionAndKind(obj.APIVersion, obj.Kind)
}

View file

@ -32,9 +32,9 @@ func init() {
}
func (obj *Config) GetObjectKind() unversioned.ObjectKind { return obj }
func (obj *Config) SetGroupVersionKind(gvk *unversioned.GroupVersionKind) {
func (obj *Config) SetGroupVersionKind(gvk unversioned.GroupVersionKind) {
obj.APIVersion, obj.Kind = gvk.ToAPIVersionAndKind()
}
func (obj *Config) GroupVersionKind() *unversioned.GroupVersionKind {
func (obj *Config) GroupVersionKind() unversioned.GroupVersionKind {
return unversioned.FromAPIVersionAndKind(obj.APIVersion, obj.Kind)
}

View file

@ -399,3 +399,13 @@ func BuildConfigFromFlags(masterUrl, kubeconfigPath string) (*restclient.Config,
&ClientConfigLoadingRules{ExplicitPath: kubeconfigPath},
&ConfigOverrides{ClusterInfo: clientcmdapi.Cluster{Server: masterUrl}}).ClientConfig()
}
// BuildConfigFromKubeconfigGetter is a helper function that builds configs from a master
// url and a kubeconfigGetter.
func BuildConfigFromKubeconfigGetter(masterUrl string, kubeconfigGetter KubeconfigGetter) (*restclient.Config, error) {
// TODO: We do not need a DeferredLoader here. Refactor code and see if we can use DirectClientConfig here.
cc := NewNonInteractiveDeferredLoadingClientConfig(
&ClientConfigGetter{kubeconfigGetter: kubeconfigGetter},
&ConfigOverrides{ClusterInfo: clientcmdapi.Cluster{Server: masterUrl}})
return cc.ClientConfig()
}

View file

@ -63,6 +63,40 @@ func currentMigrationRules() map[string]string {
return migrationRules
}
type ClientConfigLoader interface {
ConfigAccess
Load() (*clientcmdapi.Config, error)
}
type KubeconfigGetter func() (*clientcmdapi.Config, error)
type ClientConfigGetter struct {
kubeconfigGetter KubeconfigGetter
}
// ClientConfigGetter implements the ClientConfigLoader interface.
var _ ClientConfigLoader = &ClientConfigGetter{}
func (g *ClientConfigGetter) Load() (*clientcmdapi.Config, error) {
return g.kubeconfigGetter()
}
func (g *ClientConfigGetter) GetLoadingPrecedence() []string {
return nil
}
func (g *ClientConfigGetter) GetStartingConfig() (*clientcmdapi.Config, error) {
return nil, nil
}
func (g *ClientConfigGetter) GetDefaultFilename() string {
return ""
}
func (g *ClientConfigGetter) IsExplicitFile() bool {
return false
}
func (g *ClientConfigGetter) GetExplicitFile() string {
return ""
}
// ClientConfigLoadingRules is an ExplicitPath and string slice of specific locations that are used for merging together a Config
// Callers can put the chain together however they want, but we'd recommend:
// EnvVarPathFiles if set (a list of files if set) OR the HomeDirectoryPath
@ -80,6 +114,9 @@ type ClientConfigLoadingRules struct {
DoNotResolvePaths bool
}
// ClientConfigLoadingRules implements the ClientConfigLoader interface.
var _ ClientConfigLoader = &ClientConfigLoadingRules{}
// NewDefaultClientConfigLoadingRules returns a ClientConfigLoadingRules object with default fields filled in. You are not required to
// use this constructor
func NewDefaultClientConfigLoadingRules() *ClientConfigLoadingRules {
@ -260,7 +297,7 @@ func (rules *ClientConfigLoadingRules) GetDefaultFilename() string {
return filename
}
}
// If none exists, use the first from precendence.
// If none exists, use the first from precedence.
if len(rules.Precedence) > 0 {
return rules.Precedence[0]
}

View file

@ -27,13 +27,13 @@ import (
clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
)
// DeferredLoadingClientConfig is a ClientConfig interface that is backed by a set of loading rules
// DeferredLoadingClientConfig is a ClientConfig interface that is backed by a client config loader.
// It is used in cases where the loading rules may change after you've instantiated them and you want to be sure that
// the most recent rules are used. This is useful in cases where you bind flags to loading rule parameters before
// the parse happens and you want your calling code to be ignorant of how the values are being mutated to avoid
// passing extraneous information down a call stack
type DeferredLoadingClientConfig struct {
loadingRules *ClientConfigLoadingRules
loader ClientConfigLoader
overrides *ConfigOverrides
fallbackReader io.Reader
@ -42,13 +42,13 @@ type DeferredLoadingClientConfig struct {
}
// NewNonInteractiveDeferredLoadingClientConfig creates a ConfigClientClientConfig using the passed context name
func NewNonInteractiveDeferredLoadingClientConfig(loadingRules *ClientConfigLoadingRules, overrides *ConfigOverrides) ClientConfig {
return &DeferredLoadingClientConfig{loadingRules: loadingRules, overrides: overrides}
func NewNonInteractiveDeferredLoadingClientConfig(loader ClientConfigLoader, overrides *ConfigOverrides) ClientConfig {
return &DeferredLoadingClientConfig{loader: loader, overrides: overrides}
}
// NewInteractiveDeferredLoadingClientConfig creates a ConfigClientClientConfig using the passed context name and the fallback auth reader
func NewInteractiveDeferredLoadingClientConfig(loadingRules *ClientConfigLoadingRules, overrides *ConfigOverrides, fallbackReader io.Reader) ClientConfig {
return &DeferredLoadingClientConfig{loadingRules: loadingRules, overrides: overrides, fallbackReader: fallbackReader}
func NewInteractiveDeferredLoadingClientConfig(loader ClientConfigLoader, overrides *ConfigOverrides, fallbackReader io.Reader) ClientConfig {
return &DeferredLoadingClientConfig{loader: loader, overrides: overrides, fallbackReader: fallbackReader}
}
func (config *DeferredLoadingClientConfig) createClientConfig() (ClientConfig, error) {
@ -57,16 +57,16 @@ func (config *DeferredLoadingClientConfig) createClientConfig() (ClientConfig, e
defer config.loadingLock.Unlock()
if config.clientConfig == nil {
mergedConfig, err := config.loadingRules.Load()
mergedConfig, err := config.loader.Load()
if err != nil {
return nil, err
}
var mergedClientConfig ClientConfig
if config.fallbackReader != nil {
mergedClientConfig = NewInteractiveClientConfig(*mergedConfig, config.overrides.CurrentContext, config.overrides, config.fallbackReader, config.loadingRules)
mergedClientConfig = NewInteractiveClientConfig(*mergedConfig, config.overrides.CurrentContext, config.overrides, config.fallbackReader, config.loader)
} else {
mergedClientConfig = NewNonInteractiveClientConfig(*mergedConfig, config.overrides.CurrentContext, config.overrides, config.loadingRules)
mergedClientConfig = NewNonInteractiveClientConfig(*mergedConfig, config.overrides.CurrentContext, config.overrides, config.loader)
}
config.clientConfig = mergedClientConfig
@ -118,5 +118,5 @@ func (config *DeferredLoadingClientConfig) Namespace() (string, bool, error) {
// ConfigAccess implements ClientConfig
func (config *DeferredLoadingClientConfig) ConfigAccess() ConfigAccess {
return config.loadingRules
return config.loader
}

View file

@ -260,8 +260,10 @@ func validateContext(contextName string, context clientcmdapi.Context, config cl
validationErrors = append(validationErrors, fmt.Errorf("cluster %q was not found for context %q", context.Cluster, contextName))
}
if (len(context.Namespace) != 0) && !validation.IsDNS952Label(context.Namespace) {
validationErrors = append(validationErrors, fmt.Errorf("namespace %q for context %q does not conform to the kubernetes DNS952 rules", context.Namespace, contextName))
if len(context.Namespace) != 0 {
if len(validation.IsDNS1123Label(context.Namespace)) != 0 {
validationErrors = append(validationErrors, fmt.Errorf("namespace %q for context %q does not conform to the kubernetes DNS_LABEL rules", context.Namespace, contextName))
}
}
return validationErrors

View file

@ -0,0 +1,92 @@
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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.
*/
package unversioned
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/watch"
)
// ClusterRoleBindings has methods to work with ClusterRoleBinding resources in a namespace
type ClusterRoleBindings interface {
ClusterRoleBindings() ClusterRoleBindingInterface
}
// ClusterRoleBindingInterface has methods to work with ClusterRoleBinding resources.
type ClusterRoleBindingInterface interface {
List(opts api.ListOptions) (*rbac.ClusterRoleBindingList, error)
Get(name string) (*rbac.ClusterRoleBinding, error)
Delete(name string, options *api.DeleteOptions) error
Create(clusterRoleBinding *rbac.ClusterRoleBinding) (*rbac.ClusterRoleBinding, error)
Update(clusterRoleBinding *rbac.ClusterRoleBinding) (*rbac.ClusterRoleBinding, error)
Watch(opts api.ListOptions) (watch.Interface, error)
}
// clusterRoleBindings implements ClusterRoleBindingsNamespacer interface
type clusterRoleBindings struct {
client *RbacClient
}
// newClusterRoleBindings returns a clusterRoleBindings
func newClusterRoleBindings(c *RbacClient) *clusterRoleBindings {
return &clusterRoleBindings{
client: c,
}
}
// List takes label and field selectors, and returns the list of clusterRoleBindings that match those selectors.
func (c *clusterRoleBindings) List(opts api.ListOptions) (result *rbac.ClusterRoleBindingList, err error) {
result = &rbac.ClusterRoleBindingList{}
err = c.client.Get().Resource("clusterrolebindings").VersionedParams(&opts, api.ParameterCodec).Do().Into(result)
return
}
// Get takes the name of the clusterRoleBinding, and returns the corresponding ClusterRoleBinding object, and an error if it occurs
func (c *clusterRoleBindings) Get(name string) (result *rbac.ClusterRoleBinding, err error) {
result = &rbac.ClusterRoleBinding{}
err = c.client.Get().Resource("clusterrolebindings").Name(name).Do().Into(result)
return
}
// Delete takes the name of the clusterRoleBinding and deletes it. Returns an error if one occurs.
func (c *clusterRoleBindings) Delete(name string, options *api.DeleteOptions) error {
return c.client.Delete().Resource("clusterrolebindings").Name(name).Body(options).Do().Error()
}
// Create takes the representation of a clusterRoleBinding and creates it. Returns the server's representation of the clusterRoleBinding, and an error, if it occurs.
func (c *clusterRoleBindings) Create(clusterRoleBinding *rbac.ClusterRoleBinding) (result *rbac.ClusterRoleBinding, err error) {
result = &rbac.ClusterRoleBinding{}
err = c.client.Post().Resource("clusterrolebindings").Body(clusterRoleBinding).Do().Into(result)
return
}
// Update takes the representation of a clusterRoleBinding and updates it. Returns the server's representation of the clusterRoleBinding, and an error, if it occurs.
func (c *clusterRoleBindings) Update(clusterRoleBinding *rbac.ClusterRoleBinding) (result *rbac.ClusterRoleBinding, err error) {
result = &rbac.ClusterRoleBinding{}
err = c.client.Put().Resource("clusterrolebindings").Name(clusterRoleBinding.Name).Body(clusterRoleBinding).Do().Into(result)
return
}
// Watch returns a watch.Interface that watches the requested clusterRoleBindings.
func (c *clusterRoleBindings) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.client.Get().
Prefix("watch").
Resource("clusterrolebindings").
VersionedParams(&opts, api.ParameterCodec).
Watch()
}

View file

@ -0,0 +1,92 @@
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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.
*/
package unversioned
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/watch"
)
// ClusterRoles has methods to work with ClusterRole resources in a namespace
type ClusterRoles interface {
ClusterRoles() ClusterRoleInterface
}
// ClusterRoleInterface has methods to work with ClusterRole resources.
type ClusterRoleInterface interface {
List(opts api.ListOptions) (*rbac.ClusterRoleList, error)
Get(name string) (*rbac.ClusterRole, error)
Delete(name string, options *api.DeleteOptions) error
Create(clusterRole *rbac.ClusterRole) (*rbac.ClusterRole, error)
Update(clusterRole *rbac.ClusterRole) (*rbac.ClusterRole, error)
Watch(opts api.ListOptions) (watch.Interface, error)
}
// clusterRoles implements ClusterRolesNamespacer interface
type clusterRoles struct {
client *RbacClient
}
// newClusterRoles returns a clusterRoles
func newClusterRoles(c *RbacClient) *clusterRoles {
return &clusterRoles{
client: c,
}
}
// List takes label and field selectors, and returns the list of clusterRoles that match those selectors.
func (c *clusterRoles) List(opts api.ListOptions) (result *rbac.ClusterRoleList, err error) {
result = &rbac.ClusterRoleList{}
err = c.client.Get().Resource("clusterroles").VersionedParams(&opts, api.ParameterCodec).Do().Into(result)
return
}
// Get takes the name of the clusterRole, and returns the corresponding ClusterRole object, and an error if it occurs
func (c *clusterRoles) Get(name string) (result *rbac.ClusterRole, err error) {
result = &rbac.ClusterRole{}
err = c.client.Get().Resource("clusterroles").Name(name).Do().Into(result)
return
}
// Delete takes the name of the clusterRole and deletes it. Returns an error if one occurs.
func (c *clusterRoles) Delete(name string, options *api.DeleteOptions) error {
return c.client.Delete().Resource("clusterroles").Name(name).Body(options).Do().Error()
}
// Create takes the representation of a clusterRole and creates it. Returns the server's representation of the clusterRole, and an error, if it occurs.
func (c *clusterRoles) Create(clusterRole *rbac.ClusterRole) (result *rbac.ClusterRole, err error) {
result = &rbac.ClusterRole{}
err = c.client.Post().Resource("clusterroles").Body(clusterRole).Do().Into(result)
return
}
// Update takes the representation of a clusterRole and updates it. Returns the server's representation of the clusterRole, and an error, if it occurs.
func (c *clusterRoles) Update(clusterRole *rbac.ClusterRole) (result *rbac.ClusterRole, err error) {
result = &rbac.ClusterRole{}
err = c.client.Put().Resource("clusterroles").Name(clusterRole.Name).Body(clusterRole).Do().Into(result)
return
}
// Watch returns a watch.Interface that watches the requested clusterRoles.
func (c *clusterRoles) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.client.Get().
Prefix("watch").
Resource("clusterroles").
VersionedParams(&opts, api.ParameterCodec).
Watch()
}

View file

@ -45,6 +45,9 @@ type deployments struct {
ns string
}
// Ensure statically that deployments implements DeploymentInterface.
var _ DeploymentInterface = &deployments{}
// newDeployments returns a Deployments
func newDeployments(c *ExtensionsClient, namespace string) *deployments {
return &deployments{

View file

@ -24,8 +24,6 @@ Most consumers should use the Config object to create a Client:
import (
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
)
[...]
@ -39,7 +37,7 @@ Most consumers should use the Config object to create a Client:
if err != nil {
// handle error
}
pods, err := client.Pods(api.NamespaceDefault).List(labels.Everything(), fields.Everything())
pods, err := client.Pods(api.NamespaceDefault).List(api.ListOptions{})
if err != nil {
// handle error
}

View file

@ -28,12 +28,12 @@ import (
// Features of Extensions group are not supported and may be changed or removed in
// incompatible ways at any time.
type ExtensionsInterface interface {
HorizontalPodAutoscalersNamespacer
ScaleNamespacer
DaemonSetsNamespacer
DeploymentsNamespacer
JobsNamespacer
IngressNamespacer
NetworkPolicyNamespacer
ThirdPartyResourceNamespacer
ReplicaSetsNamespacer
PodSecurityPoliciesInterface
@ -50,10 +50,6 @@ func (c *ExtensionsClient) PodSecurityPolicies() PodSecurityPolicyInterface {
return newPodSecurityPolicy(c)
}
func (c *ExtensionsClient) HorizontalPodAutoscalers(namespace string) HorizontalPodAutoscalerInterface {
return newHorizontalPodAutoscalers(c, namespace)
}
func (c *ExtensionsClient) Scales(namespace string) ScaleInterface {
return newScales(c, namespace)
}
@ -74,6 +70,10 @@ func (c *ExtensionsClient) Ingress(namespace string) IngressInterface {
return newIngress(c, namespace)
}
func (c *ExtensionsClient) NetworkPolicies(namespace string) NetworkPolicyInterface {
return newNetworkPolicies(c, namespace)
}
func (c *ExtensionsClient) ThirdPartyResources() ThirdPartyResourceInterface {
return newThirdPartyResources(c)
}

View file

@ -26,6 +26,8 @@ import (
"k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/policy"
"k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/client/typed/discovery"
"k8s.io/kubernetes/pkg/util/sets"
@ -85,6 +87,15 @@ func New(c *restclient.Config) (*Client, error) {
return nil, err
}
}
var policyClient *PolicyClient
if registered.IsRegistered(policy.GroupName) {
policyConfig := *c
policyClient, err = NewPolicy(&policyConfig)
if err != nil {
return nil, err
}
}
var appsClient *AppsClient
if registered.IsRegistered(apps.GroupName) {
appsConfig := *c
@ -94,7 +105,16 @@ func New(c *restclient.Config) (*Client, error) {
}
}
return &Client{RESTClient: client, AutoscalingClient: autoscalingClient, BatchClient: batchClient, ExtensionsClient: extensionsClient, DiscoveryClient: discoveryClient, AppsClient: appsClient}, nil
var rbacClient *RbacClient
if registered.IsRegistered(rbac.GroupName) {
rbacConfig := *c
rbacClient, err = NewRbac(&rbacConfig)
if err != nil {
return nil, err
}
}
return &Client{RESTClient: client, AutoscalingClient: autoscalingClient, BatchClient: batchClient, ExtensionsClient: extensionsClient, DiscoveryClient: discoveryClient, AppsClient: appsClient, PolicyClient: policyClient, RbacClient: rbacClient}, nil
}
// MatchesServerVersion queries the server to compares the build version

View file

@ -18,7 +18,7 @@ package unversioned
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/watch"
)
@ -29,23 +29,23 @@ type HorizontalPodAutoscalersNamespacer interface {
// HorizontalPodAutoscalerInterface has methods to work with HorizontalPodAutoscaler resources.
type HorizontalPodAutoscalerInterface interface {
List(opts api.ListOptions) (*extensions.HorizontalPodAutoscalerList, error)
Get(name string) (*extensions.HorizontalPodAutoscaler, error)
List(opts api.ListOptions) (*autoscaling.HorizontalPodAutoscalerList, error)
Get(name string) (*autoscaling.HorizontalPodAutoscaler, error)
Delete(name string, options *api.DeleteOptions) error
Create(horizontalPodAutoscaler *extensions.HorizontalPodAutoscaler) (*extensions.HorizontalPodAutoscaler, error)
Update(horizontalPodAutoscaler *extensions.HorizontalPodAutoscaler) (*extensions.HorizontalPodAutoscaler, error)
UpdateStatus(horizontalPodAutoscaler *extensions.HorizontalPodAutoscaler) (*extensions.HorizontalPodAutoscaler, error)
Create(horizontalPodAutoscaler *autoscaling.HorizontalPodAutoscaler) (*autoscaling.HorizontalPodAutoscaler, error)
Update(horizontalPodAutoscaler *autoscaling.HorizontalPodAutoscaler) (*autoscaling.HorizontalPodAutoscaler, error)
UpdateStatus(horizontalPodAutoscaler *autoscaling.HorizontalPodAutoscaler) (*autoscaling.HorizontalPodAutoscaler, error)
Watch(opts api.ListOptions) (watch.Interface, error)
}
// horizontalPodAutoscalers implements HorizontalPodAutoscalersNamespacer interface
// horizontalPodAutoscalers implements HorizontalPodAutoscalersNamespacer interface using AutoscalingClient internally
type horizontalPodAutoscalers struct {
client *ExtensionsClient
client *AutoscalingClient
ns string
}
// newHorizontalPodAutoscalers returns a horizontalPodAutoscalers
func newHorizontalPodAutoscalers(c *ExtensionsClient, namespace string) *horizontalPodAutoscalers {
func newHorizontalPodAutoscalers(c *AutoscalingClient, namespace string) *horizontalPodAutoscalers {
return &horizontalPodAutoscalers{
client: c,
ns: namespace,
@ -53,15 +53,15 @@ func newHorizontalPodAutoscalers(c *ExtensionsClient, namespace string) *horizon
}
// List takes label and field selectors, and returns the list of horizontalPodAutoscalers that match those selectors.
func (c *horizontalPodAutoscalers) List(opts api.ListOptions) (result *extensions.HorizontalPodAutoscalerList, err error) {
result = &extensions.HorizontalPodAutoscalerList{}
func (c *horizontalPodAutoscalers) List(opts api.ListOptions) (result *autoscaling.HorizontalPodAutoscalerList, err error) {
result = &autoscaling.HorizontalPodAutoscalerList{}
err = c.client.Get().Namespace(c.ns).Resource("horizontalPodAutoscalers").VersionedParams(&opts, api.ParameterCodec).Do().Into(result)
return
}
// Get takes the name of the horizontalPodAutoscaler, and returns the corresponding HorizontalPodAutoscaler object, and an error if it occurs
func (c *horizontalPodAutoscalers) Get(name string) (result *extensions.HorizontalPodAutoscaler, err error) {
result = &extensions.HorizontalPodAutoscaler{}
func (c *horizontalPodAutoscalers) Get(name string) (result *autoscaling.HorizontalPodAutoscaler, err error) {
result = &autoscaling.HorizontalPodAutoscaler{}
err = c.client.Get().Namespace(c.ns).Resource("horizontalPodAutoscalers").Name(name).Do().Into(result)
return
}
@ -72,22 +72,22 @@ func (c *horizontalPodAutoscalers) Delete(name string, options *api.DeleteOption
}
// Create takes the representation of a horizontalPodAutoscaler and creates it. Returns the server's representation of the horizontalPodAutoscaler, and an error, if it occurs.
func (c *horizontalPodAutoscalers) Create(horizontalPodAutoscaler *extensions.HorizontalPodAutoscaler) (result *extensions.HorizontalPodAutoscaler, err error) {
result = &extensions.HorizontalPodAutoscaler{}
func (c *horizontalPodAutoscalers) Create(horizontalPodAutoscaler *autoscaling.HorizontalPodAutoscaler) (result *autoscaling.HorizontalPodAutoscaler, err error) {
result = &autoscaling.HorizontalPodAutoscaler{}
err = c.client.Post().Namespace(c.ns).Resource("horizontalPodAutoscalers").Body(horizontalPodAutoscaler).Do().Into(result)
return
}
// Update takes the representation of a horizontalPodAutoscaler and updates it. Returns the server's representation of the horizontalPodAutoscaler, and an error, if it occurs.
func (c *horizontalPodAutoscalers) Update(horizontalPodAutoscaler *extensions.HorizontalPodAutoscaler) (result *extensions.HorizontalPodAutoscaler, err error) {
result = &extensions.HorizontalPodAutoscaler{}
func (c *horizontalPodAutoscalers) Update(horizontalPodAutoscaler *autoscaling.HorizontalPodAutoscaler) (result *autoscaling.HorizontalPodAutoscaler, err error) {
result = &autoscaling.HorizontalPodAutoscaler{}
err = c.client.Put().Namespace(c.ns).Resource("horizontalPodAutoscalers").Name(horizontalPodAutoscaler.Name).Body(horizontalPodAutoscaler).Do().Into(result)
return
}
// UpdateStatus takes the representation of a horizontalPodAutoscaler and updates it. Returns the server's representation of the horizontalPodAutoscaler, and an error, if it occurs.
func (c *horizontalPodAutoscalers) UpdateStatus(horizontalPodAutoscaler *extensions.HorizontalPodAutoscaler) (result *extensions.HorizontalPodAutoscaler, err error) {
result = &extensions.HorizontalPodAutoscaler{}
func (c *horizontalPodAutoscalers) UpdateStatus(horizontalPodAutoscaler *autoscaling.HorizontalPodAutoscaler) (result *autoscaling.HorizontalPodAutoscaler, err error) {
result = &autoscaling.HorizontalPodAutoscaler{}
err = c.client.Put().Namespace(c.ns).Resource("horizontalPodAutoscalers").Name(horizontalPodAutoscaler.Name).SubResource("status").Body(horizontalPodAutoscaler).Do().Into(result)
return
}
@ -101,68 +101,3 @@ func (c *horizontalPodAutoscalers) Watch(opts api.ListOptions) (watch.Interface,
VersionedParams(&opts, api.ParameterCodec).
Watch()
}
// horizontalPodAutoscalersV1 implements HorizontalPodAutoscalersNamespacer interface using AutoscalingClient internally
// TODO(piosz): get back to one client implementation once HPA will be graduated to GA completely
type horizontalPodAutoscalersV1 struct {
client *AutoscalingClient
ns string
}
// newHorizontalPodAutoscalers returns a horizontalPodAutoscalers
func newHorizontalPodAutoscalersV1(c *AutoscalingClient, namespace string) *horizontalPodAutoscalersV1 {
return &horizontalPodAutoscalersV1{
client: c,
ns: namespace,
}
}
// List takes label and field selectors, and returns the list of horizontalPodAutoscalers that match those selectors.
func (c *horizontalPodAutoscalersV1) List(opts api.ListOptions) (result *extensions.HorizontalPodAutoscalerList, err error) {
result = &extensions.HorizontalPodAutoscalerList{}
err = c.client.Get().Namespace(c.ns).Resource("horizontalPodAutoscalers").VersionedParams(&opts, api.ParameterCodec).Do().Into(result)
return
}
// Get takes the name of the horizontalPodAutoscaler, and returns the corresponding HorizontalPodAutoscaler object, and an error if it occurs
func (c *horizontalPodAutoscalersV1) Get(name string) (result *extensions.HorizontalPodAutoscaler, err error) {
result = &extensions.HorizontalPodAutoscaler{}
err = c.client.Get().Namespace(c.ns).Resource("horizontalPodAutoscalers").Name(name).Do().Into(result)
return
}
// Delete takes the name of the horizontalPodAutoscaler and deletes it. Returns an error if one occurs.
func (c *horizontalPodAutoscalersV1) Delete(name string, options *api.DeleteOptions) error {
return c.client.Delete().Namespace(c.ns).Resource("horizontalPodAutoscalers").Name(name).Body(options).Do().Error()
}
// Create takes the representation of a horizontalPodAutoscaler and creates it. Returns the server's representation of the horizontalPodAutoscaler, and an error, if it occurs.
func (c *horizontalPodAutoscalersV1) Create(horizontalPodAutoscaler *extensions.HorizontalPodAutoscaler) (result *extensions.HorizontalPodAutoscaler, err error) {
result = &extensions.HorizontalPodAutoscaler{}
err = c.client.Post().Namespace(c.ns).Resource("horizontalPodAutoscalers").Body(horizontalPodAutoscaler).Do().Into(result)
return
}
// Update takes the representation of a horizontalPodAutoscaler and updates it. Returns the server's representation of the horizontalPodAutoscaler, and an error, if it occurs.
func (c *horizontalPodAutoscalersV1) Update(horizontalPodAutoscaler *extensions.HorizontalPodAutoscaler) (result *extensions.HorizontalPodAutoscaler, err error) {
result = &extensions.HorizontalPodAutoscaler{}
err = c.client.Put().Namespace(c.ns).Resource("horizontalPodAutoscalers").Name(horizontalPodAutoscaler.Name).Body(horizontalPodAutoscaler).Do().Into(result)
return
}
// UpdateStatus takes the representation of a horizontalPodAutoscaler and updates it. Returns the server's representation of the horizontalPodAutoscaler, and an error, if it occurs.
func (c *horizontalPodAutoscalersV1) UpdateStatus(horizontalPodAutoscaler *extensions.HorizontalPodAutoscaler) (result *extensions.HorizontalPodAutoscaler, err error) {
result = &extensions.HorizontalPodAutoscaler{}
err = c.client.Put().Namespace(c.ns).Resource("horizontalPodAutoscalers").Name(horizontalPodAutoscaler.Name).SubResource("status").Body(horizontalPodAutoscaler).Do().Into(result)
return
}
// Watch returns a watch.Interface that watches the requested horizontalPodAutoscalers.
func (c *horizontalPodAutoscalersV1) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.client.Get().
Prefix("watch").
Namespace(c.ns).
Resource("horizontalPodAutoscalers").
VersionedParams(&opts, api.ParameterCodec).
Watch()
}

View file

@ -23,13 +23,14 @@ import (
_ "k8s.io/kubernetes/pkg/api/install"
"k8s.io/kubernetes/pkg/apimachinery/registered"
_ "k8s.io/kubernetes/pkg/apis/apps/install"
_ "k8s.io/kubernetes/pkg/apis/authentication.k8s.io/install"
_ "k8s.io/kubernetes/pkg/apis/authorization/install"
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
_ "k8s.io/kubernetes/pkg/apis/batch/install"
_ "k8s.io/kubernetes/pkg/apis/componentconfig/install"
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
_ "k8s.io/kubernetes/pkg/apis/metrics/install"
_ "k8s.io/kubernetes/pkg/apis/policy/install"
_ "k8s.io/kubernetes/pkg/apis/rbac/install"
)
func init() {

View file

@ -0,0 +1,92 @@
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
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.
*/
package unversioned
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/watch"
)
// NetworkPolicyNamespacer has methods to work with NetworkPolicy resources in a namespace
type NetworkPolicyNamespacer interface {
NetworkPolicies(namespace string) NetworkPolicyInterface
}
// NetworkPolicyInterface exposes methods to work on NetworkPolicy resources.
type NetworkPolicyInterface interface {
List(opts api.ListOptions) (*extensions.NetworkPolicyList, error)
Get(name string) (*extensions.NetworkPolicy, error)
Create(networkPolicy *extensions.NetworkPolicy) (*extensions.NetworkPolicy, error)
Update(networkPolicy *extensions.NetworkPolicy) (*extensions.NetworkPolicy, error)
Delete(name string, options *api.DeleteOptions) error
Watch(opts api.ListOptions) (watch.Interface, error)
}
// NetworkPolicies implements NetworkPolicyNamespacer interface
type NetworkPolicies struct {
r *ExtensionsClient
ns string
}
// newNetworkPolicies returns a NetworkPolicies
func newNetworkPolicies(c *ExtensionsClient, namespace string) *NetworkPolicies {
return &NetworkPolicies{c, namespace}
}
// List returns a list of networkPolicy that match the label and field selectors.
func (c *NetworkPolicies) List(opts api.ListOptions) (result *extensions.NetworkPolicyList, err error) {
result = &extensions.NetworkPolicyList{}
err = c.r.Get().Namespace(c.ns).Resource("networkpolicies").VersionedParams(&opts, api.ParameterCodec).Do().Into(result)
return
}
// Get returns information about a particular networkPolicy.
func (c *NetworkPolicies) Get(name string) (result *extensions.NetworkPolicy, err error) {
result = &extensions.NetworkPolicy{}
err = c.r.Get().Namespace(c.ns).Resource("networkpolicies").Name(name).Do().Into(result)
return
}
// Create creates a new networkPolicy.
func (c *NetworkPolicies) Create(networkPolicy *extensions.NetworkPolicy) (result *extensions.NetworkPolicy, err error) {
result = &extensions.NetworkPolicy{}
err = c.r.Post().Namespace(c.ns).Resource("networkpolicies").Body(networkPolicy).Do().Into(result)
return
}
// Update updates an existing networkPolicy.
func (c *NetworkPolicies) Update(networkPolicy *extensions.NetworkPolicy) (result *extensions.NetworkPolicy, err error) {
result = &extensions.NetworkPolicy{}
err = c.r.Put().Namespace(c.ns).Resource("networkpolicies").Name(networkPolicy.Name).Body(networkPolicy).Do().Into(result)
return
}
// Delete deletes a networkPolicy, returns error if one occurs.
func (c *NetworkPolicies) Delete(name string, options *api.DeleteOptions) (err error) {
return c.r.Delete().Namespace(c.ns).Resource("networkpolicies").Name(name).Body(options).Do().Error()
}
// Watch returns a watch.Interface that watches the requested networkPolicy.
func (c *NetworkPolicies) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.r.Get().
Prefix("watch").
Namespace(c.ns).
Resource("networkpolicies").
VersionedParams(&opts, api.ParameterCodec).
Watch()
}

View file

@ -0,0 +1,100 @@
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
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.
*/
package unversioned
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/policy"
"k8s.io/kubernetes/pkg/watch"
)
// PodDisruptionBudgetNamespacer has methods to work with PodDisruptionBudget resources in a namespace
type PodDisruptionBudgetNamespacer interface {
PodDisruptionBudgets(namespace string) PodDisruptionBudgetInterface
}
// PodDisruptionBudgetInterface exposes methods to work on PodDisruptionBudget resources.
type PodDisruptionBudgetInterface interface {
List(opts api.ListOptions) (*policy.PodDisruptionBudgetList, error)
Get(name string) (*policy.PodDisruptionBudget, error)
Create(podDisruptionBudget *policy.PodDisruptionBudget) (*policy.PodDisruptionBudget, error)
Update(podDisruptionBudget *policy.PodDisruptionBudget) (*policy.PodDisruptionBudget, error)
Delete(name string, options *api.DeleteOptions) error
Watch(opts api.ListOptions) (watch.Interface, error)
UpdateStatus(podDisruptionBudget *policy.PodDisruptionBudget) (*policy.PodDisruptionBudget, error)
}
// podDisruptionBudget implements PodDisruptionBudgetNamespacer interface
type podDisruptionBudget struct {
r *PolicyClient
ns string
}
// newPodDisruptionBudget returns a podDisruptionBudget
func newPodDisruptionBudget(c *PolicyClient, namespace string) *podDisruptionBudget {
return &podDisruptionBudget{c, namespace}
}
// List returns a list of podDisruptionBudget that match the label and field selectors.
func (c *podDisruptionBudget) List(opts api.ListOptions) (result *policy.PodDisruptionBudgetList, err error) {
result = &policy.PodDisruptionBudgetList{}
err = c.r.Get().Namespace(c.ns).Resource("poddisruptionbudgets").VersionedParams(&opts, api.ParameterCodec).Do().Into(result)
return
}
// Get returns information about a particular podDisruptionBudget.
func (c *podDisruptionBudget) Get(name string) (result *policy.PodDisruptionBudget, err error) {
result = &policy.PodDisruptionBudget{}
err = c.r.Get().Namespace(c.ns).Resource("poddisruptionbudgets").Name(name).Do().Into(result)
return
}
// Create creates a new podDisruptionBudget.
func (c *podDisruptionBudget) Create(podDisruptionBudget *policy.PodDisruptionBudget) (result *policy.PodDisruptionBudget, err error) {
result = &policy.PodDisruptionBudget{}
err = c.r.Post().Namespace(c.ns).Resource("poddisruptionbudgets").Body(podDisruptionBudget).Do().Into(result)
return
}
// Update updates an existing podDisruptionBudget.
func (c *podDisruptionBudget) Update(podDisruptionBudget *policy.PodDisruptionBudget) (result *policy.PodDisruptionBudget, err error) {
result = &policy.PodDisruptionBudget{}
err = c.r.Put().Namespace(c.ns).Resource("poddisruptionbudgets").Name(podDisruptionBudget.Name).Body(podDisruptionBudget).Do().Into(result)
return
}
// Delete deletes a podDisruptionBudget, returns error if one occurs.
func (c *podDisruptionBudget) Delete(name string, options *api.DeleteOptions) (err error) {
return c.r.Delete().Namespace(c.ns).Resource("poddisruptionbudgets").Name(name).Body(options).Do().Error()
}
// Watch returns a watch.Interface that watches the requested podDisruptionBudget.
func (c *podDisruptionBudget) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.r.Get().
Prefix("watch").
Namespace(c.ns).
Resource("poddisruptionbudgets").
VersionedParams(&opts, api.ParameterCodec).
Watch()
}
// UpdateStatus takes the name of the podDisruptionBudget and the new status. Returns the server's representation of the podDisruptionBudget, and an error, if it occurs.
func (c *podDisruptionBudget) UpdateStatus(podDisruptionBudget *policy.PodDisruptionBudget) (result *policy.PodDisruptionBudget, err error) {
result = &policy.PodDisruptionBudget{}
err = c.r.Put().Namespace(c.ns).Resource("poddisruptionbudgets").Name(podDisruptionBudget.Name).SubResource("status").Body(podDisruptionBudget).Do().Into(result)
return
}

View file

@ -28,7 +28,7 @@ type PodSecurityPoliciesInterface interface {
type PodSecurityPolicyInterface interface {
Get(name string) (result *extensions.PodSecurityPolicy, err error)
Create(scc *extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error)
Create(psp *extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error)
List(opts api.ListOptions) (*extensions.PodSecurityPolicyList, error)
Delete(name string) error
Update(*extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error)
@ -45,11 +45,11 @@ func newPodSecurityPolicy(c *ExtensionsClient) *podSecurityPolicy {
return &podSecurityPolicy{c}
}
func (s *podSecurityPolicy) Create(scc *extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error) {
func (s *podSecurityPolicy) Create(psp *extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error) {
result := &extensions.PodSecurityPolicy{}
err := s.client.Post().
Resource("podsecuritypolicies").
Body(scc).
Body(psp).
Do().
Into(result)

View file

@ -0,0 +1,83 @@
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
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.
*/
package unversioned
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/apis/policy"
"k8s.io/kubernetes/pkg/client/restclient"
)
type PolicyInterface interface {
PodDisruptionBudgetNamespacer
}
// PolicyClient is used to interact with Kubernetes batch features.
type PolicyClient struct {
*restclient.RESTClient
}
func (c *PolicyClient) PodDisruptionBudgets(namespace string) PodDisruptionBudgetInterface {
return newPodDisruptionBudget(c, namespace)
}
func NewPolicy(c *restclient.Config) (*PolicyClient, error) {
config := *c
if err := setPolicyDefaults(&config); err != nil {
return nil, err
}
client, err := restclient.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &PolicyClient{client}, nil
}
func NewPolicyOrDie(c *restclient.Config) *PolicyClient {
client, err := NewPolicy(c)
if err != nil {
panic(err)
}
return client
}
func setPolicyDefaults(config *restclient.Config) error {
g, err := registered.Group(policy.GroupName)
if err != nil {
return err
}
config.APIPath = defaultAPIPath
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.Codec = api.Codecs.LegacyCodec(*config.GroupVersion)
config.NegotiatedSerializer = api.Codecs
if config.QPS == 0 {
config.QPS = 5
}
if config.Burst == 0 {
config.Burst = 10
}
return nil
}

103
vendor/k8s.io/kubernetes/pkg/client/unversioned/rbac.go generated vendored Normal file
View file

@ -0,0 +1,103 @@
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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.
*/
package unversioned
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/client/restclient"
)
// Interface holds the methods for clients of Kubernetes to allow mock testing.
type RbacInterface interface {
RoleBindingsNamespacer
RolesNamespacer
ClusterRoleBindings
ClusterRoles
}
type RbacClient struct {
*restclient.RESTClient
}
func (c *RbacClient) RoleBindings(namespace string) RoleBindingInterface {
return newRoleBindings(c, namespace)
}
func (c *RbacClient) Roles(namespace string) RoleInterface {
return newRoles(c, namespace)
}
func (c *RbacClient) ClusterRoleBindings() ClusterRoleBindingInterface {
return newClusterRoleBindings(c)
}
func (c *RbacClient) ClusterRoles() ClusterRoleInterface {
return newClusterRoles(c)
}
// NewRbac creates a new RbacClient for the given config.
func NewRbac(c *restclient.Config) (*RbacClient, error) {
config := *c
if err := setRbacDefaults(&config); err != nil {
return nil, err
}
client, err := restclient.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &RbacClient{client}, nil
}
// NewRbacOrDie creates a new RbacClient for the given config and
// panics if there is an error in the config.
func NewRbacOrDie(c *restclient.Config) *RbacClient {
client, err := NewRbac(c)
if err != nil {
panic(err)
}
return client
}
func setRbacDefaults(config *restclient.Config) error {
// if rbac group is not registered, return an error
g, err := registered.Group(rbac.GroupName)
if err != nil {
return err
}
config.APIPath = defaultAPIPath
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.Codec = api.Codecs.LegacyCodec(*config.GroupVersion)
config.NegotiatedSerializer = api.Codecs
if config.QPS == 0 {
config.QPS = 5
}
if config.Burst == 0 {
config.Burst = 10
}
return nil
}

View file

@ -0,0 +1,95 @@
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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.
*/
package unversioned
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/watch"
)
// RoleBindingsNamespacer has methods to work with RoleBinding resources in a namespace
type RoleBindingsNamespacer interface {
RoleBindings(namespace string) RoleBindingInterface
}
// RoleBindingInterface has methods to work with RoleBinding resources.
type RoleBindingInterface interface {
List(opts api.ListOptions) (*rbac.RoleBindingList, error)
Get(name string) (*rbac.RoleBinding, error)
Delete(name string, options *api.DeleteOptions) error
Create(roleBinding *rbac.RoleBinding) (*rbac.RoleBinding, error)
Update(roleBinding *rbac.RoleBinding) (*rbac.RoleBinding, error)
Watch(opts api.ListOptions) (watch.Interface, error)
}
// roleBindings implements RoleBindingsNamespacer interface
type roleBindings struct {
client *RbacClient
ns string
}
// newRoleBindings returns a roleBindings
func newRoleBindings(c *RbacClient, namespace string) *roleBindings {
return &roleBindings{
client: c,
ns: namespace,
}
}
// List takes label and field selectors, and returns the list of roleBindings that match those selectors.
func (c *roleBindings) List(opts api.ListOptions) (result *rbac.RoleBindingList, err error) {
result = &rbac.RoleBindingList{}
err = c.client.Get().Namespace(c.ns).Resource("rolebindings").VersionedParams(&opts, api.ParameterCodec).Do().Into(result)
return
}
// Get takes the name of the roleBinding, and returns the corresponding RoleBinding object, and an error if it occurs
func (c *roleBindings) Get(name string) (result *rbac.RoleBinding, err error) {
result = &rbac.RoleBinding{}
err = c.client.Get().Namespace(c.ns).Resource("rolebindings").Name(name).Do().Into(result)
return
}
// Delete takes the name of the roleBinding and deletes it. Returns an error if one occurs.
func (c *roleBindings) Delete(name string, options *api.DeleteOptions) error {
return c.client.Delete().Namespace(c.ns).Resource("rolebindings").Name(name).Body(options).Do().Error()
}
// Create takes the representation of a roleBinding and creates it. Returns the server's representation of the roleBinding, and an error, if it occurs.
func (c *roleBindings) Create(roleBinding *rbac.RoleBinding) (result *rbac.RoleBinding, err error) {
result = &rbac.RoleBinding{}
err = c.client.Post().Namespace(c.ns).Resource("rolebindings").Body(roleBinding).Do().Into(result)
return
}
// Update takes the representation of a roleBinding and updates it. Returns the server's representation of the roleBinding, and an error, if it occurs.
func (c *roleBindings) Update(roleBinding *rbac.RoleBinding) (result *rbac.RoleBinding, err error) {
result = &rbac.RoleBinding{}
err = c.client.Put().Namespace(c.ns).Resource("rolebindings").Name(roleBinding.Name).Body(roleBinding).Do().Into(result)
return
}
// Watch returns a watch.Interface that watches the requested roleBindings.
func (c *roleBindings) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.client.Get().
Prefix("watch").
Namespace(c.ns).
Resource("rolebindings").
VersionedParams(&opts, api.ParameterCodec).
Watch()
}

View file

@ -0,0 +1,95 @@
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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.
*/
package unversioned
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/watch"
)
// RolesNamespacer has methods to work with Role resources in a namespace
type RolesNamespacer interface {
Roles(namespace string) RoleInterface
}
// RoleInterface has methods to work with Role resources.
type RoleInterface interface {
List(opts api.ListOptions) (*rbac.RoleList, error)
Get(name string) (*rbac.Role, error)
Delete(name string, options *api.DeleteOptions) error
Create(role *rbac.Role) (*rbac.Role, error)
Update(role *rbac.Role) (*rbac.Role, error)
Watch(opts api.ListOptions) (watch.Interface, error)
}
// roles implements RolesNamespacer interface
type roles struct {
client *RbacClient
ns string
}
// newRoles returns a roles
func newRoles(c *RbacClient, namespace string) *roles {
return &roles{
client: c,
ns: namespace,
}
}
// List takes label and field selectors, and returns the list of roles that match those selectors.
func (c *roles) List(opts api.ListOptions) (result *rbac.RoleList, err error) {
result = &rbac.RoleList{}
err = c.client.Get().Namespace(c.ns).Resource("roles").VersionedParams(&opts, api.ParameterCodec).Do().Into(result)
return
}
// Get takes the name of the role, and returns the corresponding Role object, and an error if it occurs
func (c *roles) Get(name string) (result *rbac.Role, err error) {
result = &rbac.Role{}
err = c.client.Get().Namespace(c.ns).Resource("roles").Name(name).Do().Into(result)
return
}
// Delete takes the name of the role and deletes it. Returns an error if one occurs.
func (c *roles) Delete(name string, options *api.DeleteOptions) error {
return c.client.Delete().Namespace(c.ns).Resource("roles").Name(name).Body(options).Do().Error()
}
// Create takes the representation of a role and creates it. Returns the server's representation of the role, and an error, if it occurs.
func (c *roles) Create(role *rbac.Role) (result *rbac.Role, err error) {
result = &rbac.Role{}
err = c.client.Post().Namespace(c.ns).Resource("roles").Body(role).Do().Into(result)
return
}
// Update takes the representation of a role and updates it. Returns the server's representation of the role, and an error, if it occurs.
func (c *roles) Update(role *rbac.Role) (result *rbac.Role, err error) {
result = &rbac.Role{}
err = c.client.Put().Namespace(c.ns).Resource("roles").Name(role.Name).Body(role).Do().Into(result)
return
}
// Watch returns a watch.Interface that watches the requested roles.
func (c *roles) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.client.Get().
Prefix("watch").
Namespace(c.ns).
Resource("roles").
VersionedParams(&opts, api.ParameterCodec).
Watch()
}

View file

@ -0,0 +1,103 @@
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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.
*/
package unversioned
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/watch"
)
// ScheduledJobsNamespacer has methods to work with ScheduledJob resources in a namespace
type ScheduledJobsNamespacer interface {
ScheduledJobs(namespace string) ScheduledJobInterface
}
// ScheduledJobInterface exposes methods to work on ScheduledJob resources.
type ScheduledJobInterface interface {
List(opts api.ListOptions) (*batch.ScheduledJobList, error)
Get(name string) (*batch.ScheduledJob, error)
Create(scheduledJob *batch.ScheduledJob) (*batch.ScheduledJob, error)
Update(scheduledJob *batch.ScheduledJob) (*batch.ScheduledJob, error)
Delete(name string, options *api.DeleteOptions) error
Watch(opts api.ListOptions) (watch.Interface, error)
UpdateStatus(scheduledJob *batch.ScheduledJob) (*batch.ScheduledJob, error)
}
// scheduledJobs implements ScheduledJobsNamespacer interface
type scheduledJobs struct {
r *BatchClient
ns string
}
// newScheduledJobs returns a scheduledJobs
func newScheduledJobs(c *BatchClient, namespace string) *scheduledJobs {
return &scheduledJobs{c, namespace}
}
// Ensure statically that scheduledJobs implements ScheduledJobInterface.
var _ ScheduledJobInterface = &scheduledJobs{}
// List returns a list of scheduled jobs that match the label and field selectors.
func (c *scheduledJobs) List(opts api.ListOptions) (result *batch.ScheduledJobList, err error) {
result = &batch.ScheduledJobList{}
err = c.r.Get().Namespace(c.ns).Resource("scheduledJobs").VersionedParams(&opts, api.ParameterCodec).Do().Into(result)
return
}
// Get returns information about a particular scheduled job.
func (c *scheduledJobs) Get(name string) (result *batch.ScheduledJob, err error) {
result = &batch.ScheduledJob{}
err = c.r.Get().Namespace(c.ns).Resource("scheduledJobs").Name(name).Do().Into(result)
return
}
// Create creates a new scheduled job.
func (c *scheduledJobs) Create(job *batch.ScheduledJob) (result *batch.ScheduledJob, err error) {
result = &batch.ScheduledJob{}
err = c.r.Post().Namespace(c.ns).Resource("scheduledJobs").Body(job).Do().Into(result)
return
}
// Update updates an existing scheduled job.
func (c *scheduledJobs) Update(job *batch.ScheduledJob) (result *batch.ScheduledJob, err error) {
result = &batch.ScheduledJob{}
err = c.r.Put().Namespace(c.ns).Resource("scheduledJobs").Name(job.Name).Body(job).Do().Into(result)
return
}
// Delete deletes a scheduled job, returns error if one occurs.
func (c *scheduledJobs) Delete(name string, options *api.DeleteOptions) (err error) {
return c.r.Delete().Namespace(c.ns).Resource("scheduledJobs").Name(name).Body(options).Do().Error()
}
// Watch returns a watch.Interface that watches the requested scheduled jobs.
func (c *scheduledJobs) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.r.Get().
Prefix("watch").
Namespace(c.ns).
Resource("scheduledJobs").
VersionedParams(&opts, api.ParameterCodec).
Watch()
}
// UpdateStatus takes the name of the scheduled job and the new status. Returns the server's representation of the scheduled job, and an error, if it occurs.
func (c *scheduledJobs) UpdateStatus(job *batch.ScheduledJob) (result *batch.ScheduledJob, err error) {
result = &batch.ScheduledJob{}
err = c.r.Put().Namespace(c.ns).Resource("scheduledJobs").Name(job.Name).SubResource("status").Body(job).Do().Into(result)
return
}

View file

@ -0,0 +1,73 @@
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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.
*/
package testclient
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/watch"
)
// FakeClusterRoleBindings implements ClusterRoleBindingInterface
type FakeClusterRoleBindings struct {
Fake *FakeRbac
}
func (c *FakeClusterRoleBindings) Get(name string) (*rbac.ClusterRoleBinding, error) {
obj, err := c.Fake.Invokes(NewRootGetAction("clusterrolebindings", name), &rbac.ClusterRoleBinding{})
if obj == nil {
return nil, err
}
return obj.(*rbac.ClusterRoleBinding), err
}
func (c *FakeClusterRoleBindings) List(opts api.ListOptions) (*rbac.ClusterRoleBindingList, error) {
obj, err := c.Fake.Invokes(NewRootListAction("clusterrolebindings", opts), &rbac.ClusterRoleBindingList{})
if obj == nil {
return nil, err
}
return obj.(*rbac.ClusterRoleBindingList), err
}
func (c *FakeClusterRoleBindings) Create(csr *rbac.ClusterRoleBinding) (*rbac.ClusterRoleBinding, error) {
obj, err := c.Fake.Invokes(NewRootCreateAction("clusterrolebindings", csr), csr)
if obj == nil {
return nil, err
}
return obj.(*rbac.ClusterRoleBinding), err
}
func (c *FakeClusterRoleBindings) Update(csr *rbac.ClusterRoleBinding) (*rbac.ClusterRoleBinding, error) {
obj, err := c.Fake.Invokes(NewRootUpdateAction("clusterrolebindings", csr), csr)
if obj == nil {
return nil, err
}
return obj.(*rbac.ClusterRoleBinding), err
}
func (c *FakeClusterRoleBindings) Delete(name string, opts *api.DeleteOptions) error {
_, err := c.Fake.Invokes(NewRootDeleteAction("clusterrolebindings", name), &rbac.ClusterRoleBinding{})
return err
}
func (c *FakeClusterRoleBindings) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.Fake.InvokesWatch(NewRootWatchAction("clusterrolebindings", opts))
}

View file

@ -0,0 +1,73 @@
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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.
*/
package testclient
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/watch"
)
// FakeClusterRoles implements ClusterRoleInterface
type FakeClusterRoles struct {
Fake *FakeRbac
}
func (c *FakeClusterRoles) Get(name string) (*rbac.ClusterRole, error) {
obj, err := c.Fake.Invokes(NewRootGetAction("clusterroles", name), &rbac.ClusterRole{})
if obj == nil {
return nil, err
}
return obj.(*rbac.ClusterRole), err
}
func (c *FakeClusterRoles) List(opts api.ListOptions) (*rbac.ClusterRoleList, error) {
obj, err := c.Fake.Invokes(NewRootListAction("clusterroles", opts), &rbac.ClusterRoleList{})
if obj == nil {
return nil, err
}
return obj.(*rbac.ClusterRoleList), err
}
func (c *FakeClusterRoles) Create(csr *rbac.ClusterRole) (*rbac.ClusterRole, error) {
obj, err := c.Fake.Invokes(NewRootCreateAction("clusterroles", csr), csr)
if obj == nil {
return nil, err
}
return obj.(*rbac.ClusterRole), err
}
func (c *FakeClusterRoles) Update(csr *rbac.ClusterRole) (*rbac.ClusterRole, error) {
obj, err := c.Fake.Invokes(NewRootUpdateAction("clusterroles", csr), csr)
if obj == nil {
return nil, err
}
return obj.(*rbac.ClusterRole), err
}
func (c *FakeClusterRoles) Delete(name string, opts *api.DeleteOptions) error {
_, err := c.Fake.Invokes(NewRootDeleteAction("clusterroles", name), &rbac.ClusterRole{})
return err
}
func (c *FakeClusterRoles) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.Fake.InvokesWatch(NewRootWatchAction("clusterroles", opts))
}

View file

@ -19,17 +19,21 @@ package testclient
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/extensions"
kclientlib "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
)
// FakeDeployments implements DeploymentsInterface. Meant to be embedded into a struct to get a default
// FakeDeployments implements DeploymentInterface. Meant to be embedded into a struct to get a default
// implementation. This makes faking out just the methods you want to test easier.
type FakeDeployments struct {
Fake *FakeExperimental
Namespace string
}
// Ensure statically that FakeDeployments implements DeploymentInterface.
var _ kclientlib.DeploymentInterface = &FakeDeployments{}
func (c *FakeDeployments) Get(name string) (*extensions.Deployment, error) {
obj, err := c.Fake.Invokes(NewGetAction("deployments", c.Namespace, name), &extensions.Deployment{})
if obj == nil {

View file

@ -18,7 +18,7 @@ package testclient
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
)
@ -26,21 +26,21 @@ import (
// FakeHorizontalPodAutoscalers implements HorizontalPodAutoscalerInterface. Meant to be embedded into a struct to get a default
// implementation. This makes faking out just the methods you want to test easier.
type FakeHorizontalPodAutoscalers struct {
Fake *FakeExperimental
Fake *FakeAutoscaling
Namespace string
}
func (c *FakeHorizontalPodAutoscalers) Get(name string) (*extensions.HorizontalPodAutoscaler, error) {
obj, err := c.Fake.Invokes(NewGetAction("horizontalpodautoscalers", c.Namespace, name), &extensions.HorizontalPodAutoscaler{})
func (c *FakeHorizontalPodAutoscalers) Get(name string) (*autoscaling.HorizontalPodAutoscaler, error) {
obj, err := c.Fake.Invokes(NewGetAction("horizontalpodautoscalers", c.Namespace, name), &autoscaling.HorizontalPodAutoscaler{})
if obj == nil {
return nil, err
}
return obj.(*extensions.HorizontalPodAutoscaler), err
return obj.(*autoscaling.HorizontalPodAutoscaler), err
}
func (c *FakeHorizontalPodAutoscalers) List(opts api.ListOptions) (*extensions.HorizontalPodAutoscalerList, error) {
obj, err := c.Fake.Invokes(NewListAction("horizontalpodautoscalers", c.Namespace, opts), &extensions.HorizontalPodAutoscalerList{})
func (c *FakeHorizontalPodAutoscalers) List(opts api.ListOptions) (*autoscaling.HorizontalPodAutoscalerList, error) {
obj, err := c.Fake.Invokes(NewListAction("horizontalpodautoscalers", c.Namespace, opts), &autoscaling.HorizontalPodAutoscalerList{})
if obj == nil {
return nil, err
}
@ -48,8 +48,8 @@ func (c *FakeHorizontalPodAutoscalers) List(opts api.ListOptions) (*extensions.H
if label == nil {
label = labels.Everything()
}
list := &extensions.HorizontalPodAutoscalerList{}
for _, a := range obj.(*extensions.HorizontalPodAutoscalerList).Items {
list := &autoscaling.HorizontalPodAutoscalerList{}
for _, a := range obj.(*autoscaling.HorizontalPodAutoscalerList).Items {
if label.Matches(labels.Set(a.Labels)) {
list.Items = append(list.Items, a)
}
@ -57,108 +57,37 @@ func (c *FakeHorizontalPodAutoscalers) List(opts api.ListOptions) (*extensions.H
return list, err
}
func (c *FakeHorizontalPodAutoscalers) Create(a *extensions.HorizontalPodAutoscaler) (*extensions.HorizontalPodAutoscaler, error) {
func (c *FakeHorizontalPodAutoscalers) Create(a *autoscaling.HorizontalPodAutoscaler) (*autoscaling.HorizontalPodAutoscaler, error) {
obj, err := c.Fake.Invokes(NewCreateAction("horizontalpodautoscalers", c.Namespace, a), a)
if obj == nil {
return nil, err
}
return obj.(*extensions.HorizontalPodAutoscaler), err
return obj.(*autoscaling.HorizontalPodAutoscaler), err
}
func (c *FakeHorizontalPodAutoscalers) Update(a *extensions.HorizontalPodAutoscaler) (*extensions.HorizontalPodAutoscaler, error) {
func (c *FakeHorizontalPodAutoscalers) Update(a *autoscaling.HorizontalPodAutoscaler) (*autoscaling.HorizontalPodAutoscaler, error) {
obj, err := c.Fake.Invokes(NewUpdateAction("horizontalpodautoscalers", c.Namespace, a), a)
if obj == nil {
return nil, err
}
return obj.(*extensions.HorizontalPodAutoscaler), err
return obj.(*autoscaling.HorizontalPodAutoscaler), err
}
func (c *FakeHorizontalPodAutoscalers) UpdateStatus(a *extensions.HorizontalPodAutoscaler) (*extensions.HorizontalPodAutoscaler, error) {
obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("horizontalpodautoscalers", "status", c.Namespace, a), &extensions.HorizontalPodAutoscaler{})
func (c *FakeHorizontalPodAutoscalers) UpdateStatus(a *autoscaling.HorizontalPodAutoscaler) (*autoscaling.HorizontalPodAutoscaler, error) {
obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("horizontalpodautoscalers", "status", c.Namespace, a), &autoscaling.HorizontalPodAutoscaler{})
if obj == nil {
return nil, err
}
return obj.(*extensions.HorizontalPodAutoscaler), err
return obj.(*autoscaling.HorizontalPodAutoscaler), err
}
func (c *FakeHorizontalPodAutoscalers) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.Invokes(NewDeleteAction("horizontalpodautoscalers", c.Namespace, name), &extensions.HorizontalPodAutoscaler{})
_, err := c.Fake.Invokes(NewDeleteAction("horizontalpodautoscalers", c.Namespace, name), &autoscaling.HorizontalPodAutoscaler{})
return err
}
func (c *FakeHorizontalPodAutoscalers) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.Fake.InvokesWatch(NewWatchAction("horizontalpodautoscalers", c.Namespace, opts))
}
// FakeHorizontalPodAutoscalers implements HorizontalPodAutoscalerInterface. Meant to be embedded into a struct to get a default
// implementation. This makes faking out just the methods you want to test easier.
// This is a test implementation of HorizontalPodAutoscalersV1
// TODO(piosz): get back to one client implementation once HPA will be graduated to GA completely
type FakeHorizontalPodAutoscalersV1 struct {
Fake *FakeAutoscaling
Namespace string
}
func (c *FakeHorizontalPodAutoscalersV1) Get(name string) (*extensions.HorizontalPodAutoscaler, error) {
obj, err := c.Fake.Invokes(NewGetAction("horizontalpodautoscalers", c.Namespace, name), &extensions.HorizontalPodAutoscaler{})
if obj == nil {
return nil, err
}
return obj.(*extensions.HorizontalPodAutoscaler), err
}
func (c *FakeHorizontalPodAutoscalersV1) List(opts api.ListOptions) (*extensions.HorizontalPodAutoscalerList, error) {
obj, err := c.Fake.Invokes(NewListAction("horizontalpodautoscalers", c.Namespace, opts), &extensions.HorizontalPodAutoscalerList{})
if obj == nil {
return nil, err
}
label := opts.LabelSelector
if label == nil {
label = labels.Everything()
}
list := &extensions.HorizontalPodAutoscalerList{}
for _, a := range obj.(*extensions.HorizontalPodAutoscalerList).Items {
if label.Matches(labels.Set(a.Labels)) {
list.Items = append(list.Items, a)
}
}
return list, err
}
func (c *FakeHorizontalPodAutoscalersV1) Create(a *extensions.HorizontalPodAutoscaler) (*extensions.HorizontalPodAutoscaler, error) {
obj, err := c.Fake.Invokes(NewCreateAction("horizontalpodautoscalers", c.Namespace, a), a)
if obj == nil {
return nil, err
}
return obj.(*extensions.HorizontalPodAutoscaler), err
}
func (c *FakeHorizontalPodAutoscalersV1) Update(a *extensions.HorizontalPodAutoscaler) (*extensions.HorizontalPodAutoscaler, error) {
obj, err := c.Fake.Invokes(NewUpdateAction("horizontalpodautoscalers", c.Namespace, a), a)
if obj == nil {
return nil, err
}
return obj.(*extensions.HorizontalPodAutoscaler), err
}
func (c *FakeHorizontalPodAutoscalersV1) UpdateStatus(a *extensions.HorizontalPodAutoscaler) (*extensions.HorizontalPodAutoscaler, error) {
obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("horizontalpodautoscalers", "status", c.Namespace, a), &extensions.HorizontalPodAutoscaler{})
if obj == nil {
return nil, err
}
return obj.(*extensions.HorizontalPodAutoscaler), err
}
func (c *FakeHorizontalPodAutoscalersV1) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.Invokes(NewDeleteAction("horizontalpodautoscalers", c.Namespace, name), &extensions.HorizontalPodAutoscaler{})
return err
}
func (c *FakeHorizontalPodAutoscalersV1) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.Fake.InvokesWatch(NewWatchAction("horizontalpodautoscalers", c.Namespace, opts))
}

View file

@ -0,0 +1,75 @@
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
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.
*/
package testclient
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/extensions"
kclientlib "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
// FakeNetworkPolicies implements NetworkPolicyInterface. 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 FakeNetworkPolicies struct {
Fake *FakeExperimental
Namespace string
}
// Ensure statically that FakeNetworkPolicies implements NetworkPolicyInterface.
var _ kclientlib.NetworkPolicyInterface = &FakeNetworkPolicies{}
func (c *FakeNetworkPolicies) Get(name string) (*extensions.NetworkPolicy, error) {
obj, err := c.Fake.Invokes(NewGetAction("networkpolicies", c.Namespace, name), &extensions.NetworkPolicy{})
if obj == nil {
return nil, err
}
return obj.(*extensions.NetworkPolicy), err
}
func (c *FakeNetworkPolicies) List(opts api.ListOptions) (*extensions.NetworkPolicyList, error) {
obj, err := c.Fake.Invokes(NewListAction("networkpolicies", c.Namespace, opts), &extensions.NetworkPolicyList{})
if obj == nil {
return nil, err
}
return obj.(*extensions.NetworkPolicyList), err
}
func (c *FakeNetworkPolicies) Create(np *extensions.NetworkPolicy) (*extensions.NetworkPolicy, error) {
obj, err := c.Fake.Invokes(NewCreateAction("networkpolicies", c.Namespace, np), &extensions.NetworkPolicy{})
if obj == nil {
return nil, err
}
return obj.(*extensions.NetworkPolicy), err
}
func (c *FakeNetworkPolicies) Update(np *extensions.NetworkPolicy) (*extensions.NetworkPolicy, error) {
obj, err := c.Fake.Invokes(NewUpdateAction("networkpolicies", c.Namespace, np), &extensions.NetworkPolicy{})
if obj == nil {
return nil, err
}
return obj.(*extensions.NetworkPolicy), err
}
func (c *FakeNetworkPolicies) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.Invokes(NewDeleteAction("networkpolicies", c.Namespace, name), &extensions.NetworkPolicy{})
return err
}
func (c *FakeNetworkPolicies) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.Fake.InvokesWatch(NewWatchAction("networkpolicies", c.Namespace, opts))
}

View file

@ -47,16 +47,16 @@ func (c *FakePodSecurityPolicy) Get(name string) (*extensions.PodSecurityPolicy,
return obj.(*extensions.PodSecurityPolicy), err
}
func (c *FakePodSecurityPolicy) Create(scc *extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error) {
obj, err := c.Fake.Invokes(NewCreateAction("podsecuritypolicies", c.Namespace, scc), &extensions.PodSecurityPolicy{})
func (c *FakePodSecurityPolicy) Create(psp *extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error) {
obj, err := c.Fake.Invokes(NewCreateAction("podsecuritypolicies", c.Namespace, psp), &extensions.PodSecurityPolicy{})
if obj == nil {
return nil, err
}
return obj.(*extensions.PodSecurityPolicy), err
}
func (c *FakePodSecurityPolicy) Update(scc *extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error) {
obj, err := c.Fake.Invokes(NewUpdateAction("podsecuritypolicies", c.Namespace, scc), &extensions.PodSecurityPolicy{})
func (c *FakePodSecurityPolicy) Update(psp *extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error) {
obj, err := c.Fake.Invokes(NewUpdateAction("podsecuritypolicies", c.Namespace, psp), &extensions.PodSecurityPolicy{})
if obj == nil {
return nil, err
}

View file

@ -0,0 +1,74 @@
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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.
*/
package testclient
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/watch"
)
// FakeRoleBindings implements RoleBindingInterface
type FakeRoleBindings struct {
Fake *FakeRbac
Namespace string
}
func (c *FakeRoleBindings) Get(name string) (*rbac.RoleBinding, error) {
obj, err := c.Fake.Invokes(NewGetAction("rolebindings", c.Namespace, name), &rbac.RoleBinding{})
if obj == nil {
return nil, err
}
return obj.(*rbac.RoleBinding), err
}
func (c *FakeRoleBindings) List(opts api.ListOptions) (*rbac.RoleBindingList, error) {
obj, err := c.Fake.Invokes(NewListAction("rolebindings", c.Namespace, opts), &rbac.RoleBindingList{})
if obj == nil {
return nil, err
}
return obj.(*rbac.RoleBindingList), err
}
func (c *FakeRoleBindings) Create(csr *rbac.RoleBinding) (*rbac.RoleBinding, error) {
obj, err := c.Fake.Invokes(NewCreateAction("rolebindings", c.Namespace, csr), csr)
if obj == nil {
return nil, err
}
return obj.(*rbac.RoleBinding), err
}
func (c *FakeRoleBindings) Update(csr *rbac.RoleBinding) (*rbac.RoleBinding, error) {
obj, err := c.Fake.Invokes(NewUpdateAction("rolebindings", c.Namespace, csr), csr)
if obj == nil {
return nil, err
}
return obj.(*rbac.RoleBinding), err
}
func (c *FakeRoleBindings) Delete(name string, opts *api.DeleteOptions) error {
_, err := c.Fake.Invokes(NewDeleteAction("rolebindings", c.Namespace, name), &rbac.RoleBinding{})
return err
}
func (c *FakeRoleBindings) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.Fake.InvokesWatch(NewWatchAction("rolebindings", c.Namespace, opts))
}

View file

@ -0,0 +1,74 @@
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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.
*/
package testclient
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/watch"
)
// FakeRoles implements RoleInterface
type FakeRoles struct {
Fake *FakeRbac
Namespace string
}
func (c *FakeRoles) Get(name string) (*rbac.Role, error) {
obj, err := c.Fake.Invokes(NewGetAction("roles", c.Namespace, name), &rbac.Role{})
if obj == nil {
return nil, err
}
return obj.(*rbac.Role), err
}
func (c *FakeRoles) List(opts api.ListOptions) (*rbac.RoleList, error) {
obj, err := c.Fake.Invokes(NewListAction("roles", c.Namespace, opts), &rbac.RoleList{})
if obj == nil {
return nil, err
}
return obj.(*rbac.RoleList), err
}
func (c *FakeRoles) Create(csr *rbac.Role) (*rbac.Role, error) {
obj, err := c.Fake.Invokes(NewCreateAction("roles", c.Namespace, csr), csr)
if obj == nil {
return nil, err
}
return obj.(*rbac.Role), err
}
func (c *FakeRoles) Update(csr *rbac.Role) (*rbac.Role, error) {
obj, err := c.Fake.Invokes(NewUpdateAction("roles", c.Namespace, csr), csr)
if obj == nil {
return nil, err
}
return obj.(*rbac.Role), err
}
func (c *FakeRoles) Delete(name string, opts *api.DeleteOptions) error {
_, err := c.Fake.Invokes(NewDeleteAction("roles", c.Namespace, name), &rbac.Role{})
return err
}
func (c *FakeRoles) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.Fake.InvokesWatch(NewWatchAction("roles", c.Namespace, opts))
}

View file

@ -0,0 +1,84 @@
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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.
*/
package testclient
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/watch"
)
// FakeScheduledJobs implements ScheduledJobInterface. Meant to be embedded into a struct to get a default
// implementation. This makes faking out just the methods you want to test easier.
type FakeScheduledJobs struct {
Fake *FakeBatch
Namespace string
}
func (c *FakeScheduledJobs) Get(name string) (*batch.ScheduledJob, error) {
obj, err := c.Fake.Invokes(NewGetAction("scheduledjobs", c.Namespace, name), &batch.ScheduledJob{})
if obj == nil {
return nil, err
}
return obj.(*batch.ScheduledJob), err
}
func (c *FakeScheduledJobs) List(opts api.ListOptions) (*batch.ScheduledJobList, error) {
obj, err := c.Fake.Invokes(NewListAction("scheduledjobs", c.Namespace, opts), &batch.ScheduledJobList{})
if obj == nil {
return nil, err
}
return obj.(*batch.ScheduledJobList), err
}
func (c *FakeScheduledJobs) Create(scheduledJob *batch.ScheduledJob) (*batch.ScheduledJob, error) {
obj, err := c.Fake.Invokes(NewCreateAction("scheduledjobs", c.Namespace, scheduledJob), scheduledJob)
if obj == nil {
return nil, err
}
return obj.(*batch.ScheduledJob), err
}
func (c *FakeScheduledJobs) Update(scheduledJob *batch.ScheduledJob) (*batch.ScheduledJob, error) {
obj, err := c.Fake.Invokes(NewUpdateAction("scheduledjobs", c.Namespace, scheduledJob), scheduledJob)
if obj == nil {
return nil, err
}
return obj.(*batch.ScheduledJob), err
}
func (c *FakeScheduledJobs) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.Invokes(NewDeleteAction("scheduledjobs", c.Namespace, name), &batch.ScheduledJob{})
return err
}
func (c *FakeScheduledJobs) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.Fake.InvokesWatch(NewWatchAction("scheduledjobs", c.Namespace, opts))
}
func (c *FakeScheduledJobs) UpdateStatus(scheduledJob *batch.ScheduledJob) (result *batch.ScheduledJob, err error) {
obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("scheduledjobs", "status", c.Namespace, scheduledJob), scheduledJob)
if obj == nil {
return nil, err
}
return obj.(*batch.ScheduledJob), err
}

View file

@ -204,11 +204,11 @@ func (o objects) Kind(kind unversioned.GroupVersionKind, name string) (runtime.O
}
func (o objects) Add(obj runtime.Object) error {
gvk, err := o.scheme.ObjectKind(obj)
gvks, _, err := o.scheme.ObjectKinds(obj)
if err != nil {
return err
}
kind := gvk.Kind
kind := gvks[0].Kind
switch {
case meta.IsListType(obj):

View file

@ -301,6 +301,10 @@ func (c *Fake) ConfigMaps(namespace string) client.ConfigMapsInterface {
return &FakeConfigMaps{Fake: c, Namespace: namespace}
}
func (c *Fake) Rbac() client.RbacInterface {
return &FakeRbac{Fake: c}
}
// SwaggerSchema returns an empty swagger.ApiDeclaration for testing
func (c *Fake) SwaggerSchema(version unversioned.GroupVersion) (*swagger.ApiDeclaration, error) {
action := ActionImpl{}
@ -325,7 +329,7 @@ type FakeAutoscaling struct {
}
func (c *FakeAutoscaling) HorizontalPodAutoscalers(namespace string) client.HorizontalPodAutoscalerInterface {
return &FakeHorizontalPodAutoscalersV1{Fake: c, Namespace: namespace}
return &FakeHorizontalPodAutoscalers{Fake: c, Namespace: namespace}
}
// NewSimpleFakeBatch returns a client that will respond with the provided objects
@ -341,6 +345,10 @@ func (c *FakeBatch) Jobs(namespace string) client.JobInterface {
return &FakeJobsV1{Fake: c, Namespace: namespace}
}
func (c *FakeBatch) ScheduledJobs(namespace string) client.ScheduledJobInterface {
return &FakeScheduledJobs{Fake: c, Namespace: namespace}
}
// NewSimpleFakeExp returns a client that will respond with the provided objects
func NewSimpleFakeExp(objects ...runtime.Object) *FakeExperimental {
return &FakeExperimental{Fake: NewSimpleFake(objects...)}
@ -354,10 +362,6 @@ func (c *FakeExperimental) DaemonSets(namespace string) client.DaemonSetInterfac
return &FakeDaemonSets{Fake: c, Namespace: namespace}
}
func (c *FakeExperimental) HorizontalPodAutoscalers(namespace string) client.HorizontalPodAutoscalerInterface {
return &FakeHorizontalPodAutoscalers{Fake: c, Namespace: namespace}
}
func (c *FakeExperimental) Deployments(namespace string) client.DeploymentInterface {
return &FakeDeployments{Fake: c, Namespace: namespace}
}
@ -382,10 +386,46 @@ func (c *FakeExperimental) ReplicaSets(namespace string) client.ReplicaSetInterf
return &FakeReplicaSets{Fake: c, Namespace: namespace}
}
func (c *FakeExperimental) NetworkPolicies(namespace string) client.NetworkPolicyInterface {
return &FakeNetworkPolicies{Fake: c, Namespace: namespace}
}
func NewSimpleFakeRbac(objects ...runtime.Object) *FakeRbac {
return &FakeRbac{Fake: NewSimpleFake(objects...)}
}
type FakeRbac struct {
*Fake
}
func (c *FakeRbac) Roles(namespace string) client.RoleInterface {
return &FakeRoles{Fake: c, Namespace: namespace}
}
func (c *FakeRbac) RoleBindings(namespace string) client.RoleBindingInterface {
return &FakeRoleBindings{Fake: c, Namespace: namespace}
}
func (c *FakeRbac) ClusterRoles() client.ClusterRoleInterface {
return &FakeClusterRoles{Fake: c}
}
func (c *FakeRbac) ClusterRoleBindings() client.ClusterRoleBindingInterface {
return &FakeClusterRoleBindings{Fake: c}
}
type FakeDiscovery struct {
*Fake
}
func (c *FakeDiscovery) ServerPreferredResources() ([]unversioned.GroupVersionResource, error) {
return nil, nil
}
func (c *FakeDiscovery) ServerPreferredNamespacedResources() ([]unversioned.GroupVersionResource, error) {
return nil, nil
}
func (c *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*unversioned.APIResourceList, error) {
action := ActionImpl{
Verb: "get",