Skip to content

Commit

Permalink
[installer]: promote telemetry from experimental to main config
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Emms committed Jan 19, 2023
1 parent f484884 commit ed59f5f
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 12 deletions.
7 changes: 3 additions & 4 deletions install/installer/cmd/testdata/render/telemetry/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

apiVersion: v1
domain: gitpod.example.com
experimental:
telemetry:
data:
platform: k3s
telemetry:
data:
platform: k3s
3 changes: 3 additions & 0 deletions install/installer/cmd/testdata/render/telemetry/output.golden

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions install/installer/pkg/components/gitpod/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

"github.com/gitpod-io/gitpod/installer/pkg/common"
config "github.com/gitpod-io/gitpod/installer/pkg/config/v1"
"github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental"
)

func cronjob(ctx *common.RenderContext) ([]runtime.Object, error) {
Expand All @@ -24,12 +23,9 @@ func cronjob(ctx *common.RenderContext) ([]runtime.Object, error) {
}

platformTelemetryData := "unknown"
_ = ctx.WithExperimental(func(cfg *experimental.Config) error {
if cfg.Telemetry != nil && cfg.Telemetry.Data.Platform != "" {
platformTelemetryData = cfg.Telemetry.Data.Platform
}
return nil
})
if ctx.Config.Telemetry != nil && ctx.Config.Telemetry.Data != nil && ctx.Config.Telemetry.Data.Platform != "" {
platformTelemetryData = ctx.Config.Telemetry.Data.Platform
}

installationTelemetryComponent := fmt.Sprintf("%s-telemetry", Component)

Expand Down
10 changes: 10 additions & 0 deletions install/installer/pkg/config/v1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ type Config struct {

Components *Components `json:"components,omitempty"`

Telemetry *TelemetryConfig `json:"telemetry,omitempty"`

Experimental *experimental.Config `json:"experimental,omitempty"`
}

Expand Down Expand Up @@ -434,3 +436,11 @@ type ProxyComponent struct {
type ComponentTypeService struct {
ServiceType *corev1.ServiceType `json:"serviceType,omitempty" validate:"omitempty,service_config_type"`
}

type TelemetryConfig struct {
Data *TelemetryData `json:"data,omitempty"`
}

type TelemetryData struct {
Platform string `json:"platform"`
}
20 changes: 20 additions & 0 deletions install/installer/pkg/config/v1/deprecations.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ var deprecatedFields = map[string]deprecatedField{
return nil
},
},
"experimental.telemetry.data.platform": {
Selector: func(cfg *Config) (bool, any) {
val := cfg.Experimental.Telemetry.Data.Platform
return val != "", val
},
MapValue: func(cfg *Config) error {
if cfg.Telemetry != nil && cfg.Telemetry.Data != nil && cfg.Telemetry.Data.Platform != "" {
return errors.New("cannot set telemetry platform in both telemetry and experimental")
}
if cfg.Telemetry == nil {
cfg.Telemetry = &TelemetryConfig{}
}
if cfg.Telemetry.Data == nil {
cfg.Telemetry.Data = &TelemetryData{}
}

cfg.Telemetry.Data.Platform = cfg.Experimental.Telemetry.Data.Platform
return nil
},
},
"objectStorage.maximumBackupCount": {
Selector: func(cfg *Config) (bool, any) {
val := cfg.ObjectStorage.MaximumBackupCount
Expand Down
3 changes: 2 additions & 1 deletion install/installer/pkg/config/v1/experimental/experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ type Config struct {
WebApp *WebAppConfig `json:"webapp,omitempty"`
IDE *IDEConfig `json:"ide,omitempty"`
Common *CommonConfig `json:"common,omitempty"`
Telemetry *TelemetryConfig `json:"telemetry,omitempty"`
Telemetry *TelemetryConfig `json:"telemetry,omitempty"` // @deprecated
AgentSmith *agentSmith.Config `json:"agentSmith,omitempty"`
}

// @deprecated
type TelemetryConfig struct {
Data struct {
Platform string `json:"platform"`
Expand Down

0 comments on commit ed59f5f

Please sign in to comment.