Skip to content

Commit 3be23aa

Browse files
Simon Emmsroboquat
authored andcommitted
[installer]: only allow config patch if advanced mode enabled
1 parent 0eab1e9 commit 3be23aa

File tree

4 files changed

+32
-19
lines changed

4 files changed

+32
-19
lines changed

install/installer/pkg/config/v1/envvars.go

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,18 @@ func (v version) BuildFromEnvvars(in interface{}) error {
370370
}
371371
}
372372

373+
if telemetryValue := envvars.Distribution; telemetryValue != "" {
374+
log.Infof("Setting deployment platform: %s", telemetryValue)
375+
if cfg.Experimental == nil {
376+
cfg.Experimental = &experimental.Config{}
377+
}
378+
379+
if cfg.Experimental.Telemetry == nil {
380+
cfg.Experimental.Telemetry = &experimental.TelemetryConfig{}
381+
}
382+
cfg.Experimental.Telemetry.Data.Platform = telemetryValue
383+
}
384+
373385
cfg.Components = nil
374386
cfg.Customization = nil
375387
if envvars.AdvancedModeEnabled {
@@ -403,28 +415,17 @@ func (v version) BuildFromEnvvars(in interface{}) error {
403415

404416
cfg.Customization = customization.Customization
405417
}
406-
} else {
407-
log.Info("No advanced configuration applied")
408-
}
409418

410-
if telemetryValue := envvars.Distribution; telemetryValue != "" {
411-
if cfg.Experimental == nil {
412-
cfg.Experimental = &experimental.Config{}
413-
}
414-
415-
if cfg.Experimental.Telemetry == nil {
416-
cfg.Experimental.Telemetry = &experimental.TelemetryConfig{}
417-
}
418-
cfg.Experimental.Telemetry.Data.Platform = telemetryValue
419-
}
419+
if cfgPatch := envvars.ConfigPatch; cfgPatch != "" {
420+
log.Warnf("Applying patch customization - this may overwrite all settings: %+v", cfgPatch)
420421

421-
if cfgPatch := envvars.ConfigPatch; cfgPatch != "" {
422-
log.Warnf("Applying patch customization - this may overwrite all settings: %+v", cfgPatch)
423-
424-
err := yaml.Unmarshal([]byte(cfgPatch), &cfg)
425-
if err != nil {
426-
return err
422+
err := yaml.Unmarshal([]byte(cfgPatch), &cfg)
423+
if err != nil {
424+
return err
425+
}
427426
}
427+
} else {
428+
log.Info("No advanced configuration applied")
428429
}
429430

430431
return nil
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
2+
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.
3+
4+
envvars:
5+
# This will be ignored as advanced mode not enabled
6+
CONFIG_PATCH: "domain: override.gitpod.io"
7+
DOMAIN: gitpod.io
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
2+
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.
3+
4+
domain: gitpod.io

install/installer/pkg/config/v1/testdata/envvars/config-patch/envvars.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.
33

44
envvars:
5+
ADVANCED_MODE_ENABLED: "1"
56
CONFIG_PATCH: "domain: override.gitpod.io"
67
DOMAIN: gitpod.io

0 commit comments

Comments
 (0)