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:
parent
4d4360b86b
commit
bc29419c17
17 changed files with 354 additions and 182 deletions
23
pkg/libkubectl/restart.go
Normal file
23
pkg/libkubectl/restart.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
package libkubectl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"k8s.io/kubectl/pkg/cmd/rollout"
|
||||
)
|
||||
|
||||
func (c *Client) RolloutRestart(ctx context.Context, manifests []string) (string, error) {
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
cmd := rollout.NewCmdRollout(c.factory, c.streams)
|
||||
cmd.SetArgs(manifestFilesToArgs(manifests))
|
||||
cmd.SetOut(buf)
|
||||
|
||||
if err := cmd.ExecuteContext(ctx); err != nil {
|
||||
return "", fmt.Errorf("error restarting resources: %w", err)
|
||||
}
|
||||
|
||||
return buf.String(), nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue