Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

runKubeadmUpgradeApply : add real dry run support #39

Open
github-actions bot opened this issue May 19, 2022 · 0 comments
Open

runKubeadmUpgradeApply : add real dry run support #39

github-actions bot opened this issue May 19, 2022 · 0 comments
Labels

Comments

@github-actions
Copy link

add real dry run support

// TODO: add real dry run support

import (
	"fmt"
	"strings"

	"github.com/go-logr/logr"
	"github.com/pkg/errors"

	operatorv1 "k8s.io/kubeadm/operator/api/v1alpha1"
)

// runKubeadmUpgradeApply runs the kubeadm upgrade apply command
func runKubeadmUpgradeApply(spec *operatorv1.KubeadmUpgradeApplyCommandSpec, log logr.Logger) error {
	var cmd *cmd
	// TODO: add real dry run support
	cmd = newCmd("kubeadm", "upgrade", "apply", spec.KubernetesVersion, "--yes", "--v=4")
	if spec.DryRun {
		cmd = newCmd("kubeadm", "upgrade", "apply", spec.KubernetesVersion, "--yes", "--dry-run", "--v=4")
	}

	lines, err := cmd.RunAndCapture()
	if err != nil {
		log.Error(err, "kubeadm upgrade apply failed", strings.Join(lines, "\n"))
		return errors.WithStack(errors.WithMessage(err, strings.Join(lines, "\n")))
	}

	log.Info(fmt.Sprintf("%s", strings.Join(lines, "\n")))

	return nil
}
ndex 5f59a43..bb89918 100644
++ b/config/crd/bases/operator.kubeadm.x-k8s.io_operations.yaml

7277cee350b74297c311eb83e67e2a2420c956c7

@github-actions github-actions bot added the todo label May 19, 2022
@pacoxu pacoxu changed the title add real dry run support runKubeadmUpgradeApply : add real dry run support May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

0 participants