1/*
2Copyright 2018 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8    http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package versioned
18
19import (
20	"k8s.io/kubectl/pkg/generate"
21)
22
23// GeneratorFn gives a way to easily override the function for unit testing if needed
24var GeneratorFn generate.GeneratorFunc = DefaultGenerators
25
26const (
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
35func 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