Skip to content

Commit 070a1c2

Browse files
refac(cs-flags): Split experiments into internal and preview (#544)
Also enabled `workspace-ssh` preview flag by default (was handed over to SRE yesterday). --------- Signed-off-by: Nathanael Ruf <nathanael@codesphere.com>
1 parent 2a7814f commit 070a1c2

17 files changed

Lines changed: 247 additions & 126 deletions

cli/cmd/bootstrap_gcp.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ type BootstrapGcpCmd struct {
2828
CodesphereEnv *gcp.CodesphereEnvironment
2929
InputRegistryType string
3030
SSHQuiet bool
31-
FeatureFlagList []string
31+
// experiments backs the deprecated --experiments flag; its values
32+
// are folded into the internal bucket for backwards compatibility.
33+
experiments []string
3234
}
3335

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

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

175-
for _, flag := range c.FeatureFlagList {
176-
c.CodesphereEnv.FeatureFlags[flag] = true
180+
if c.cmd.Flags().Changed("experiments") {
181+
if c.cmd.Flags().Changed("internal-flags") {
182+
log.Printf("Warning: both --experiments and --internal-flags were set; ignoring deprecated --experiments values %v", c.experiments)
183+
} else {
184+
c.CodesphereEnv.InternalFlags = c.experiments
185+
}
177186
}
178187

179188
err = bs.Bootstrap()

cli/cmd/bootstrap_local.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"errors"
1010
"fmt"
1111
stdio "io"
12+
"log"
1213
"os"
1314
"os/exec"
1415
"path/filepath"
@@ -35,10 +36,12 @@ import (
3536
)
3637

3738
type BootstrapLocalCmd struct {
38-
cmd *cobra.Command
39-
CodesphereEnv *local.CodesphereEnvironment
40-
Yes bool
41-
FeatureFlagList []string
39+
cmd *cobra.Command
40+
CodesphereEnv *local.CodesphereEnvironment
41+
Yes bool
42+
// Experiments backs the deprecated --experiments flag; its values
43+
// are folded into the internal bucket for backwards compatibility.
44+
experiments []string
4245
}
4346

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

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

@@ -124,8 +130,12 @@ func (c *BootstrapLocalCmd) BootstrapLocal() error {
124130
return err
125131
}
126132

127-
for _, flag := range c.FeatureFlagList {
128-
c.CodesphereEnv.FeatureFlags[flag] = true
133+
if c.cmd.Flags().Changed("experiments") {
134+
if c.cmd.Flags().Changed("internal-flags") {
135+
log.Printf("Warning: both --experiments and --internal-flags were set; ignoring deprecated --experiments values %v", c.experiments)
136+
} else {
137+
c.CodesphereEnv.InternalFlags = c.experiments
138+
}
129139
}
130140

131141
stlog := bootstrap.NewStepLogger(false)

cli/cmd/init_install_config_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ codesphere:
110110
cNameBaseDomain: custom.example.com
111111
dnsServers:
112112
- 8.8.8.8
113-
experiments: []
113+
internal: []
114+
preview: {}
115+
features: {}
114116
deployConfig:
115117
images:
116118
ubuntu-24.04:

cli/cmd/update_install_config_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ codesphere:
126126
dnsServers:
127127
- 8.8.8.8
128128
- 8.8.4.4
129-
experiments: []
129+
internal: []
130+
preview: {}
131+
features: {}
130132
deployConfig:
131133
images: {}
132134
plans:

docs/oms_beta_bootstrap-gcp.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ oms beta bootstrap-gcp [flags]
3333
--datacenter-name string Datacenter name (default: dev) (default "dev")
3434
--dns-project-id string GCP Project ID for Cloud DNS (optional)
3535
--dns-zone-name string Cloud DNS Zone Name (optional) (default "oms-testing")
36-
--experiments stringArray Experiments to enable in Codesphere installation (optional) (default [headless-services,vcluster,custom-service-image,ms-in-ls,secret-management,sub-path-mount])
3736
--external-loki-endpoint string External Loki endpoint for Grafana Alloy log forwarding (optional)
3837
--external-loki-secret string External Loki password stored in the generated vault (optional)
3938
--external-loki-user string External Loki username for Grafana Alloy log forwarding (optional)
@@ -54,6 +53,7 @@ oms beta bootstrap-gcp [flags]
5453
--install-local string Install Codesphere from local package (default: none)
5554
-s, --install-skip-steps stringArray Installation steps to skip during Codesphere installation (optional)
5655
--install-version string Codesphere version to install (default: none)
56+
--internal-flags stringArray Internal flags to enable in Codesphere installation (optional) (default [headless-services,vcluster,custom-service-image,ms-in-ls])
5757
--local-trace-endpoint string Endpoint for exporting traces to an in-cluster storage (optional)
5858
--oidc-client-id string OIDC OAuth provider Client ID (optional)
5959
--oidc-client-secret string OIDC OAuth provider Client Secret (optional)
@@ -64,6 +64,7 @@ oms beta bootstrap-gcp [flags]
6464
--openbao-uri string URI for OpenBao (optional)
6565
--openbao-user string OpenBao username (optional) (default "admin")
6666
--preemptible Use preemptible VMs for Codesphere infrastructure. Mutually exclusive with --spot-vms (default: false)
67+
--preview-flags stringArray Preview flags to enable in Codesphere installation (optional) (default [secret-management,sub-path-mount,workspace-ssh])
6768
--project-name string Unique GCP Project Name (required)
6869
--project-ttl string Time to live for the GCP project. Cleanup workflows will remove it afterwards. (default: 2 hours) (default "2h")
6970
--prometheus-remote-write-password string Prometheus remote write password stored in the generated vault (optional)

docs/oms_beta_bootstrap-local.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,25 @@ oms beta bootstrap-local [flags]
1616
### Options
1717

1818
```
19-
--argocd After infra setup: install ArgoCD, update the OCI pull secret, and install pc-apps from the BOM version
20-
--base-domain string Base domain for Codesphere (default "cs.local")
21-
--experiments stringArray Experiments to enable in Codesphere installation (optional) (default [headless-services,vcluster,custom-service-image,ms-in-ls,secret-management,sub-path-mount])
22-
--feature-flags stringArray Feature flags to enable in Codesphere installation (optional)
23-
-h, --help help for bootstrap-local
24-
--install-config string Path to install config file (default: <install-dir>/config.yaml)
25-
--install-dir string Directory for config, secrets, and bundle files (default ".installer")
26-
--install-hash string Codesphere package hash (required when install-version is set)
27-
--install-local string Path to a local installer package (tar.gz or unpacked directory)
28-
--install-version string Codesphere version to install (downloaded from the OMS portal)
29-
--k0s Use k0s-specific configuration (required to deploy to k0s clusters)
30-
--pod-cidr string Service CIDR of the Kubernetes cluster. If not specified, OMS will try to determine it.
31-
--profile string Profile to apply to the install config like resources (supported: dev, minimal, prod) (default "dev")
32-
--registry-url string OCI registry URL used for the ArgoCD helm pull secret (only relevant with --argocd) (default "oci://ghcr.io/codesphere-cloud/charts")
33-
--registry-user string Custom Registry username (optional)
34-
--secrets-file string Path to secrets file (default: <install-dir>/prod.vault.yaml)
35-
--service-cidr string Service CIDR of the Kubernetes cluster. If not specified, OMS will try to determine it.
36-
-y, --yes Auto-approve the local bootstrapping warning prompt
19+
--argocd After infra setup: install ArgoCD, update the OCI pull secret, and install pc-apps from the BOM version
20+
--base-domain string Base domain for Codesphere (default "cs.local")
21+
--feature-flags stringArray Feature flags to enable in Codesphere installation (optional)
22+
-h, --help help for bootstrap-local
23+
--install-config string Path to install config file (default: <install-dir>/config.yaml)
24+
--install-dir string Directory for config, secrets, and bundle files (default ".installer")
25+
--install-hash string Codesphere package hash (required when install-version is set)
26+
--install-local string Path to a local installer package (tar.gz or unpacked directory)
27+
--install-version string Codesphere version to install (downloaded from the OMS portal)
28+
--internal-flags stringArray Internal flags to enable in Codesphere installation (optional) (default [headless-services,vcluster,custom-service-image,ms-in-ls])
29+
--k0s Use k0s-specific configuration (required to deploy to k0s clusters)
30+
--pod-cidr string Service CIDR of the Kubernetes cluster. If not specified, OMS will try to determine it.
31+
--preview-flags stringArray Preview flags to enable in Codesphere installation (optional) (default [secret-management,sub-path-mount,workspace-ssh])
32+
--profile string Profile to apply to the install config like resources (supported: dev, minimal, prod) (default "dev")
33+
--registry-url string OCI registry URL used for the ArgoCD helm pull secret (only relevant with --argocd) (default "oci://ghcr.io/codesphere-cloud/charts")
34+
--registry-user string Custom Registry username (optional)
35+
--secrets-file string Path to secrets file (default: <install-dir>/prod.vault.yaml)
36+
--service-cidr string Service CIDR of the Kubernetes cluster. If not specified, OMS will try to determine it.
37+
-y, --yes Auto-approve the local bootstrapping warning prompt
3738
```
3839

3940
### SEE ALSO

internal/bootstrap/gcp/gce_test.go

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,16 @@ var _ = Describe("GCE", func() {
145145

146146
BeforeEach(func() {
147147
csEnv = &gcp.CodesphereEnvironment{
148-
ProjectName: "test",
149-
Region: "us-central1",
150-
Zone: "us-central1-a",
151-
BaseDomain: "example.com",
152-
DNSProjectID: "dns-project",
153-
DNSZoneName: "test-zone",
154-
SecretsDir: "/etc/codesphere/secrets",
155-
DatacenterID: 1,
156-
Experiments: gcp.DefaultExperiments,
148+
ProjectName: "test",
149+
Region: "us-central1",
150+
Zone: "us-central1-a",
151+
BaseDomain: "example.com",
152+
DNSProjectID: "dns-project",
153+
DNSZoneName: "test-zone",
154+
SecretsDir: "/etc/codesphere/secrets",
155+
DatacenterID: 1,
156+
InternalFlags: gcp.DefaultInternalFlags,
157+
PreviewFlags: gcp.DefaultPreviewFlags,
157158
}
158159
gc := gcp.NewMockGCPClientManager(GinkgoT())
159160
bs = newTestBootstrapper(csEnv, gc)
@@ -202,7 +203,8 @@ var _ = Describe("GCE", func() {
202203
DNSZoneName: "test-zone",
203204
SecretsDir: "/etc/codesphere/secrets",
204205
DatacenterID: 1,
205-
Experiments: gcp.DefaultExperiments,
206+
InternalFlags: gcp.DefaultInternalFlags,
207+
PreviewFlags: gcp.DefaultPreviewFlags,
206208
InstallConfigPath: "fake-config",
207209
SecretsFilePath: "fake-secrets",
208210
GitHubAppName: "fake-app",
@@ -248,16 +250,17 @@ var _ = Describe("GCE", func() {
248250
BeforeEach(func() {
249251
gc = gcp.NewMockGCPClientManager(GinkgoT())
250252
csEnv = &gcp.CodesphereEnvironment{
251-
ProjectName: "test",
252-
ProjectID: "test-pid",
253-
Region: "us-central1",
254-
Zone: "us-central1-a",
255-
BaseDomain: "example.com",
256-
DNSProjectID: "dns-project",
257-
DNSZoneName: "test-zone",
258-
SecretsDir: "/etc/codesphere/secrets",
259-
DatacenterID: 1,
260-
Experiments: gcp.DefaultExperiments,
253+
ProjectName: "test",
254+
ProjectID: "test-pid",
255+
Region: "us-central1",
256+
Zone: "us-central1-a",
257+
BaseDomain: "example.com",
258+
DNSProjectID: "dns-project",
259+
DNSZoneName: "test-zone",
260+
SecretsDir: "/etc/codesphere/secrets",
261+
DatacenterID: 1,
262+
InternalFlags: gcp.DefaultInternalFlags,
263+
PreviewFlags: gcp.DefaultPreviewFlags,
261264
}
262265
logCh = make(chan string, 10)
263266
bs = newTestBootstrapper(csEnv, gc)
@@ -487,15 +490,16 @@ var _ = Describe("GCE", func() {
487490
gc := gcp.NewMockGCPClientManager(GinkgoT())
488491
fw = util.NewMockFileIO(GinkgoT())
489492
csEnv := &gcp.CodesphereEnvironment{
490-
ProjectName: "test",
491-
Region: "us-central1",
492-
Zone: "us-central1-a",
493-
BaseDomain: "example.com",
494-
DNSProjectID: "dns-project",
495-
DNSZoneName: "test-zone",
496-
SecretsDir: "/etc/codesphere/secrets",
497-
DatacenterID: 1,
498-
Experiments: gcp.DefaultExperiments,
493+
ProjectName: "test",
494+
Region: "us-central1",
495+
Zone: "us-central1-a",
496+
BaseDomain: "example.com",
497+
DNSProjectID: "dns-project",
498+
DNSZoneName: "test-zone",
499+
SecretsDir: "/etc/codesphere/secrets",
500+
DatacenterID: 1,
501+
InternalFlags: gcp.DefaultInternalFlags,
502+
PreviewFlags: gcp.DefaultPreviewFlags,
499503
}
500504
bs = newTestBootstrapperWithFileIO(csEnv, gc, fw)
501505
})
@@ -546,8 +550,9 @@ var _ = Describe("GCE", func() {
546550
SecretsDir: "/etc/codesphere/secrets",
547551
DatacenterID: 1,
548552
SSHPublicKeyPath: "key.pub",
549-
Experiments: gcp.DefaultExperiments,
550-
FeatureFlags: map[string]bool{},
553+
InternalFlags: gcp.DefaultInternalFlags,
554+
PreviewFlags: gcp.DefaultPreviewFlags,
555+
FeatureFlags: gcp.DefaultFeatureFlags,
551556
RootDiskSize: 50,
552557
}
553558
bs = newTestBootstrapperAll(csEnv, gc, fw, mockGitHubClient)

0 commit comments

Comments
 (0)