@@ -29,25 +29,31 @@ import (
29
29
"k8s.io/apimachinery/pkg/runtime"
30
30
"k8s.io/apimachinery/pkg/runtime/schema"
31
31
clientset "k8s.io/client-go/kubernetes"
32
- appsinternal "k8s.io/kubernetes/pkg/apis/apps"
33
- batchinternal "k8s.io/kubernetes/pkg/apis/batch"
34
- api "k8s.io/kubernetes/pkg/apis/core"
35
- extensionsinternal "k8s.io/kubernetes/pkg/apis/extensions"
32
+ )
33
+
34
+ var (
35
+ kindReplicationController = schema.GroupKind {Kind : "ReplicationController" }
36
+ kindExtensionsReplicaSet = schema.GroupKind {Group : "extensions" , Kind : "ReplicaSet" }
37
+ kindAppsReplicaSet = schema.GroupKind {Group : "apps" , Kind : "ReplicaSet" }
38
+ kindExtensionsDeployment = schema.GroupKind {Group : "extensions" , Kind : "Deployment" }
39
+ kindAppsDeployment = schema.GroupKind {Group : "apps" , Kind : "Deployment" }
40
+ kindExtensionsDaemonSet = schema.GroupKind {Group : "extensions" , Kind : "DaemonSet" }
41
+ kindBatchJob = schema.GroupKind {Group : "batch" , Kind : "Job" }
36
42
)
37
43
38
44
// GetRuntimeObjectForKind returns a runtime.Object based on its GroupKind,
39
45
// namespace and name.
40
46
func GetRuntimeObjectForKind (c clientset.Interface , kind schema.GroupKind , ns , name string ) (runtime.Object , error ) {
41
47
switch kind {
42
- case api . Kind ( "ReplicationController" ) :
48
+ case kindReplicationController :
43
49
return c .CoreV1 ().ReplicationControllers (ns ).Get (context .TODO (), name , metav1.GetOptions {})
44
- case extensionsinternal . Kind ( "ReplicaSet" ), appsinternal . Kind ( "ReplicaSet" ) :
50
+ case kindExtensionsReplicaSet , kindAppsReplicaSet :
45
51
return c .AppsV1 ().ReplicaSets (ns ).Get (context .TODO (), name , metav1.GetOptions {})
46
- case extensionsinternal . Kind ( "Deployment" ), appsinternal . Kind ( "Deployment" ) :
52
+ case kindExtensionsDeployment , kindAppsDeployment :
47
53
return c .AppsV1 ().Deployments (ns ).Get (context .TODO (), name , metav1.GetOptions {})
48
- case extensionsinternal . Kind ( "DaemonSet" ) :
54
+ case kindExtensionsDaemonSet :
49
55
return c .AppsV1 ().DaemonSets (ns ).Get (context .TODO (), name , metav1.GetOptions {})
50
- case batchinternal . Kind ( "Job" ) :
56
+ case kindBatchJob :
51
57
return c .BatchV1 ().Jobs (ns ).Get (context .TODO (), name , metav1.GetOptions {})
52
58
default :
53
59
return nil , fmt .Errorf ("Unsupported kind when getting runtime object: %v" , kind )
0 commit comments