MCPcopy Index your code
hub / github.com/devspace-sh/devspace / findTargetByKindName

Function findTargetByKindName

pkg/devspace/services/podreplace/find.go:18–41  ·  view source on GitHub ↗
(ctx devspacecontext.Context, kind, namespace, name string)

Source from the content-addressed store, hash-verified

16)
17
18func 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
43func findTargetBySelector(ctx devspacecontext.Context, devPod *latest.DevPod, filter func(obj metav1.Object) bool) (runtime.Object, error) {
44 namespace := ctx.KubeClient().Namespace()

Callers 2

RevertReplacePodMethod · 0.85
updateNeededFunction · 0.85

Calls 4

KubeClientMethod · 0.65
ContextMethod · 0.65
GetMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected