Skip to content

Commit b152378

Browse files
committed
feat(bootstrap): Add option to specify feature flags and experiments
* Add default experiments * refactor tests
1 parent ccbb7b9 commit b152378

File tree

4 files changed

+256
-668
lines changed

4 files changed

+256
-668
lines changed

cli/cmd/bootstrap_gcp.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ func AddBootstrapGcpCmd(parent *cobra.Command, opts *GlobalOptions) {
8080
flags.BoolVar(&bootstrapGcpCmd.SSHQuiet, "ssh-quiet", true, "Suppress SSH command output (default: true)")
8181
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.GitHubPAT, "github-pat", "", "GitHub Personal Access Token to use for direct image access. Scope required: package read (optional)")
8282
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.RegistryUser, "registry-user", "", "Custom Registry username (only for GitHub registry type) (optional)")
83+
flags.StringArrayVar(&bootstrapGcpCmd.CodesphereEnv.Experiments, "experiments", gcp.DefaultExperiments, "Experiments to enable in Codesphere installation (optional)")
84+
flags.StringArrayVar(&bootstrapGcpCmd.CodesphereEnv.FeatureFlags, "feature-flags", []string{}, "Feature flags to enable in Codesphere installation (optional)")
8385

8486
util.MarkFlagRequired(bootstrapGcpCmd.cmd, "project-name")
8587
util.MarkFlagRequired(bootstrapGcpCmd.cmd, "billing-account")

internal/bootstrap/gcp/gcp.go

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ var vmDefs = []VMDef{
5454
{"k0s-3", "e2-standard-16", []string{"k0s"}, []int64{}, false},
5555
}
5656

57+
var DefaultExperiments []string = []string{
58+
"managed-services",
59+
"vcluster",
60+
"custom-service-image",
61+
"ms-in-ls",
62+
"secret-management",
63+
"sub-path-mount",
64+
}
65+
5766
type GCPBootstrapper struct {
5867
ctx context.Context
5968
stlog *bootstrap.StepLogger
@@ -84,6 +93,8 @@ type CodesphereEnvironment struct {
8493
RegistryType RegistryType `json:"registry_type"`
8594
GitHubPAT string `json:"-"`
8695
RegistryUser string `json:"-"`
96+
Experiments []string `json:"experiments"`
97+
FeatureFlags []string `json:"feature_flags"`
8798

8899
// Config
89100
InstallConfigPath string `json:"-"`
@@ -1065,7 +1076,6 @@ func (b *GCPBootstrapper) UpdateInstallConfig() error {
10651076
1: 1,
10661077
2: 1,
10671078
3: 0,
1068-
4: 0,
10691079
},
10701080
},
10711081
},
@@ -1075,27 +1085,20 @@ func (b *GCPBootstrapper) UpdateInstallConfig() error {
10751085
b.Env.InstallConfig.Codesphere.Plans = files.PlansConfig{
10761086
HostingPlans: map[int]files.HostingPlan{
10771087
1: {
1078-
CPUTenth: 10,
1079-
GPUParts: 0,
1080-
MemoryMb: 2048,
1081-
StorageMb: 20480,
1082-
TempStorageMb: 1024,
1083-
},
1084-
2: {
10851088
CPUTenth: 20,
10861089
GPUParts: 0,
10871090
MemoryMb: 4096,
10881091
StorageMb: 20480,
10891092
TempStorageMb: 1024,
10901093
},
1091-
3: {
1094+
2: {
10921095
CPUTenth: 40,
10931096
GPUParts: 0,
10941097
MemoryMb: 8192,
10951098
StorageMb: 40960,
10961099
TempStorageMb: 1024,
10971100
},
1098-
4: {
1101+
3: {
10991102
CPUTenth: 80,
11001103
GPUParts: 0,
11011104
MemoryMb: 16384,
@@ -1105,26 +1108,20 @@ func (b *GCPBootstrapper) UpdateInstallConfig() error {
11051108
},
11061109
WorkspacePlans: map[int]files.WorkspacePlan{
11071110
1: {
1108-
Name: "Micro",
1111+
Name: "Standard",
11091112
HostingPlanID: 1,
11101113
MaxReplicas: 3,
11111114
OnDemand: true,
11121115
},
11131116
2: {
1114-
Name: "Standard",
1117+
Name: "Big",
11151118
HostingPlanID: 2,
11161119
MaxReplicas: 3,
11171120
OnDemand: true,
11181121
},
11191122
3: {
1120-
Name: "Big",
1121-
HostingPlanID: 3,
1122-
MaxReplicas: 3,
1123-
OnDemand: true,
1124-
},
1125-
4: {
11261123
Name: "Pro",
1127-
HostingPlanID: 4,
1124+
HostingPlanID: 3,
11281125
MaxReplicas: 3,
11291126
OnDemand: true,
11301127
},
@@ -1147,6 +1144,8 @@ func (b *GCPBootstrapper) UpdateInstallConfig() error {
11471144
},
11481145
},
11491146
}
1147+
b.Env.InstallConfig.Codesphere.Experiments = b.Env.Experiments
1148+
b.Env.InstallConfig.Codesphere.Features = b.Env.FeatureFlags
11501149
b.Env.InstallConfig.Codesphere.ManagedServices = []files.ManagedServiceConfig{}
11511150

11521151
if !b.Env.ExistingConfigUsed {

0 commit comments

Comments
 (0)