1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 05:19:39 +02:00

refactor: replace the kubectl binary with the upstream sdk (#524)

This commit is contained in:
Steven Kang 2025-05-07 20:40:38 +12:00 committed by GitHub
parent 4d4360b86b
commit bc29419c17
17 changed files with 354 additions and 182 deletions

24
pkg/libkubectl/delete.go Normal file
View file

@ -0,0 +1,24 @@
package libkubectl
import (
"bytes"
"context"
"fmt"
"k8s.io/kubectl/pkg/cmd/delete"
)
func (c *Client) Delete(ctx context.Context, manifests []string) (string, error) {
buf := new(bytes.Buffer)
cmd := delete.NewCmdDelete(c.factory, c.streams)
cmd.SetArgs(manifestFilesToArgs(manifests))
cmd.Flags().Set("ignore-not-found", "true")
cmd.SetOut(buf)
if err := cmd.ExecuteContext(ctx); err != nil {
return "", fmt.Errorf("error deleting resources: %w", err)
}
return buf.String(), nil
}