2015-08-05 01:35:07 +00:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2015-08-12 17:35:07 +00:00
|
|
|
package unversioned
|
2015-08-05 01:35:07 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2015-09-10 19:30:47 +00:00
|
|
|
"k8s.io/kubernetes/pkg/api/latest"
|
2015-12-08 14:21:04 +00:00
|
|
|
"k8s.io/kubernetes/pkg/apis/extensions"
|
2015-08-05 01:35:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Interface holds the experimental methods for clients of Kubernetes
|
|
|
|
// to allow mock testing.
|
2015-10-12 17:50:20 +00:00
|
|
|
// Features of Extensions group are not supported and may be changed or removed in
|
2015-08-05 01:35:07 +00:00
|
|
|
// incompatible ways at any time.
|
2015-10-12 17:50:20 +00:00
|
|
|
type ExtensionsInterface interface {
|
2015-08-17 12:18:26 +00:00
|
|
|
HorizontalPodAutoscalersNamespacer
|
2015-08-20 12:55:28 +00:00
|
|
|
ScaleNamespacer
|
2015-09-08 23:58:25 +00:00
|
|
|
DaemonSetsNamespacer
|
2015-09-01 00:39:31 +00:00
|
|
|
DeploymentsNamespacer
|
2015-08-21 14:23:12 +00:00
|
|
|
JobsNamespacer
|
2015-09-28 23:41:09 +00:00
|
|
|
IngressNamespacer
|
2015-12-07 22:15:44 +00:00
|
|
|
ThirdPartyResourceNamespacer
|
2015-03-31 21:36:25 +00:00
|
|
|
ConfigMapsNamespacer
|
2015-08-05 01:35:07 +00:00
|
|
|
}
|
|
|
|
|
2015-10-12 17:50:20 +00:00
|
|
|
// ExtensionsClient is used to interact with experimental Kubernetes features.
|
|
|
|
// Features of Extensions group are not supported and may be changed or removed in
|
2015-08-05 01:35:07 +00:00
|
|
|
// incompatible ways at any time.
|
2015-10-12 17:50:20 +00:00
|
|
|
type ExtensionsClient struct {
|
2015-08-05 01:35:07 +00:00
|
|
|
*RESTClient
|
|
|
|
}
|
|
|
|
|
2015-10-12 17:50:20 +00:00
|
|
|
func (c *ExtensionsClient) HorizontalPodAutoscalers(namespace string) HorizontalPodAutoscalerInterface {
|
2015-08-17 12:18:26 +00:00
|
|
|
return newHorizontalPodAutoscalers(c, namespace)
|
|
|
|
}
|
|
|
|
|
2015-10-12 17:50:20 +00:00
|
|
|
func (c *ExtensionsClient) Scales(namespace string) ScaleInterface {
|
2015-08-20 12:55:28 +00:00
|
|
|
return newScales(c, namespace)
|
|
|
|
}
|
|
|
|
|
2015-10-12 17:50:20 +00:00
|
|
|
func (c *ExtensionsClient) DaemonSets(namespace string) DaemonSetInterface {
|
2015-09-08 23:58:25 +00:00
|
|
|
return newDaemonSets(c, namespace)
|
2015-08-27 17:17:41 +00:00
|
|
|
}
|
|
|
|
|
2015-10-12 17:50:20 +00:00
|
|
|
func (c *ExtensionsClient) Deployments(namespace string) DeploymentInterface {
|
2015-09-01 00:39:31 +00:00
|
|
|
return newDeployments(c, namespace)
|
|
|
|
}
|
|
|
|
|
2015-10-12 17:50:20 +00:00
|
|
|
func (c *ExtensionsClient) Jobs(namespace string) JobInterface {
|
2015-08-21 14:23:12 +00:00
|
|
|
return newJobs(c, namespace)
|
|
|
|
}
|
|
|
|
|
2015-10-12 17:50:20 +00:00
|
|
|
func (c *ExtensionsClient) Ingress(namespace string) IngressInterface {
|
2015-09-28 23:41:09 +00:00
|
|
|
return newIngress(c, namespace)
|
|
|
|
}
|
|
|
|
|
2015-03-31 21:36:25 +00:00
|
|
|
func (c *ExtensionsClient) ConfigMaps(namespace string) ConfigMapsInterface {
|
|
|
|
return newConfigMaps(c, namespace)
|
|
|
|
}
|
|
|
|
|
2015-12-07 22:15:44 +00:00
|
|
|
func (c *ExtensionsClient) ThirdPartyResources(namespace string) ThirdPartyResourceInterface {
|
|
|
|
return newThirdPartyResources(c, namespace)
|
|
|
|
}
|
|
|
|
|
2015-10-12 17:50:20 +00:00
|
|
|
// NewExtensions creates a new ExtensionsClient for the given config. This client
|
2015-08-05 01:35:07 +00:00
|
|
|
// provides access to experimental Kubernetes features.
|
2015-10-12 17:50:20 +00:00
|
|
|
// Features of Extensions group are not supported and may be changed or removed in
|
2015-08-05 01:35:07 +00:00
|
|
|
// incompatible ways at any time.
|
2015-10-12 17:50:20 +00:00
|
|
|
func NewExtensions(c *Config) (*ExtensionsClient, error) {
|
2015-08-05 01:35:07 +00:00
|
|
|
config := *c
|
2015-10-12 17:50:20 +00:00
|
|
|
if err := setExtensionsDefaults(&config); err != nil {
|
2015-08-05 01:35:07 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
client, err := RESTClientFor(&config)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2015-10-12 17:50:20 +00:00
|
|
|
return &ExtensionsClient{client}, nil
|
2015-08-05 01:35:07 +00:00
|
|
|
}
|
|
|
|
|
2015-10-12 17:50:20 +00:00
|
|
|
// NewExtensionsOrDie creates a new ExtensionsClient for the given config and
|
2015-08-05 01:35:07 +00:00
|
|
|
// panics if there is an error in the config.
|
2015-10-12 17:50:20 +00:00
|
|
|
// Features of Extensions group are not supported and may be changed or removed in
|
2015-08-05 01:35:07 +00:00
|
|
|
// incompatible ways at any time.
|
2015-10-12 17:50:20 +00:00
|
|
|
func NewExtensionsOrDie(c *Config) *ExtensionsClient {
|
|
|
|
client, err := NewExtensions(c)
|
2015-08-05 01:35:07 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return client
|
|
|
|
}
|
|
|
|
|
2015-10-12 17:50:20 +00:00
|
|
|
func setExtensionsDefaults(config *Config) error {
|
2015-09-11 22:46:18 +00:00
|
|
|
// if experimental group is not registered, return an error
|
2015-12-08 14:21:04 +00:00
|
|
|
g, err := latest.Group(extensions.GroupName)
|
2015-09-11 22:46:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2016-01-06 23:59:54 +00:00
|
|
|
config.APIPath = defaultAPIPath
|
2015-08-05 01:35:07 +00:00
|
|
|
if config.UserAgent == "" {
|
|
|
|
config.UserAgent = DefaultKubernetesUserAgent()
|
|
|
|
}
|
2015-09-17 05:15:05 +00:00
|
|
|
// TODO: Unconditionally set the config.Version, until we fix the config.
|
|
|
|
//if config.Version == "" {
|
2015-11-16 18:34:28 +00:00
|
|
|
copyGroupVersion := g.GroupVersion
|
|
|
|
config.GroupVersion = ©GroupVersion
|
2015-09-17 05:15:05 +00:00
|
|
|
//}
|
2015-09-11 22:46:18 +00:00
|
|
|
|
2015-12-08 18:27:26 +00:00
|
|
|
versionInterfaces, err := g.InterfacesFor(*config.GroupVersion)
|
2015-08-05 01:35:07 +00:00
|
|
|
if err != nil {
|
2015-12-02 20:47:42 +00:00
|
|
|
return fmt.Errorf("Extensions API group/version '%v' is not recognized (valid values: %v)",
|
2015-12-08 14:21:04 +00:00
|
|
|
config.GroupVersion, latest.GroupOrDie(extensions.GroupName).GroupVersions)
|
2015-08-05 01:35:07 +00:00
|
|
|
}
|
2015-09-28 21:36:54 +00:00
|
|
|
config.Codec = versionInterfaces.Codec
|
2015-08-05 01:35:07 +00:00
|
|
|
if config.QPS == 0 {
|
|
|
|
config.QPS = 5
|
|
|
|
}
|
|
|
|
if config.Burst == 0 {
|
|
|
|
config.Burst = 10
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|