(ctx devspacecontext.Context, kind, namespace, name string)
| 16 | ) |
| 17 | |
| 18 | func findTargetByKindName(ctx devspacecontext.Context, kind, namespace, name string) (runtime.Object, error) { |
| 19 | var ( |
| 20 | err error |
| 21 | parent runtime.Object |
| 22 | ) |
| 23 | switch kind { |
| 24 | case "ReplicaSet": |
| 25 | parent, err = ctx.KubeClient().KubeClient().AppsV1().ReplicaSets(namespace).Get(ctx.Context(), name, metav1.GetOptions{}) |
| 26 | case "Deployment": |
| 27 | parent, err = ctx.KubeClient().KubeClient().AppsV1().Deployments(namespace).Get(ctx.Context(), name, metav1.GetOptions{}) |
| 28 | case "StatefulSet": |
| 29 | parent, err = ctx.KubeClient().KubeClient().AppsV1().StatefulSets(namespace).Get(ctx.Context(), name, metav1.GetOptions{}) |
| 30 | default: |
| 31 | return nil, fmt.Errorf("unrecognized parent kind") |
| 32 | } |
| 33 | if err != nil { |
| 34 | return nil, err |
| 35 | } |
| 36 | |
| 37 | typeAccessor, _ := meta.TypeAccessor(parent) |
| 38 | typeAccessor.SetAPIVersion("apps/v1") |
| 39 | typeAccessor.SetKind(kind) |
| 40 | return parent, nil |
| 41 | } |
| 42 | |
| 43 | func findTargetBySelector(ctx devspacecontext.Context, devPod *latest.DevPod, filter func(obj metav1.Object) bool) (runtime.Object, error) { |
| 44 | namespace := ctx.KubeClient().Namespace() |
no test coverage detected