2019-01-12 04:58:27 +00:00
|
|
|
/*
|
|
|
|
Copyright 2018 The Kubernetes Authors.
|
|
|
|
|
|
|
|
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 versioned
|
|
|
|
|
|
|
|
import (
|
2019-09-27 21:51:53 +00:00
|
|
|
"k8s.io/kubectl/pkg/generate"
|
2019-01-12 04:58:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// GeneratorFn gives a way to easily override the function for unit testing if needed
|
|
|
|
var GeneratorFn generate.GeneratorFunc = DefaultGenerators
|
|
|
|
|
|
|
|
const (
|
|
|
|
// TODO(sig-cli): Enforce consistent naming for generators here.
|
|
|
|
// See discussion in https://github.com/kubernetes/kubernetes/issues/46237
|
|
|
|
// before you add any more.
|
2021-03-18 22:40:29 +00:00
|
|
|
RunPodV1GeneratorName = "run-pod/v1"
|
|
|
|
ServiceV2GeneratorName = "service/v2"
|
2019-01-12 04:58:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// DefaultGenerators returns the set of default generators for use in Factory instances
|
|
|
|
func DefaultGenerators(cmdName string) map[string]generate.Generator {
|
|
|
|
var generator map[string]generate.Generator
|
|
|
|
switch cmdName {
|
|
|
|
case "expose":
|
|
|
|
generator = map[string]generate.Generator{
|
|
|
|
ServiceV2GeneratorName: ServiceGeneratorV2{},
|
|
|
|
}
|
|
|
|
case "run":
|
|
|
|
generator = map[string]generate.Generator{
|
2020-03-26 21:07:15 +00:00
|
|
|
RunPodV1GeneratorName: BasicPod{},
|
2019-01-12 04:58:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return generator
|
|
|
|
}
|