mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
Merge pull request #17798 from deads2k/gv-kubectl-01
Auto commit by PR queue bot
This commit is contained in:
commit
69bb774dd4
@ -330,7 +330,12 @@ _kubectl_describe()
|
|||||||
|
|
||||||
must_have_one_flag=()
|
must_have_one_flag=()
|
||||||
must_have_one_noun=()
|
must_have_one_noun=()
|
||||||
|
must_have_one_noun+=("daemonset")
|
||||||
|
must_have_one_noun+=("deployment")
|
||||||
must_have_one_noun+=("endpoints")
|
must_have_one_noun+=("endpoints")
|
||||||
|
must_have_one_noun+=("horizontalpodautoscaler")
|
||||||
|
must_have_one_noun+=("ingress")
|
||||||
|
must_have_one_noun+=("job")
|
||||||
must_have_one_noun+=("limitrange")
|
must_have_one_noun+=("limitrange")
|
||||||
must_have_one_noun+=("namespace")
|
must_have_one_noun+=("namespace")
|
||||||
must_have_one_noun+=("node")
|
must_have_one_noun+=("node")
|
||||||
|
@ -27,6 +27,11 @@ var Scheme = runtime.NewScheme()
|
|||||||
// SchemeGroupVersion is group version used to register these objects
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: ""}
|
var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: ""}
|
||||||
|
|
||||||
|
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
|
||||||
|
func Kind(kind string) unversioned.GroupKind {
|
||||||
|
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Scheme.AddKnownTypes(SchemeGroupVersion,
|
Scheme.AddKnownTypes(SchemeGroupVersion,
|
||||||
&Pod{},
|
&Pod{},
|
||||||
|
@ -28,6 +28,11 @@ func init() {
|
|||||||
// SchemeGroupVersion is group version used to register these objects
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
var SchemeGroupVersion = unversioned.GroupVersion{Group: "componentconfig", Version: ""}
|
var SchemeGroupVersion = unversioned.GroupVersion{Group: "componentconfig", Version: ""}
|
||||||
|
|
||||||
|
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
|
||||||
|
func Kind(kind string) unversioned.GroupKind {
|
||||||
|
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
||||||
|
}
|
||||||
|
|
||||||
func addKnownTypes() {
|
func addKnownTypes() {
|
||||||
// TODO this will get cleaned up with the scheme types are fixed
|
// TODO this will get cleaned up with the scheme types are fixed
|
||||||
api.Scheme.AddKnownTypes(SchemeGroupVersion,
|
api.Scheme.AddKnownTypes(SchemeGroupVersion,
|
||||||
|
@ -24,6 +24,11 @@ import (
|
|||||||
// SchemeGroupVersion is group version used to register these objects
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
var SchemeGroupVersion = unversioned.GroupVersion{Group: "extensions", Version: ""}
|
var SchemeGroupVersion = unversioned.GroupVersion{Group: "extensions", Version: ""}
|
||||||
|
|
||||||
|
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
|
||||||
|
func Kind(kind string) unversioned.GroupKind {
|
||||||
|
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Register the API.
|
// Register the API.
|
||||||
addKnownTypes()
|
addKnownTypes()
|
||||||
|
@ -29,6 +29,11 @@ func init() {
|
|||||||
// SchemeGroupVersion is group version used to register these objects
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
var SchemeGroupVersion = unversioned.GroupVersion{Group: "metrics", Version: ""}
|
var SchemeGroupVersion = unversioned.GroupVersion{Group: "metrics", Version: ""}
|
||||||
|
|
||||||
|
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
|
||||||
|
func Kind(kind string) unversioned.GroupKind {
|
||||||
|
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
||||||
|
}
|
||||||
|
|
||||||
// Adds the list of known types to api.Scheme.
|
// Adds the list of known types to api.Scheme.
|
||||||
func addKnownTypes() {
|
func addKnownTypes() {
|
||||||
// TODO this will get cleaned up with the scheme types are fixed
|
// TODO this will get cleaned up with the scheme types are fixed
|
||||||
|
@ -172,15 +172,11 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
|
|||||||
return nil, fmt.Errorf("unable to get RESTClient for resource '%s'", mapping.Resource)
|
return nil, fmt.Errorf("unable to get RESTClient for resource '%s'", mapping.Resource)
|
||||||
},
|
},
|
||||||
Describer: func(mapping *meta.RESTMapping) (kubectl.Describer, error) {
|
Describer: func(mapping *meta.RESTMapping) (kubectl.Describer, error) {
|
||||||
gvk, err := api.RESTMapper.KindFor(mapping.Resource)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
client, err := clients.ClientForVersion(mapping.GroupVersionKind.GroupVersion().String())
|
client, err := clients.ClientForVersion(mapping.GroupVersionKind.GroupVersion().String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if describer, ok := kubectl.DescriberFor(gvk.Group, mapping.GroupVersionKind.Kind, client); ok {
|
if describer, ok := kubectl.DescriberFor(mapping.GroupVersionKind.GroupKind(), client); ok {
|
||||||
return describer, nil
|
return describer, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("no description has been implemented for %q", mapping.Kind)
|
return nil, fmt.Errorf("no description has been implemented for %q", mapping.Kind)
|
||||||
@ -257,14 +253,14 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return kubectl.ScalerFor(mapping.GroupVersionKind.Kind, client)
|
return kubectl.ScalerFor(mapping.GroupVersionKind.GroupKind(), client)
|
||||||
},
|
},
|
||||||
Reaper: func(mapping *meta.RESTMapping) (kubectl.Reaper, error) {
|
Reaper: func(mapping *meta.RESTMapping) (kubectl.Reaper, error) {
|
||||||
client, err := clients.ClientForVersion(mapping.GroupVersionKind.GroupVersion().String())
|
client, err := clients.ClientForVersion(mapping.GroupVersionKind.GroupVersion().String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return kubectl.ReaperFor(mapping.GroupVersionKind.Kind, client)
|
return kubectl.ReaperFor(mapping.GroupVersionKind.GroupKind(), client)
|
||||||
},
|
},
|
||||||
Validator: func(validate bool, cacheDir string) (validation.Schema, error) {
|
Validator: func(validate bool, cacheDir string) (validation.Schema, error) {
|
||||||
if validate {
|
if validate {
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/api/resource"
|
"k8s.io/kubernetes/pkg/api/resource"
|
||||||
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/fieldpath"
|
"k8s.io/kubernetes/pkg/fieldpath"
|
||||||
@ -66,32 +67,29 @@ func (e ErrNoDescriber) Error() string {
|
|||||||
return fmt.Sprintf("no describer has been defined for %v", e.Types)
|
return fmt.Sprintf("no describer has been defined for %v", e.Types)
|
||||||
}
|
}
|
||||||
|
|
||||||
func describerMap(c *client.Client) map[string]Describer {
|
func describerMap(c *client.Client) map[unversioned.GroupKind]Describer {
|
||||||
m := map[string]Describer{
|
m := map[unversioned.GroupKind]Describer{
|
||||||
"Pod": &PodDescriber{c},
|
api.Kind("Pod"): &PodDescriber{c},
|
||||||
"ReplicationController": &ReplicationControllerDescriber{c},
|
api.Kind("ReplicationController"): &ReplicationControllerDescriber{c},
|
||||||
"Secret": &SecretDescriber{c},
|
api.Kind("Secret"): &SecretDescriber{c},
|
||||||
"Service": &ServiceDescriber{c},
|
api.Kind("Service"): &ServiceDescriber{c},
|
||||||
"ServiceAccount": &ServiceAccountDescriber{c},
|
api.Kind("ServiceAccount"): &ServiceAccountDescriber{c},
|
||||||
"Node": &NodeDescriber{c},
|
api.Kind("Node"): &NodeDescriber{c},
|
||||||
"LimitRange": &LimitRangeDescriber{c},
|
api.Kind("LimitRange"): &LimitRangeDescriber{c},
|
||||||
"ResourceQuota": &ResourceQuotaDescriber{c},
|
api.Kind("ResourceQuota"): &ResourceQuotaDescriber{c},
|
||||||
"PersistentVolume": &PersistentVolumeDescriber{c},
|
api.Kind("PersistentVolume"): &PersistentVolumeDescriber{c},
|
||||||
"PersistentVolumeClaim": &PersistentVolumeClaimDescriber{c},
|
api.Kind("PersistentVolumeClaim"): &PersistentVolumeClaimDescriber{c},
|
||||||
"Namespace": &NamespaceDescriber{c},
|
api.Kind("Namespace"): &NamespaceDescriber{c},
|
||||||
"Endpoints": &EndpointsDescriber{c},
|
api.Kind("Endpoints"): &EndpointsDescriber{c},
|
||||||
}
|
|
||||||
return m
|
|
||||||
}
|
|
||||||
|
|
||||||
func expDescriberMap(c *client.Client) map[string]Describer {
|
extensions.Kind("HorizontalPodAutoscaler"): &HorizontalPodAutoscalerDescriber{c},
|
||||||
return map[string]Describer{
|
extensions.Kind("DaemonSet"): &DaemonSetDescriber{c},
|
||||||
"HorizontalPodAutoscaler": &HorizontalPodAutoscalerDescriber{c},
|
extensions.Kind("Job"): &JobDescriber{c},
|
||||||
"DaemonSet": &DaemonSetDescriber{c},
|
extensions.Kind("Deployment"): &DeploymentDescriber{c},
|
||||||
"Job": &JobDescriber{c},
|
extensions.Kind("Ingress"): &IngressDescriber{c},
|
||||||
"Deployment": &DeploymentDescriber{c},
|
|
||||||
"Ingress": &IngressDescriber{c},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of all resource types we can describe
|
// List of all resource types we can describe
|
||||||
@ -99,7 +97,7 @@ func DescribableResources() []string {
|
|||||||
keys := make([]string, 0)
|
keys := make([]string, 0)
|
||||||
|
|
||||||
for k := range describerMap(nil) {
|
for k := range describerMap(nil) {
|
||||||
resource := strings.ToLower(k)
|
resource := strings.ToLower(k.Kind)
|
||||||
keys = append(keys, resource)
|
keys = append(keys, resource)
|
||||||
}
|
}
|
||||||
return keys
|
return keys
|
||||||
@ -107,17 +105,8 @@ func DescribableResources() []string {
|
|||||||
|
|
||||||
// Describer returns the default describe functions for each of the standard
|
// Describer returns the default describe functions for each of the standard
|
||||||
// Kubernetes types.
|
// Kubernetes types.
|
||||||
func DescriberFor(group string, kind string, c *client.Client) (Describer, bool) {
|
func DescriberFor(kind unversioned.GroupKind, c *client.Client) (Describer, bool) {
|
||||||
var f Describer
|
f, ok := describerMap(c)[kind]
|
||||||
var ok bool
|
|
||||||
|
|
||||||
switch group {
|
|
||||||
case "":
|
|
||||||
f, ok = describerMap(c)[kind]
|
|
||||||
case "extensions":
|
|
||||||
f, ok = expDescriberMap(c)[kind]
|
|
||||||
}
|
|
||||||
|
|
||||||
return f, ok
|
return f, ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ func (r *RollingUpdater) scaleDown(newRc, oldRc *api.ReplicationController, desi
|
|||||||
|
|
||||||
// scalerScaleAndWait scales a controller using a Scaler and a real client.
|
// scalerScaleAndWait scales a controller using a Scaler and a real client.
|
||||||
func (r *RollingUpdater) scaleAndWaitWithScaler(rc *api.ReplicationController, retry *RetryParams, wait *RetryParams) (*api.ReplicationController, error) {
|
func (r *RollingUpdater) scaleAndWaitWithScaler(rc *api.ReplicationController, retry *RetryParams, wait *RetryParams) (*api.ReplicationController, error) {
|
||||||
scaler, err := ScalerFor("ReplicationController", r.c)
|
scaler, err := ScalerFor(api.Kind("ReplicationController"), r.c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Couldn't make scaler: %s", err)
|
return nil, fmt.Errorf("Couldn't make scaler: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/api/errors"
|
"k8s.io/kubernetes/pkg/api/errors"
|
||||||
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/util/wait"
|
"k8s.io/kubernetes/pkg/util/wait"
|
||||||
@ -39,13 +40,13 @@ type Scaler interface {
|
|||||||
ScaleSimple(namespace, name string, preconditions *ScalePrecondition, newSize uint) error
|
ScaleSimple(namespace, name string, preconditions *ScalePrecondition, newSize uint) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func ScalerFor(kind string, c client.Interface) (Scaler, error) {
|
func ScalerFor(kind unversioned.GroupKind, c client.Interface) (Scaler, error) {
|
||||||
switch kind {
|
switch kind {
|
||||||
case "ReplicationController":
|
case api.Kind("ReplicationController"):
|
||||||
return &ReplicationControllerScaler{c}, nil
|
return &ReplicationControllerScaler{c}, nil
|
||||||
case "Job":
|
case extensions.Kind("Job"):
|
||||||
return &JobScaler{c.Extensions()}, nil
|
return &JobScaler{c.Extensions()}, nil
|
||||||
case "Deployment":
|
case extensions.Kind("Deployment"):
|
||||||
return &DeploymentScaler{c.Extensions()}, nil
|
return &DeploymentScaler{c.Extensions()}, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("no scaler has been implemented for %q", kind)
|
return nil, fmt.Errorf("no scaler has been implemented for %q", kind)
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/api/meta"
|
"k8s.io/kubernetes/pkg/api/meta"
|
||||||
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/fields"
|
"k8s.io/kubernetes/pkg/fields"
|
||||||
@ -45,11 +46,11 @@ type Reaper interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type NoSuchReaperError struct {
|
type NoSuchReaperError struct {
|
||||||
kind string
|
kind unversioned.GroupKind
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NoSuchReaperError) Error() string {
|
func (n *NoSuchReaperError) Error() string {
|
||||||
return fmt.Sprintf("no reaper has been implemented for %q", n.kind)
|
return fmt.Sprintf("no reaper has been implemented for %v", n.kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsNoSuchReaperError(err error) bool {
|
func IsNoSuchReaperError(err error) bool {
|
||||||
@ -57,18 +58,23 @@ func IsNoSuchReaperError(err error) bool {
|
|||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReaperFor(kind string, c client.Interface) (Reaper, error) {
|
func ReaperFor(kind unversioned.GroupKind, c client.Interface) (Reaper, error) {
|
||||||
switch kind {
|
switch kind {
|
||||||
case "ReplicationController":
|
case api.Kind("ReplicationController"):
|
||||||
return &ReplicationControllerReaper{c, Interval, Timeout}, nil
|
return &ReplicationControllerReaper{c, Interval, Timeout}, nil
|
||||||
case "DaemonSet":
|
|
||||||
|
case extensions.Kind("DaemonSet"):
|
||||||
return &DaemonSetReaper{c, Interval, Timeout}, nil
|
return &DaemonSetReaper{c, Interval, Timeout}, nil
|
||||||
case "Pod":
|
|
||||||
|
case api.Kind("Pod"):
|
||||||
return &PodReaper{c}, nil
|
return &PodReaper{c}, nil
|
||||||
case "Service":
|
|
||||||
|
case api.Kind("Service"):
|
||||||
return &ServiceReaper{c}, nil
|
return &ServiceReaper{c}, nil
|
||||||
case "Job":
|
|
||||||
|
case extensions.Kind("Job"):
|
||||||
return &JobReaper{c, Interval, Timeout}, nil
|
return &JobReaper{c, Interval, Timeout}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
return nil, &NoSuchReaperError{kind}
|
return nil, &NoSuchReaperError{kind}
|
||||||
}
|
}
|
||||||
@ -120,7 +126,7 @@ func getOverlappingControllers(c client.ReplicationControllerInterface, rc *api.
|
|||||||
|
|
||||||
func (reaper *ReplicationControllerReaper) Stop(namespace, name string, timeout time.Duration, gracePeriod *api.DeleteOptions) error {
|
func (reaper *ReplicationControllerReaper) Stop(namespace, name string, timeout time.Duration, gracePeriod *api.DeleteOptions) error {
|
||||||
rc := reaper.ReplicationControllers(namespace)
|
rc := reaper.ReplicationControllers(namespace)
|
||||||
scaler, err := ScalerFor("ReplicationController", *reaper)
|
scaler, err := ScalerFor(api.Kind("ReplicationController"), *reaper)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -224,7 +230,7 @@ func (reaper *DaemonSetReaper) Stop(namespace, name string, timeout time.Duratio
|
|||||||
func (reaper *JobReaper) Stop(namespace, name string, timeout time.Duration, gracePeriod *api.DeleteOptions) error {
|
func (reaper *JobReaper) Stop(namespace, name string, timeout time.Duration, gracePeriod *api.DeleteOptions) error {
|
||||||
jobs := reaper.Extensions().Jobs(namespace)
|
jobs := reaper.Extensions().Jobs(namespace)
|
||||||
pods := reaper.Pods(namespace)
|
pods := reaper.Pods(namespace)
|
||||||
scaler, err := ScalerFor("Job", *reaper)
|
scaler, err := ScalerFor(extensions.Kind("Job"), *reaper)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
|
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
|
||||||
@ -424,7 +425,7 @@ func (c *reaperFake) Services(namespace string) client.ServiceInterface {
|
|||||||
func TestSimpleStop(t *testing.T) {
|
func TestSimpleStop(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
fake *reaperFake
|
fake *reaperFake
|
||||||
kind string
|
kind unversioned.GroupKind
|
||||||
actions []testclient.Action
|
actions []testclient.Action
|
||||||
expectError bool
|
expectError bool
|
||||||
test string
|
test string
|
||||||
@ -433,7 +434,7 @@ func TestSimpleStop(t *testing.T) {
|
|||||||
fake: &reaperFake{
|
fake: &reaperFake{
|
||||||
Fake: &testclient.Fake{},
|
Fake: &testclient.Fake{},
|
||||||
},
|
},
|
||||||
kind: "Pod",
|
kind: api.Kind("Pod"),
|
||||||
actions: []testclient.Action{
|
actions: []testclient.Action{
|
||||||
testclient.NewGetAction("pods", api.NamespaceDefault, "foo"),
|
testclient.NewGetAction("pods", api.NamespaceDefault, "foo"),
|
||||||
testclient.NewDeleteAction("pods", api.NamespaceDefault, "foo"),
|
testclient.NewDeleteAction("pods", api.NamespaceDefault, "foo"),
|
||||||
@ -445,7 +446,7 @@ func TestSimpleStop(t *testing.T) {
|
|||||||
fake: &reaperFake{
|
fake: &reaperFake{
|
||||||
Fake: &testclient.Fake{},
|
Fake: &testclient.Fake{},
|
||||||
},
|
},
|
||||||
kind: "Service",
|
kind: api.Kind("Service"),
|
||||||
actions: []testclient.Action{
|
actions: []testclient.Action{
|
||||||
testclient.NewGetAction("services", api.NamespaceDefault, "foo"),
|
testclient.NewGetAction("services", api.NamespaceDefault, "foo"),
|
||||||
testclient.NewDeleteAction("services", api.NamespaceDefault, "foo"),
|
testclient.NewDeleteAction("services", api.NamespaceDefault, "foo"),
|
||||||
@ -458,7 +459,7 @@ func TestSimpleStop(t *testing.T) {
|
|||||||
Fake: &testclient.Fake{},
|
Fake: &testclient.Fake{},
|
||||||
noSuchPod: true,
|
noSuchPod: true,
|
||||||
},
|
},
|
||||||
kind: "Pod",
|
kind: api.Kind("Pod"),
|
||||||
actions: []testclient.Action{},
|
actions: []testclient.Action{},
|
||||||
expectError: true,
|
expectError: true,
|
||||||
test: "stop pod fails, no pod",
|
test: "stop pod fails, no pod",
|
||||||
@ -468,7 +469,7 @@ func TestSimpleStop(t *testing.T) {
|
|||||||
Fake: &testclient.Fake{},
|
Fake: &testclient.Fake{},
|
||||||
noDeleteService: true,
|
noDeleteService: true,
|
||||||
},
|
},
|
||||||
kind: "Service",
|
kind: api.Kind("Service"),
|
||||||
actions: []testclient.Action{
|
actions: []testclient.Action{
|
||||||
testclient.NewGetAction("services", api.NamespaceDefault, "foo"),
|
testclient.NewGetAction("services", api.NamespaceDefault, "foo"),
|
||||||
},
|
},
|
||||||
|
@ -98,7 +98,7 @@ var _ = Describe("Daemon set", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
defer func() {
|
defer func() {
|
||||||
Logf("Check that reaper kills all daemon pods for %s", dsName)
|
Logf("Check that reaper kills all daemon pods for %s", dsName)
|
||||||
dsReaper, err := kubectl.ReaperFor("DaemonSet", c)
|
dsReaper, err := kubectl.ReaperFor(extensions.Kind("DaemonSet"), c)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
err = dsReaper.Stop(ns, dsName, 0, nil)
|
err = dsReaper.Stop(ns, dsName, 0, nil)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
@ -124,7 +124,7 @@ var _ = Describe("Job", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
By("scale job up")
|
By("scale job up")
|
||||||
scaler, err := kubectl.ScalerFor("Job", f.Client)
|
scaler, err := kubectl.ScalerFor(extensions.Kind("Job"), f.Client)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
waitForScale := kubectl.NewRetryParams(5*time.Second, 1*time.Minute)
|
waitForScale := kubectl.NewRetryParams(5*time.Second, 1*time.Minute)
|
||||||
waitForReplicas := kubectl.NewRetryParams(5*time.Second, 5*time.Minute)
|
waitForReplicas := kubectl.NewRetryParams(5*time.Second, 5*time.Minute)
|
||||||
@ -149,7 +149,7 @@ var _ = Describe("Job", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
By("scale job down")
|
By("scale job down")
|
||||||
scaler, err := kubectl.ScalerFor("Job", f.Client)
|
scaler, err := kubectl.ScalerFor(extensions.Kind("Job"), f.Client)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
waitForScale := kubectl.NewRetryParams(5*time.Second, 1*time.Minute)
|
waitForScale := kubectl.NewRetryParams(5*time.Second, 1*time.Minute)
|
||||||
waitForReplicas := kubectl.NewRetryParams(5*time.Second, 5*time.Minute)
|
waitForReplicas := kubectl.NewRetryParams(5*time.Second, 5*time.Minute)
|
||||||
@ -172,7 +172,7 @@ var _ = Describe("Job", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
By("scale job down")
|
By("scale job down")
|
||||||
reaper, err := kubectl.ReaperFor("Job", f.Client)
|
reaper, err := kubectl.ReaperFor(extensions.Kind("Job"), f.Client)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
timeout := 1 * time.Minute
|
timeout := 1 * time.Minute
|
||||||
err = reaper.Stop(f.Namespace.Name, job.Name, timeout, api.NewDeleteOptions(0))
|
err = reaper.Stop(f.Namespace.Name, job.Name, timeout, api.NewDeleteOptions(0))
|
||||||
|
@ -1713,7 +1713,7 @@ func getNodeEvents(c *client.Client, nodeName string) []api.Event {
|
|||||||
|
|
||||||
func ScaleRC(c *client.Client, ns, name string, size uint, wait bool) error {
|
func ScaleRC(c *client.Client, ns, name string, size uint, wait bool) error {
|
||||||
By(fmt.Sprintf("Scaling replication controller %s in namespace %s to %d", name, ns, size))
|
By(fmt.Sprintf("Scaling replication controller %s in namespace %s to %d", name, ns, size))
|
||||||
scaler, err := kubectl.ScalerFor("ReplicationController", c)
|
scaler, err := kubectl.ScalerFor(api.Kind("ReplicationController"), c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ func RCFromManifest(fileName string) *api.ReplicationController {
|
|||||||
|
|
||||||
// StopRC stops the rc via kubectl's stop library
|
// StopRC stops the rc via kubectl's stop library
|
||||||
func StopRC(rc *api.ReplicationController, restClient *client.Client) error {
|
func StopRC(rc *api.ReplicationController, restClient *client.Client) error {
|
||||||
reaper, err := kubectl.ReaperFor("ReplicationController", restClient)
|
reaper, err := kubectl.ReaperFor(api.Kind("ReplicationController"), restClient)
|
||||||
if err != nil || reaper == nil {
|
if err != nil || reaper == nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -202,7 +202,7 @@ func StopRC(rc *api.ReplicationController, restClient *client.Client) error {
|
|||||||
|
|
||||||
// ScaleRC scales the given rc to the given replicas.
|
// ScaleRC scales the given rc to the given replicas.
|
||||||
func ScaleRC(name, ns string, replicas int, restClient *client.Client) (*api.ReplicationController, error) {
|
func ScaleRC(name, ns string, replicas int, restClient *client.Client) (*api.ReplicationController, error) {
|
||||||
scaler, err := kubectl.ScalerFor("ReplicationController", restClient)
|
scaler, err := kubectl.ScalerFor(api.Kind("ReplicationController"), restClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user