mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 22:05:59 +00:00
Merge pull request #15951 from kargakis/factory-expose-method
Make CanBeExposed and CanBeAutoscaled composable
This commit is contained in:
commit
154923221f
@ -768,8 +768,8 @@ __EOF__
|
|||||||
# Pre-condition: don't need
|
# Pre-condition: don't need
|
||||||
# Command
|
# Command
|
||||||
output_message=$(! kubectl expose nodes 127.0.0.1 2>&1 "${kube_flags[@]}")
|
output_message=$(! kubectl expose nodes 127.0.0.1 2>&1 "${kube_flags[@]}")
|
||||||
# Post-condition: the error message has "invalid resource" string
|
# Post-condition: the error message has "cannot expose" string
|
||||||
kube::test::if_has_string "${output_message}" 'invalid resource'
|
kube::test::if_has_string "${output_message}" 'cannot expose'
|
||||||
|
|
||||||
### Try to generate a service with invalid name (exceeding maximum valid size)
|
### Try to generate a service with invalid name (exceeding maximum valid size)
|
||||||
# Pre-condition: use --name flag
|
# Pre-condition: use --name flag
|
||||||
|
@ -262,14 +262,21 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
|
|||||||
return generator, ok
|
return generator, ok
|
||||||
},
|
},
|
||||||
CanBeExposed: func(kind string) error {
|
CanBeExposed: func(kind string) error {
|
||||||
if kind != "ReplicationController" && kind != "Service" && kind != "Pod" {
|
switch kind {
|
||||||
return fmt.Errorf("invalid resource provided: %v, only a replication controller, service or pod is accepted", kind)
|
case "ReplicationController", "Service", "Pod":
|
||||||
|
// nothing to do here
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("cannot expose a %s", kind)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
CanBeAutoscaled: func(kind string) error { // TODO: support autoscale for deployments
|
CanBeAutoscaled: func(kind string) error {
|
||||||
if kind != "ReplicationController" {
|
switch kind {
|
||||||
return fmt.Errorf("invalid resource provided: %v, only a replication controller is accepted", kind)
|
// TODO: support autoscale for deployments
|
||||||
|
case "ReplicationController":
|
||||||
|
// nothing to do here
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("cannot autoscale a %s", kind)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user