cli: move helm and terraform out of kubernetes package (#2222)

Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
Daniel Weiße 2023-08-16 09:59:32 +02:00 committed by GitHub
parent f270e91724
commit ed0bfd9d41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 370 additions and 376 deletions

View file

@ -7,6 +7,10 @@ SPDX-License-Identifier: AGPL-3.0-only
package cmd
import (
"strings"
"time"
"github.com/google/uuid"
"github.com/spf13/cobra"
)
@ -23,3 +27,31 @@ func NewUpgradeCmd() *cobra.Command {
cmd.AddCommand(newUpgradeApplyCmd())
return cmd
}
// upgradeCmdKind is the kind of the upgrade command (check, apply).
type upgradeCmdKind int
const (
// upgradeCmdKindCheck corresponds to the upgrade check command.
upgradeCmdKindCheck upgradeCmdKind = iota
// upgradeCmdKindApply corresponds to the upgrade apply command.
upgradeCmdKindApply
// upgradeCmdKindIAM corresponds to the IAM upgrade command.
upgradeCmdKindIAM
)
func generateUpgradeID(kind upgradeCmdKind) string {
upgradeID := time.Now().Format("20060102150405") + "-" + strings.Split(uuid.New().String(), "-")[0]
switch kind {
case upgradeCmdKindCheck:
// When performing an upgrade check, the upgrade directory will only be used temporarily to store the
// Terraform state. The directory is deleted after the check is finished.
// Therefore, add a tmp-suffix to the upgrade ID to indicate that the directory will be cleared after the check.
upgradeID = "upgrade-" + upgradeID + "-tmp"
case upgradeCmdKindApply:
upgradeID = "upgrade-" + upgradeID
case upgradeCmdKindIAM:
upgradeID = "iam-" + upgradeID
}
return upgradeID
}