1 /* 2 Copyright 2018 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package versioned 18 19 import ( 20 "k8s.io/kubectl/pkg/generate" 21 ) 22 23 // GeneratorFn gives a way to easily override the function for unit testing if needed 24 var GeneratorFn generate.GeneratorFunc = DefaultGenerators 25 26 const ( 27 // TODO(sig-cli): Enforce consistent naming for generators here. 28 // See discussion in https://github.com/kubernetes/kubernetes/issues/46237 29 // before you add any more. 30 RunPodV1GeneratorName = "run-pod/v1" 31 ServiceV2GeneratorName = "service/v2" 32 ) 33 34 // DefaultGenerators returns the set of default generators for use in Factory instances 35 func DefaultGenerators(cmdName string) map[string]generate.Generator { 36 var generator map[string]generate.Generator 37 switch cmdName { 38 case "expose": 39 generator = map[string]generate.Generator{ 40 ServiceV2GeneratorName: ServiceGeneratorV2{}, 41 } 42 case "run": 43 generator = map[string]generate.Generator{ 44 RunPodV1GeneratorName: BasicPod{}, 45 } 46 } 47 48 return generator 49 } 50