MCPcopy Create free account
hub / github.com/devspace-sh/devspace / Delete

Function Delete

pkg/devspace/deploy/deployer/kubectl/delete.go:8–27  ·  view source on GitHub ↗
(ctx devspacecontext.Context, deploymentName string)

Source from the content-addressed store, hash-verified

6)
7
8func Delete(ctx devspacecontext.Context, deploymentName string) error {
9 deploymentCache, ok := ctx.Config().RemoteCache().GetDeployment(deploymentName)
10 if !ok || deploymentCache.Kubectl == nil || len(deploymentCache.Kubectl.Objects) == 0 {
11 return nil
12 }
13
14 for _, resource := range deploymentCache.Kubectl.Objects {
15 _, err := ctx.KubeClient().GenericRequest(ctx.Context(), &kubectl.GenericRequestOptions{
16 Kind: resource.Kind,
17 APIVersion: resource.APIVersion,
18 Name: resource.Name,
19 Namespace: resource.Namespace,
20 Method: "delete",
21 })
22 if err != nil {
23 ctx.Log().Errorf("error deleting %s %s: %v", resource.Kind, resource.Name, err)
24 }
25 }
26 return nil
27}

Callers 1

TestDeleteFunction · 0.70

Calls 8

GetDeploymentMethod · 0.65
RemoteCacheMethod · 0.65
ConfigMethod · 0.65
GenericRequestMethod · 0.65
KubeClientMethod · 0.65
ContextMethod · 0.65
LogMethod · 0.65
ErrorfMethod · 0.45

Tested by 1

TestDeleteFunction · 0.56