forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate.go
41 lines (34 loc) · 1 KB
/
generate.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 cmd
import (
"fmt"
"reflect"
"k8s.io/apimachinery/pkg/runtime"
kapi "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/kubectl"
deployapi "github.com/openshift/origin/pkg/deploy/api/v1"
)
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, // the generator never leaves this nil
Template: t.Spec.Template,
},
}
default:
return nil, fmt.Errorf("unrecognized object type: %v", reflect.TypeOf(t))
}
return obj, nil
}