mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-06 14:04:17 -04:00
cli: add constellation apply
command to replace init
and upgrade apply
(#2484)
* Add apply command * Mark init and upgrade apply as deprecated * Use apply command in CI * Add skippable phases for attestation config and cert SANs --------- Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
a7eb3b119a
commit
149fedb90f
9 changed files with 168 additions and 79 deletions
|
@ -10,7 +10,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/cli/internal/state"
|
||||
|
@ -24,22 +23,6 @@ import (
|
|||
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
// skipInitPhase skips the init RPC of the apply process.
|
||||
skipInitPhase skipPhase = "init"
|
||||
// skipInfrastructurePhase skips the terraform apply of the upgrade process.
|
||||
skipInfrastructurePhase skipPhase = "infrastructure"
|
||||
// skipHelmPhase skips the helm upgrade of the upgrade process.
|
||||
skipHelmPhase skipPhase = "helm"
|
||||
// skipImagePhase skips the image upgrade of the upgrade process.
|
||||
skipImagePhase skipPhase = "image"
|
||||
// skipK8sPhase skips the k8s upgrade of the upgrade process.
|
||||
skipK8sPhase skipPhase = "k8s"
|
||||
)
|
||||
|
||||
// skipPhase is a phase of the upgrade process that can be skipped.
|
||||
type skipPhase string
|
||||
|
||||
func newUpgradeApplyCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "apply",
|
||||
|
@ -51,6 +34,7 @@ func newUpgradeApplyCmd() *cobra.Command {
|
|||
cmd.Flags().Bool("merge-kubeconfig", false, "")
|
||||
return runApply(cmd, args)
|
||||
},
|
||||
Deprecated: "use 'constellation apply' instead.",
|
||||
}
|
||||
|
||||
cmd.Flags().BoolP("yes", "y", false, "run upgrades without further confirmation\n"+
|
||||
|
@ -81,25 +65,6 @@ func diffAttestationCfg(currentAttestationCfg config.AttestationCfg, newAttestat
|
|||
return diff, nil
|
||||
}
|
||||
|
||||
// skipPhases is a list of phases that can be skipped during the upgrade process.
|
||||
type skipPhases map[skipPhase]struct{}
|
||||
|
||||
// contains returns true if the list of phases contains the given phase.
|
||||
func (s skipPhases) contains(phase skipPhase) bool {
|
||||
_, ok := s[skipPhase(strings.ToLower(string(phase)))]
|
||||
return ok
|
||||
}
|
||||
|
||||
// add a phase to the list of phases.
|
||||
func (s *skipPhases) add(phases ...skipPhase) {
|
||||
if *s == nil {
|
||||
*s = make(skipPhases)
|
||||
}
|
||||
for _, phase := range phases {
|
||||
(*s)[skipPhase(strings.ToLower(string(phase)))] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
type kubernetesUpgrader interface {
|
||||
UpgradeNodeVersion(ctx context.Context, conf *config.Config, force, skipImage, skipK8s bool) error
|
||||
ExtendClusterConfigCertSANs(ctx context.Context, alternativeNames []string) error
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue