-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.go
41 lines (34 loc) · 985 Bytes
/
generator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package generator
import (
"fmt"
"reflect"
kapi "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/runtime"
deployapi "github.com/openshift/origin/pkg/deploy/api"
)
var basic = kubectl.BasicReplicationController{}
type BasicDeploymentConfigController struct{}
func (BasicDeploymentConfigController) ParamNames() []kubectl.GeneratorParam {
return basic.ParamNames()
}
func (BasicDeploymentConfigController) Generate(genericParams map[string]interface{}) (runtime.Object, error) {
obj, err := basic.Generate(genericParams)
if err != nil {
return nil, err
}
switch t := obj.(type) {
case *kapi.ReplicationController:
obj = &deployapi.DeploymentConfig{
ObjectMeta: t.ObjectMeta,
Spec: deployapi.DeploymentConfigSpec{
Selector: t.Spec.Selector,
Replicas: t.Spec.Replicas,
Template: t.Spec.Template,
},
}
default:
return nil, fmt.Errorf("unrecognized object type: %v", reflect.TypeOf(t))
}
return obj, nil
}