Skip to content

Commit b6556b5

Browse files
committed
Merge remote-tracking branch 'origin/main' into k0s-1-29
2 parents 7254e49 + fa6f101 commit b6556b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+221
-199
lines changed

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ PREVIOUS_K0S_GO_VERSION ?= v1.28.14+k0s.0
1717
K0S_BINARY_SOURCE_OVERRIDE =
1818
TROUBLESHOOT_VERSION = v0.112.1
1919

20-
KOTS_VERSION = v$(shell awk '/^version/{print $$2}' pkg/addons2/adminconsole/static/metadata.yaml | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
20+
KOTS_VERSION = v$(shell awk '/^version/{print $$2}' pkg/addons/adminconsole/static/metadata.yaml | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
2121
# When updating KOTS_BINARY_URL_OVERRIDE, also update the KOTS_VERSION above or
2222
# scripts/ci-upload-binaries.sh may find the version in the cache and not upload the overridden binary.
2323
KOTS_BINARY_URL_OVERRIDE =
@@ -50,13 +50,13 @@ LD_FLAGS = \
5050
-X github.com/replicatedhq/embedded-cluster/pkg/versions.K0sBinaryURLOverride=$(METADATA_K0S_BINARY_URL_OVERRIDE) \
5151
-X github.com/replicatedhq/embedded-cluster/pkg/versions.KOTSBinaryURLOverride=$(METADATA_KOTS_BINARY_URL_OVERRIDE) \
5252
-X github.com/replicatedhq/embedded-cluster/pkg/versions.OperatorBinaryURLOverride=$(METADATA_OPERATOR_BINARY_URL_OVERRIDE) \
53-
-X github.com/replicatedhq/embedded-cluster/pkg/addons2/adminconsole.ChartRepoOverride=$(ADMIN_CONSOLE_CHART_REPO_OVERRIDE) \
54-
-X github.com/replicatedhq/embedded-cluster/pkg/addons2/adminconsole.KurlProxyImageOverride=$(ADMIN_CONSOLE_KURL_PROXY_IMAGE_OVERRIDE) \
55-
-X github.com/replicatedhq/embedded-cluster/pkg/addons2/adminconsole.KotsVersion=$(KOTS_VERSION) \
56-
-X github.com/replicatedhq/embedded-cluster/pkg/addons2/adminconsole.AdminConsoleChartRepoOverride=$(ADMIN_CONSOLE_CHART_REPO_OVERRIDE) \
57-
-X github.com/replicatedhq/embedded-cluster/pkg/addons2/adminconsole.AdminConsoleImageOverride=$(ADMIN_CONSOLE_IMAGE_OVERRIDE) \
58-
-X github.com/replicatedhq/embedded-cluster/pkg/addons2/adminconsole.AdminConsoleMigrationsImageOverride=$(ADMIN_CONSOLE_MIGRATIONS_IMAGE_OVERRIDE) \
59-
-X github.com/replicatedhq/embedded-cluster/pkg/addons2/adminconsole.AdminConsoleKurlProxyImageOverride=$(ADMIN_CONSOLE_KURL_PROXY_IMAGE_OVERRIDE)
53+
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.ChartRepoOverride=$(ADMIN_CONSOLE_CHART_REPO_OVERRIDE) \
54+
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.KurlProxyImageOverride=$(ADMIN_CONSOLE_KURL_PROXY_IMAGE_OVERRIDE) \
55+
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.KotsVersion=$(KOTS_VERSION) \
56+
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.AdminConsoleChartRepoOverride=$(ADMIN_CONSOLE_CHART_REPO_OVERRIDE) \
57+
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.AdminConsoleImageOverride=$(ADMIN_CONSOLE_IMAGE_OVERRIDE) \
58+
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.AdminConsoleMigrationsImageOverride=$(ADMIN_CONSOLE_MIGRATIONS_IMAGE_OVERRIDE) \
59+
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.AdminConsoleKurlProxyImageOverride=$(ADMIN_CONSOLE_KURL_PROXY_IMAGE_OVERRIDE)
6060
DISABLE_FIO_BUILD ?= 0
6161

6262
export PATH := $(shell pwd)/bin:$(PATH)

cmd/buildtools/adminconsole.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"strings"
66

7-
"github.com/replicatedhq/embedded-cluster/pkg/addons2/adminconsole"
7+
"github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole"
88
"github.com/replicatedhq/embedded-cluster/pkg/helm"
99
"github.com/replicatedhq/embedded-cluster/pkg/release"
1010
"github.com/sirupsen/logrus"

cmd/buildtools/embeddedclusteroperator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"os"
77
"strings"
88

9-
"github.com/replicatedhq/embedded-cluster/pkg/addons2/embeddedclusteroperator"
9+
"github.com/replicatedhq/embedded-cluster/pkg/addons/embeddedclusteroperator"
1010
"github.com/replicatedhq/embedded-cluster/pkg/helm"
1111
"github.com/replicatedhq/embedded-cluster/pkg/release"
1212
"github.com/sirupsen/logrus"

cmd/buildtools/openebs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"os"
77
"strings"
88

9-
"github.com/replicatedhq/embedded-cluster/pkg/addons2/openebs"
9+
"github.com/replicatedhq/embedded-cluster/pkg/addons/openebs"
1010
"github.com/replicatedhq/embedded-cluster/pkg/helm"
1111
"github.com/replicatedhq/embedded-cluster/pkg/release"
1212
"github.com/sirupsen/logrus"

cmd/buildtools/registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/urfave/cli/v2"
99
"helm.sh/helm/v3/pkg/repo"
1010

11-
"github.com/replicatedhq/embedded-cluster/pkg/addons2/registry"
11+
"github.com/replicatedhq/embedded-cluster/pkg/addons/registry"
1212
"github.com/replicatedhq/embedded-cluster/pkg/helm"
1313
"github.com/replicatedhq/embedded-cluster/pkg/release"
1414
)

cmd/buildtools/seaweedfs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"os"
77
"strings"
88

9-
"github.com/replicatedhq/embedded-cluster/pkg/addons2/seaweedfs"
9+
"github.com/replicatedhq/embedded-cluster/pkg/addons/seaweedfs"
1010
"github.com/replicatedhq/embedded-cluster/pkg/helm"
1111
"github.com/replicatedhq/embedded-cluster/pkg/release"
1212
"github.com/sirupsen/logrus"

cmd/buildtools/velero.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88

99
"github.com/Masterminds/semver/v3"
10-
"github.com/replicatedhq/embedded-cluster/pkg/addons2/velero"
10+
"github.com/replicatedhq/embedded-cluster/pkg/addons/velero"
1111
"github.com/replicatedhq/embedded-cluster/pkg/helm"
1212
"github.com/replicatedhq/embedded-cluster/pkg/release"
1313
"github.com/sirupsen/logrus"

cmd/installer/cli/adminconsole_resetpassword.go

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,47 @@ import (
77
"os"
88

99
"github.com/replicatedhq/embedded-cluster/cmd/installer/kotscli"
10+
"github.com/replicatedhq/embedded-cluster/pkg/prompts"
1011
rcutil "github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig/util"
1112
"github.com/sirupsen/logrus"
1213
"github.com/spf13/cobra"
1314
)
1415

1516
func AdminConsoleResetPasswordCmd(ctx context.Context, name string) *cobra.Command {
1617
cmd := &cobra.Command{
17-
Use: "reset-password",
18-
Short: fmt.Sprintf("Reset the %s Admin Console password", name),
18+
Use: "reset-password [password]",
19+
Short: fmt.Sprintf("Reset the %s Admin Console password. If no password is provided, you will be prompted to enter a new one.", name),
1920
PreRunE: func(cmd *cobra.Command, args []string) error {
2021
if os.Getuid() != 0 {
2122
return fmt.Errorf("reset-password command must be run as root")
2223
}
23-
if len(args) != 1 {
24-
return fmt.Errorf("expected admin console password as argument")
24+
if len(args) > 1 {
25+
return fmt.Errorf("too many arguments provided")
2526
}
26-
2727
return nil
2828
},
2929
RunE: func(cmd *cobra.Command, args []string) error {
3030
if err := rcutil.InitRuntimeConfigFromCluster(ctx); err != nil {
3131
return fmt.Errorf("failed to init runtime config from cluster: %w", err)
3232
}
3333

34-
password := args[0]
35-
if !validateAdminConsolePassword(password, password) {
36-
return NewErrorNothingElseToAdd(errors.New("password is not valid"))
34+
var password string
35+
if len(args) == 1 {
36+
password = args[0]
37+
} else {
38+
maxTries := 3
39+
for i := 0; i < maxTries; i++ {
40+
promptA := prompts.New().Password(fmt.Sprintf("Set the Admin Console password (minimum %d characters):", minAdminPasswordLength))
41+
promptB := prompts.New().Password("Confirm the Admin Console password:")
42+
43+
if validateAdminConsolePassword(promptA, promptB) {
44+
password = promptA
45+
break
46+
}
47+
}
48+
if password == "" {
49+
return NewErrorNothingElseToAdd(errors.New("password is not valid"))
50+
}
3751
}
3852

3953
if err := kotscli.ResetPassword(password); err != nil {

cmd/installer/cli/install2.go renamed to cmd/installer/cli/install.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import (
2020
ecv1beta1 "github.com/replicatedhq/embedded-cluster/kinds/apis/v1beta1"
2121
"github.com/replicatedhq/embedded-cluster/kinds/types"
2222
"github.com/replicatedhq/embedded-cluster/operator/charts"
23-
"github.com/replicatedhq/embedded-cluster/pkg/addons2"
24-
"github.com/replicatedhq/embedded-cluster/pkg/addons2/adminconsole"
25-
"github.com/replicatedhq/embedded-cluster/pkg/addons2/embeddedclusteroperator"
23+
"github.com/replicatedhq/embedded-cluster/pkg/addons"
24+
"github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole"
25+
"github.com/replicatedhq/embedded-cluster/pkg/addons/embeddedclusteroperator"
2626
"github.com/replicatedhq/embedded-cluster/pkg/airgap"
2727
"github.com/replicatedhq/embedded-cluster/pkg/config"
2828
"github.com/replicatedhq/embedded-cluster/pkg/configutils"
@@ -54,7 +54,7 @@ import (
5454
"sigs.k8s.io/yaml"
5555
)
5656

57-
type Install2CmdFlags struct {
57+
type InstallCmdFlags struct {
5858
adminConsolePassword string
5959
adminConsolePort int
6060
airgapBundle string
@@ -78,18 +78,18 @@ type Install2CmdFlags struct {
7878
cidrCfg *CIDRConfig
7979
}
8080

81-
// Install2Cmd returns a cobra command for installing the embedded cluster.
81+
// InstallCmd returns a cobra command for installing the embedded cluster.
8282
// This is the upcoming version of install without the operator and where
8383
// install does all of the work. This is a hidden command until it's tested
8484
// and ready.
85-
func Install2Cmd(ctx context.Context, name string) *cobra.Command {
86-
var flags Install2CmdFlags
85+
func InstallCmd(ctx context.Context, name string) *cobra.Command {
86+
var flags InstallCmdFlags
8787

8888
cmd := &cobra.Command{
8989
Use: "install",
9090
Short: fmt.Sprintf("Install %s", name),
9191
PreRunE: func(cmd *cobra.Command, args []string) error {
92-
if err := preRunInstall2(cmd, &flags); err != nil {
92+
if err := preRunInstall(cmd, &flags); err != nil {
9393
return err
9494
}
9595

@@ -102,7 +102,7 @@ func Install2Cmd(ctx context.Context, name string) *cobra.Command {
102102
clusterID := metrics.ClusterID()
103103
metricsReporter := NewInstallReporter(flags.license, clusterID, cmd.CalledAs())
104104
metricsReporter.ReportInstallationStarted(ctx)
105-
if err := runInstall2(cmd.Context(), name, flags, metricsReporter); err != nil {
105+
if err := runInstall(cmd.Context(), name, flags, metricsReporter); err != nil {
106106
metricsReporter.ReportInstallationFailed(ctx, err)
107107
return err
108108
}
@@ -123,7 +123,7 @@ func Install2Cmd(ctx context.Context, name string) *cobra.Command {
123123
return cmd
124124
}
125125

126-
func addInstallFlags(cmd *cobra.Command, flags *Install2CmdFlags) error {
126+
func addInstallFlags(cmd *cobra.Command, flags *InstallCmdFlags) error {
127127
cmd.Flags().StringVar(&flags.airgapBundle, "airgap-bundle", "", "Path to the air gap bundle. If set, the installation will complete without internet access.")
128128
cmd.Flags().StringVar(&flags.dataDir, "data-dir", ecv1beta1.DefaultDataDir, "Path to the data directory")
129129
cmd.Flags().IntVar(&flags.localArtifactMirrorPort, "local-artifact-mirror-port", ecv1beta1.DefaultLocalArtifactMirrorPort, "Port on which the Local Artifact Mirror will be served")
@@ -157,7 +157,7 @@ func addInstallFlags(cmd *cobra.Command, flags *Install2CmdFlags) error {
157157
return nil
158158
}
159159

160-
func addInstallAdminConsoleFlags(cmd *cobra.Command, flags *Install2CmdFlags) error {
160+
func addInstallAdminConsoleFlags(cmd *cobra.Command, flags *InstallCmdFlags) error {
161161
cmd.Flags().StringVar(&flags.adminConsolePassword, "admin-console-password", "", "Password for the Admin Console")
162162
cmd.Flags().IntVar(&flags.adminConsolePort, "admin-console-port", ecv1beta1.DefaultAdminConsolePort, "Port on which the Admin Console will be served")
163163
cmd.Flags().StringVarP(&flags.licenseFile, "license", "l", "", "Path to the license file")
@@ -169,7 +169,7 @@ func addInstallAdminConsoleFlags(cmd *cobra.Command, flags *Install2CmdFlags) er
169169
return nil
170170
}
171171

172-
func preRunInstall2(cmd *cobra.Command, flags *Install2CmdFlags) error {
172+
func preRunInstall(cmd *cobra.Command, flags *InstallCmdFlags) error {
173173
if os.Getuid() != 0 {
174174
return fmt.Errorf("install command must be run as root")
175175
}
@@ -228,7 +228,7 @@ func preRunInstall2(cmd *cobra.Command, flags *Install2CmdFlags) error {
228228
return nil
229229
}
230230

231-
func runInstall2(ctx context.Context, name string, flags Install2CmdFlags, metricsReporter preflights.MetricsReporter) error {
231+
func runInstall(ctx context.Context, name string, flags InstallCmdFlags, metricsReporter preflights.MetricsReporter) error {
232232
if err := runInstallVerifyAndPrompt(ctx, name, &flags); err != nil {
233233
return err
234234
}
@@ -329,7 +329,7 @@ func runInstall2(ctx context.Context, name string, flags Install2CmdFlags, metri
329329
defer hcli.Close()
330330

331331
logrus.Debugf("installing addons")
332-
if err := addons2.Install(ctx, hcli, addons2.InstallOptions{
332+
if err := addons.Install(ctx, hcli, addons.InstallOptions{
333333
AdminConsolePwd: flags.adminConsolePassword,
334334
License: flags.license,
335335
IsAirgap: flags.airgapBundle != "",
@@ -373,7 +373,7 @@ func runInstall2(ctx context.Context, name string, flags Install2CmdFlags, metri
373373
return nil
374374
}
375375

376-
func runInstallVerifyAndPrompt(ctx context.Context, name string, flags *Install2CmdFlags) error {
376+
func runInstallVerifyAndPrompt(ctx context.Context, name string, flags *InstallCmdFlags) error {
377377
logrus.Debugf("checking if k0s is already installed")
378378
err := verifyNoInstallation(name, "reinstall")
379379
if err != nil {
@@ -415,7 +415,7 @@ func runInstallVerifyAndPrompt(ctx context.Context, name string, flags *Install2
415415
return nil
416416
}
417417

418-
func ensureAdminConsolePassword(flags *Install2CmdFlags) error {
418+
func ensureAdminConsolePassword(flags *InstallCmdFlags) error {
419419
if flags.adminConsolePassword == "" {
420420
// no password was provided
421421
if flags.assumeYes {
@@ -898,7 +898,7 @@ func waitForK0s() error {
898898
}
899899
}
900900

901-
func recordInstallation(ctx context.Context, kcli client.Client, flags Install2CmdFlags, k0sCfg *k0sv1beta1.ClusterConfig, disasterRecoveryEnabled bool) (*ecv1beta1.Installation, error) {
901+
func recordInstallation(ctx context.Context, kcli client.Client, flags InstallCmdFlags, k0sCfg *k0sv1beta1.ClusterConfig, disasterRecoveryEnabled bool) (*ecv1beta1.Installation, error) {
902902
loading := spinner.Start()
903903
defer loading.Close()
904904
loading.Infof("Creating types")
@@ -1061,7 +1061,7 @@ func createVersionMetadataConfigmap(ctx context.Context, kcli client.Client) err
10611061
// when deploying them.
10621062
func gatherVersionMetadata(withChannelRelease bool) (*types.ReleaseMetadata, error) {
10631063
versionsMap := map[string]string{}
1064-
for name, version := range addons2.Versions() {
1064+
for name, version := range addons.Versions() {
10651065
versionsMap[name] = version
10661066
}
10671067
if withChannelRelease {
@@ -1108,7 +1108,7 @@ func gatherVersionMetadata(withChannelRelease bool) (*types.ReleaseMetadata, err
11081108
Artifacts: artifacts,
11091109
}
11101110

1111-
chtconfig, repconfig, err := addons2.GenerateChartConfigs()
1111+
chtconfig, repconfig, err := addons.GenerateChartConfigs()
11121112
if err != nil {
11131113
return nil, fmt.Errorf("unable to generate chart configs: %w", err)
11141114
}
@@ -1128,12 +1128,12 @@ func gatherVersionMetadata(withChannelRelease bool) (*types.ReleaseMetadata, err
11281128

11291129
k0sCfg := config.RenderK0sConfig()
11301130
meta.K0sImages = config.ListK0sImages(k0sCfg)
1131-
meta.K0sImages = append(meta.K0sImages, addons2.GetAdditionalImages()...)
1131+
meta.K0sImages = append(meta.K0sImages, addons.GetAdditionalImages()...)
11321132
meta.K0sImages = helpers.UniqueStringSlice(meta.K0sImages)
11331133
sort.Strings(meta.K0sImages)
11341134

11351135
meta.Images = config.ListK0sImages(k0sCfg)
1136-
meta.Images = append(meta.Images, addons2.GetImages()...)
1136+
meta.Images = append(meta.Images, addons.GetImages()...)
11371137
meta.Images = append(meta.Images, versions.LocalArtifactMirrorImage)
11381138
meta.Images = helpers.UniqueStringSlice(meta.Images)
11391139
sort.Strings(meta.Images)

cmd/installer/cli/install_runpreflights.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import (
1313
)
1414

1515
func InstallRunPreflightsCmd(ctx context.Context, name string) *cobra.Command {
16-
var flags Install2CmdFlags
16+
var flags InstallCmdFlags
1717

1818
cmd := &cobra.Command{
1919
Use: "run-preflights",
2020
Short: "Run install host preflights",
2121
PreRunE: func(cmd *cobra.Command, args []string) error {
22-
if err := preRunInstall2(cmd, &flags); err != nil {
22+
if err := preRunInstall(cmd, &flags); err != nil {
2323
return err
2424
}
2525

@@ -47,7 +47,7 @@ func InstallRunPreflightsCmd(ctx context.Context, name string) *cobra.Command {
4747
return cmd
4848
}
4949

50-
func runInstallRunPreflights(ctx context.Context, name string, flags Install2CmdFlags) error {
50+
func runInstallRunPreflights(ctx context.Context, name string, flags InstallCmdFlags) error {
5151
if err := runInstallVerifyAndPrompt(ctx, name, &flags); err != nil {
5252
return err
5353
}
@@ -74,7 +74,7 @@ func runInstallRunPreflights(ctx context.Context, name string, flags Install2Cmd
7474
return nil
7575
}
7676

77-
func runInstallPreflights(ctx context.Context, flags Install2CmdFlags, metricsReported preflights.MetricsReporter) error {
77+
func runInstallPreflights(ctx context.Context, flags InstallCmdFlags, metricsReported preflights.MetricsReporter) error {
7878
var replicatedAPIURL, proxyRegistryURL string
7979
if flags.license != nil {
8080
replicatedAPIURL = flags.license.Spec.Endpoint

0 commit comments

Comments
 (0)