2025-05-07 20:40:38 +12:00
|
|
|
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)
|
2025-05-13 11:35:44 +12:00
|
|
|
args := []string{"restart"}
|
|
|
|
args = append(args, resourcesToArgs(manifests)...)
|
|
|
|
|
|
|
|
cmd.SetArgs(args)
|
2025-05-07 20:40:38 +12:00
|
|
|
cmd.SetOut(buf)
|
|
|
|
|
|
|
|
if err := cmd.ExecuteContext(ctx); err != nil {
|
|
|
|
return "", fmt.Errorf("error restarting resources: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf.String(), nil
|
|
|
|
}
|