Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -1181,15 +1181,15 @@ License URL: https://github.com/gomodules/jsonpatch/blob/v2.5.0/v2/LICENSE

----------
Module: google.golang.org/api
Version: v0.286.0
Version: v0.287.0
License: BSD-3-Clause
License URL: https://github.com/googleapis/google-api-go-client/blob/v0.286.0/LICENSE
License URL: https://github.com/googleapis/google-api-go-client/blob/v0.287.0/LICENSE

----------
Module: google.golang.org/api/internal/third_party/uritemplates
Version: v0.286.0
Version: v0.287.0
License: BSD-3-Clause
License URL: https://github.com/googleapis/google-api-go-client/blob/v0.286.0/internal/third_party/uritemplates/LICENSE
License URL: https://github.com/googleapis/google-api-go-client/blob/v0.287.0/internal/third_party/uritemplates/LICENSE

----------
Module: google.golang.org/genproto/googleapis
Expand All @@ -1211,9 +1211,9 @@ License URL: https://github.com/googleapis/go-genproto/blob/b703f567277d/googlea

----------
Module: google.golang.org/grpc
Version: v1.81.1
Version: v1.82.0
License: Apache-2.0
License URL: https://github.com/grpc/grpc-go/blob/v1.81.1/LICENSE
License URL: https://github.com/grpc/grpc-go/blob/v1.82.0/LICENSE

----------
Module: google.golang.org/protobuf
Expand Down
21 changes: 15 additions & 6 deletions cli/cmd/bootstrap_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ type BootstrapGcpCmd struct {
CodesphereEnv *gcp.CodesphereEnvironment
InputRegistryType string
SSHQuiet bool
FeatureFlagList []string
// experiments backs the deprecated --experiments flag; its values
// are folded into the internal bucket for backwards compatibility.
experiments []string
}

func (c *BootstrapGcpCmd) RunE(_ *cobra.Command, args []string) error {
Expand All @@ -53,7 +55,7 @@ func AddBootstrapGcpCmd(parent *cobra.Command, opts *GlobalOptions) {
},
Opts: opts,
Env: env.NewEnv(),
CodesphereEnv: &gcp.CodesphereEnvironment{FeatureFlags: map[string]bool{}},
CodesphereEnv: &gcp.CodesphereEnvironment{},
}
bootstrapGcpCmd.cmd.RunE = bootstrapGcpCmd.RunE

Expand Down Expand Up @@ -97,8 +99,11 @@ func AddBootstrapGcpCmd(parent *cobra.Command, opts *GlobalOptions) {
flags.StringArrayVarP(&bootstrapGcpCmd.CodesphereEnv.InstallSkipSteps, "install-skip-steps", "s", []string{}, "Installation steps to skip during Codesphere installation (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.RegistryUser, "registry-user", "", "Custom Registry username (only for GitHub registry type) (optional)")
flags.StringVar(&bootstrapGcpCmd.InputRegistryType, "registry-type", "local-container", "Container registry type to use (options: local-container, artifact-registry) (default: local-container)")
flags.StringArrayVar(&bootstrapGcpCmd.CodesphereEnv.Experiments, "experiments", gcp.DefaultExperiments, "Experiments to enable in Codesphere installation (optional)")
flags.StringArrayVar(&bootstrapGcpCmd.FeatureFlagList, "feature-flags", []string{}, "Feature flags to enable in Codesphere installation (optional)")
flags.StringArrayVar(&bootstrapGcpCmd.CodesphereEnv.InternalFlags, "internal-flags", gcp.DefaultInternalFlags, "Internal flags to enable in Codesphere installation (optional)")
flags.StringArrayVar(&bootstrapGcpCmd.experiments, "experiments", []string{}, "Deprecated: use --internal-flags instead. Values are added to the internal flags.")
_ = flags.MarkDeprecated("experiments", "use --internal-flags instead")
flags.StringArrayVar(&bootstrapGcpCmd.CodesphereEnv.PreviewFlags, "preview-flags", gcp.DefaultPreviewFlags, "Preview flags to enable in Codesphere installation (optional)")
flags.StringArrayVar(&bootstrapGcpCmd.CodesphereEnv.FeatureFlags, "feature-flags", gcp.DefaultFeatureFlags, "Feature flags to enable in Codesphere installation (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.ExternalLokiEndpoint, "external-loki-endpoint", "", "External Loki endpoint for Grafana Alloy log forwarding (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.ExternalLokiSecret, "external-loki-secret", "", "External Loki password stored in the generated vault (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.ExternalLokiUser, "external-loki-user", "", "External Loki username for Grafana Alloy log forwarding (optional)")
Expand Down Expand Up @@ -172,8 +177,12 @@ func (c *BootstrapGcpCmd) BootstrapGcp() error {
}
}

for _, flag := range c.FeatureFlagList {
c.CodesphereEnv.FeatureFlags[flag] = true
if c.cmd.Flags().Changed("experiments") {
if c.cmd.Flags().Changed("internal-flags") {
log.Printf("Warning: both --experiments and --internal-flags were set; ignoring deprecated --experiments values %v", c.experiments)
} else {
c.CodesphereEnv.InternalFlags = c.experiments
}
}

err = bs.Bootstrap()
Expand Down
26 changes: 18 additions & 8 deletions cli/cmd/bootstrap_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"errors"
"fmt"
stdio "io"
"log"
"os"
"os/exec"
"path/filepath"
Expand All @@ -35,10 +36,12 @@ import (
)

type BootstrapLocalCmd struct {
cmd *cobra.Command
CodesphereEnv *local.CodesphereEnvironment
Yes bool
FeatureFlagList []string
cmd *cobra.Command
CodesphereEnv *local.CodesphereEnvironment
Yes bool
// Experiments backs the deprecated --experiments flag; its values
// are folded into the internal bucket for backwards compatibility.
experiments []string
}

func (c *BootstrapLocalCmd) RunE(_ *cobra.Command, args []string) error {
Expand Down Expand Up @@ -75,8 +78,11 @@ func AddBootstrapLocalCmd(parent *cobra.Command) {

// Codesphere Environment
flags.StringVar(&bootstrapLocalCmd.CodesphereEnv.BaseDomain, "base-domain", "cs.local", "Base domain for Codesphere")
flags.StringArrayVar(&bootstrapLocalCmd.CodesphereEnv.Experiments, "experiments", gcp.DefaultExperiments, "Experiments to enable in Codesphere installation (optional)")
flags.StringArrayVar(&bootstrapLocalCmd.FeatureFlagList, "feature-flags", []string{}, "Feature flags to enable in Codesphere installation (optional)")
flags.StringArrayVar(&bootstrapLocalCmd.CodesphereEnv.InternalFlags, "internal-flags", gcp.DefaultInternalFlags, "Internal flags to enable in Codesphere installation (optional)")
flags.StringArrayVar(&bootstrapLocalCmd.experiments, "experiments", []string{}, "Deprecated: use --internal-flags instead. Values are added to the internal flags.")
_ = flags.MarkDeprecated("experiments", "use --internal-flags instead")
flags.StringArrayVar(&bootstrapLocalCmd.CodesphereEnv.PreviewFlags, "preview-flags", gcp.DefaultPreviewFlags, "Preview flags to enable in Codesphere installation (optional)")
flags.StringArrayVar(&bootstrapLocalCmd.CodesphereEnv.FeatureFlags, "feature-flags", gcp.DefaultFeatureFlags, "Feature flags to enable in Codesphere installation (optional)")
flags.StringVar(&bootstrapLocalCmd.CodesphereEnv.Profile, "profile", installer.PROFILE_DEV, "Profile to apply to the install config like resources (supported: dev, minimal, prod)")
flags.BoolVar(&bootstrapLocalCmd.CodesphereEnv.K0s, "k0s", false, "Use k0s-specific configuration (required to deploy to k0s clusters)")

Expand Down Expand Up @@ -124,8 +130,12 @@ func (c *BootstrapLocalCmd) BootstrapLocal() error {
return err
}

for _, flag := range c.FeatureFlagList {
c.CodesphereEnv.FeatureFlags[flag] = true
if c.cmd.Flags().Changed("experiments") {
if c.cmd.Flags().Changed("internal-flags") {
log.Printf("Warning: both --experiments and --internal-flags were set; ignoring deprecated --experiments values %v", c.experiments)
} else {
c.CodesphereEnv.InternalFlags = c.experiments
}
}

stlog := bootstrap.NewStepLogger(false)
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/download_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func AddDownloadPackageCmd(download *cobra.Command, opts *GlobalOptions) {

pkg.cmd.Flags().StringVarP(&pkg.Opts.Version, "version", "V", "", "Codesphere version to download")
pkg.cmd.Flags().StringVarP(&pkg.Opts.Hash, "hash", "H", "", "Hash of the version to download if multiple builds exist for the same version")
pkg.cmd.Flags().StringVarP(&pkg.Opts.Filename, "file", "f", "installer.tar.gz", "Specify artifact to download")
pkg.cmd.Flags().StringVarP(&pkg.Opts.Filename, "file", "f", "installer-lite.tar.gz", "Specify artifact to download")
pkg.cmd.Flags().BoolVarP(&pkg.Opts.Quiet, "quiet", "q", false, "Suppress progress output during download")
AddCmd(download, pkg.cmd)

Expand Down
4 changes: 3 additions & 1 deletion cli/cmd/init_install_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ codesphere:
cNameBaseDomain: custom.example.com
dnsServers:
- 8.8.8.8
experiments: []
internal: []
preview: {}
features: {}
deployConfig:
images:
ubuntu-24.04:
Expand Down
1 change: 1 addition & 0 deletions cli/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ func AddInstallCmd(rootCmd *cobra.Command, opts *GlobalOptions) {
AddInstallCodesphereCmd(install.cmd, opts)
AddInstallK0sCmd(install.cmd, opts)
AddInstallOpenBaoCmd(install.cmd, opts)
AddInstallDockerCmd(install.cmd, opts)
}
2 changes: 1 addition & 1 deletion cli/cmd/install_codesphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func AddInstallCodesphereCmd(install *cobra.Command, opts *GlobalOptions) {
Opts: &InstallCodesphereOpts{GlobalOptions: opts},
Env: env.NewEnv(),
}
codesphere.cmd.PersistentFlags().StringVarP(&codesphere.Opts.Package, "package", "p", "", "Package file (e.g. codesphere-v1.2.3-installer.tar.gz) to load binaries, installer etc. from")
codesphere.cmd.PersistentFlags().StringVarP(&codesphere.Opts.Package, "package", "p", "", "Package file (e.g. codesphere-v1.2.3-installer-lite.tar.gz) to load binaries, installer etc. from")
codesphere.cmd.PersistentFlags().BoolVarP(&codesphere.Opts.Force, "force", "f", false, "Enforce package extraction")
codesphere.cmd.PersistentFlags().StringArrayVarP(&codesphere.Opts.Configs, "config", "c", nil, "Path to a Codesphere Private Cloud configuration file (yaml). Can be specified multiple times and merged in order")
codesphere.cmd.PersistentFlags().StringVar(&codesphere.Opts.Vault, "vault", "", "Path to the SOPS-encrypted prod.vault.yaml file used for config templating")
Expand Down
27 changes: 21 additions & 6 deletions cli/cmd/install_codesphere_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"fmt"
"os"
"path/filepath"
"runtime"
"strings"

Expand Down Expand Up @@ -118,10 +119,14 @@ type argoCDAndAppsInstall struct {
}

func (i *argoCDAndAppsInstall) loadVaultData() error {
var err error
i.vault, err = installer.LoadVaultData(i.opts.Vault, i.opts.PrivKey)
vaultPath, err := i.resolveVaultPath()
if err != nil {
return err
}

i.vault, err = installer.LoadVaultData(vaultPath, i.opts.PrivKey)
if err != nil {
return fmt.Errorf("failed to load vault: %w", err)
return fmt.Errorf("failed to load vault %s: %w", vaultPath, err)
}
if s := i.vault.GetSecret(files.SecretRegistryPassword); s != nil && s.Fields != nil {
i.ociPassword = s.Fields.Password
Expand All @@ -145,6 +150,16 @@ func (i *argoCDAndAppsInstall) loadVaultData() error {
return nil
}

func (i *argoCDAndAppsInstall) resolveVaultPath() (string, error) {
if strings.TrimSpace(i.opts.Vault) != "" {
return i.opts.Vault, nil
}
if strings.TrimSpace(i.config.Secrets.BaseDir) == "" {
return "", fmt.Errorf("vault path is not set and config.yaml secrets.baseDir is empty")
}
return filepath.Join(i.config.Secrets.BaseDir, "prod.vault.yaml"), nil
}

func (i *argoCDAndAppsInstall) installArgoCD() error {
i.ociRegistryURL = i.opts.ArgoCDRegistryURL
if i.ociRegistryURL == "" && i.config.Registry != nil {
Expand Down Expand Up @@ -224,15 +239,15 @@ func AddInstallCodesphereDepenciesCmd(codesphere *cobra.Command, opts *InstallCo
Pass --skip-steps argocd or add argocd to operations.skip to skip the ArgoCD pre-step.`),
Example: formatExamples("install codesphere dependencies", []io.Example{
{
Cmd: "-p codesphere-v1.2.3-installer.tar.gz -k <path-to-private-key> -c config.yaml",
Cmd: "-p codesphere-v1.2.3-installer-lite.tar.gz -k <path-to-private-key> -c config.yaml",
Desc: "Install cluster dependencies (including ArgoCD)",
},
{
Cmd: "-p codesphere-v1.2.3-installer.tar.gz -k <path-to-private-key> -c config.yaml -s argocd",
Cmd: "-p codesphere-v1.2.3-installer-lite.tar.gz -k <path-to-private-key> -c config.yaml -s argocd",
Desc: "Install cluster dependencies without the ArgoCD pre-step",
},
{
Cmd: "-p codesphere-v1.2.3-installer.tar.gz -k <path-to-private-key> -c config.yaml --pc-apps-values base.yaml --pc-apps-values dc-overlay.yaml",
Cmd: "-p codesphere-v1.2.3-installer-lite.tar.gz -k <path-to-private-key> -c config.yaml --pc-apps-values base.yaml --pc-apps-values dc-overlay.yaml",
Desc: "Install cluster dependencies with custom pc-apps values files",
},
}),
Expand Down
74 changes: 74 additions & 0 deletions cli/cmd/install_codesphere_dependencies_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright (c) Codesphere Inc.
// SPDX-License-Identifier: Apache-2.0

package cmd

import (
"os"
"path/filepath"

"github.com/codesphere-cloud/oms/internal/installer/files"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("argoCDAndAppsInstall.loadVaultData", func() {
It("falls back to config secrets.baseDir when --vault is not set", func() {
tmpDir := GinkgoT().TempDir()
secretsDir := filepath.Join(tmpDir, "secrets")
Expect(os.MkdirAll(secretsDir, 0700)).To(Succeed())

vault := &files.InstallVault{
Secrets: []files.SecretEntry{
{
Name: files.SecretRegistryPassword,
Fields: &files.SecretFields{
Password: "registry-password",
},
},
{
Name: files.SecretKubeConfig,
File: &files.SecretFile{
Name: "kubeconfig",
Content: `apiVersion: v1
kind: Config
clusters:
- name: test
cluster:
server: https://127.0.0.1:6443
contexts:
- name: test
context:
cluster: test
user: test
current-context: test
users:
- name: test
user:
token: test-token
`,
},
},
},
}
vaultYAML, err := vault.Marshal()
Expect(err).ToNot(HaveOccurred())
Expect(os.WriteFile(filepath.Join(secretsDir, "prod.vault.yaml"), vaultYAML, 0600)).To(Succeed())

install := &argoCDAndAppsInstall{
opts: &InstallCodesphereOpts{},
config: files.RootConfig{
Secrets: files.SecretsConfig{
BaseDir: secretsDir,
},
},
}

err = install.loadVaultData()
Expect(err).ToNot(HaveOccurred())
Expect(install.vault).ToNot(BeNil())
Expect(install.ociPassword).To(Equal("registry-password"))
Expect(install.kubeConfig).ToNot(BeNil())
Expect(install.kubeClient).ToNot(BeNil())
})
})
2 changes: 1 addition & 1 deletion cli/cmd/install_codesphere_infra.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func AddInstallCodesphereInfraCmd(codesphere *cobra.Command, opts *InstallCodesp
Runs steps: copy-dependencies, extract-dependencies, load-container-images, sops, docker, postgres, ceph, kubernetes.`),
Example: formatExamples("install codesphere infra", []io.Example{
{
Cmd: "-p codesphere-v1.2.3-installer.tar.gz -k <path-to-private-key> -c config.yaml",
Cmd: "-p codesphere-v1.2.3-installer-lite.tar.gz -k <path-to-private-key> -c config.yaml",
Desc: "Install infrastructure components only",
},
{
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/install_codesphere_platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func AddInstallCodespherePlatformCmd(codesphere *cobra.Command, opts *InstallCod
Requires the infrastructure and dependencies phases to have completed successfully.`),
Example: formatExamples("install codesphere platform", []io.Example{
{
Cmd: "-p codesphere-v1.2.3-installer.tar.gz -k <path-to-private-key> -c config.yaml",
Cmd: "-p codesphere-v1.2.3-installer-lite.tar.gz -k <path-to-private-key> -c config.yaml",
Desc: "Install Codesphere platform only",
},
}),
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/install_codesphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var _ = Describe("InstallCodesphereCmd", func() {
globalOpts = &cmd.GlobalOptions{}
opts = &cmd.InstallCodesphereOpts{
GlobalOptions: globalOpts,
Package: "codesphere-v1.66.0-installer.tar.gz",
Package: "codesphere-v1.66.0-installer-lite.tar.gz",
Force: false,
}
c = cmd.InstallCodesphereCmd{
Expand Down
Loading
Loading