From b465d066176db87c5280dd0ff22b46a7f19feaeb Mon Sep 17 00:00:00 2001 From: Pudong Date: Thu, 23 Mar 2023 18:01:15 +0800 Subject: [PATCH] Uniformly use proxy to get the configuration of configcat (#16942) * Uniformly use proxy to get the configuration of configcat * Add configcat enabled in workspace info api * enabled configcat in ide-service --- components/common-go/experiments/types.go | 47 +++++++---- .../src/experiments/configcat-server.ts | 1 + components/ide-service/pkg/server/server.go | 7 ++ components/supervisor-api/go/info.pb.go | 82 +++++++++++-------- components/supervisor-api/info.proto | 3 + .../supervisor/pkg/serverapi/publicapi.go | 7 +- .../supervisor/pkg/supervisor/config.go | 3 + .../supervisor/pkg/supervisor/services.go | 1 + .../supervisor/pkg/supervisor/supervisor.go | 1 + install/installer/pkg/common/common.go | 6 +- .../pkg/components/ide-service/deployment.go | 1 + 11 files changed, 104 insertions(+), 55 deletions(-) diff --git a/components/common-go/experiments/types.go b/components/common-go/experiments/types.go index 9bdf0283ac..9833d261d1 100644 --- a/components/common-go/experiments/types.go +++ b/components/common-go/experiments/types.go @@ -32,32 +32,43 @@ type Attributes struct { VSCodeClientID string } +type ClientOpt func(o *options) + +func WithGitpodProxy(gitpodHost string) ClientOpt { + return func(o *options) { + o.sdkKey = "gitpod" + o.baseURL = fmt.Sprintf("https://%s/configcat", gitpodHost) + o.pollInterval = 1 * time.Minute + } +} + +type options struct { + pollInterval time.Duration + baseURL string + sdkKey string +} + // NewClient constructs a new experiments.Client. This is NOT A SINGLETON. // You should normally only call this once in the lifecycle of an application, clients are independent of each other will refresh flags on their own. -// If the environment contains CONFIGCAT_SDK_KEY value, it vill be used to construct a ConfigCat client. +// If the environment contains CONFIGCAT_SDK_KEY value, it will be used to construct a ConfigCat client. // Otherwise, it returns a client which always returns the default value. This client is used for Self-Hosted installations. -func NewClient() Client { - // TODO: get rid fo GITPOD_HOST is implementaion detail of supervisor, it is a subject to change - // gitpodHost should be provided as an option instead - gitpodHost := os.Getenv("GITPOD_HOST") - if gitpodHost == "" { - gitpodHost = os.Getenv("HOST_URL") +func NewClient(opts ...ClientOpt) Client { + opt := &options{ + sdkKey: os.Getenv("CONFIGCAT_SDK_KEY"), + baseURL: os.Getenv("CONFIGCAT_BASE_URL"), + pollInterval: 3 * time.Minute, } - if gitpodHost != "" { - return newConfigCatClient(configcat.Config{ - SDKKey: "gitpod", - BaseURL: fmt.Sprintf("%s%s", gitpodHost, "/configcat"), - PollInterval: 1 * time.Minute, - HTTPTimeout: 3 * time.Second, - }) + for _, o := range opts { + o(opt) } - sdkKey := os.Getenv("CONFIGCAT_SDK_KEY") - if sdkKey == "" { + + if opt.sdkKey == "" { return NewAlwaysReturningDefaultValueClient() } return newConfigCatClient(configcat.Config{ - SDKKey: sdkKey, - PollInterval: 3 * time.Minute, + SDKKey: opt.sdkKey, + BaseURL: opt.baseURL, + PollInterval: opt.pollInterval, HTTPTimeout: 3 * time.Second, Logger: &configCatLogger{log.Log}, }) diff --git a/components/gitpod-protocol/src/experiments/configcat-server.ts b/components/gitpod-protocol/src/experiments/configcat-server.ts index 3234d208c4..d0b962958c 100644 --- a/components/gitpod-protocol/src/experiments/configcat-server.ts +++ b/components/gitpod-protocol/src/experiments/configcat-server.ts @@ -35,6 +35,7 @@ export function getExperimentsClientForBackend(): Client { requestTimeoutMs: 2000, logger: configcat.createConsoleLogger(LogLevel.Error), maxInitWaitTimeSeconds: 0, + baseUrl: process.env.CONFIGCAT_BASE_URL, }); client = new ConfigCatClient(configCatClient); diff --git a/components/ide-service/pkg/server/server.go b/components/ide-service/pkg/server/server.go index def7da12a5..49122d3d7f 100644 --- a/components/ide-service/pkg/server/server.go +++ b/components/ide-service/pkg/server/server.go @@ -254,6 +254,13 @@ func (s *IDEServiceServer) ResolveWorkspaceConfig(ctx context.Context, req *api. IdeImageLayers: defaultIde.ImageLayers, } + if os.Getenv("CONFIGCAT_SDK_KEY") != "" { + resp.Envvars = append(resp.Envvars, &api.EnvironmentVariable{ + Name: "GITPOD_CONFIGCAT_ENABLED", + Value: "true", + }) + } + var wsConfig *gitpodapi.GitpodConfig if req.WorkspaceConfig != "" { diff --git a/components/supervisor-api/go/info.pb.go b/components/supervisor-api/go/info.pb.go index fdc2aba3e2..872ccc3473 100644 --- a/components/supervisor-api/go/info.pb.go +++ b/components/supervisor-api/go/info.pb.go @@ -154,6 +154,8 @@ type WorkspaceInfoResponse struct { OwnerId string `protobuf:"bytes,16,opt,name=owner_id,json=ownerId,proto3" json:"owner_id,omitempty"` // debug_workspace_type indicates whether it is a regular or prebuild debug workspace DebugWorkspaceType DebugWorkspaceType `protobuf:"varint,17,opt,name=debug_workspace_type,json=debugWorkspaceType,proto3,enum=supervisor.DebugWorkspaceType" json:"debug_workspace_type,omitempty"` + // configcat_enabled controls whether configcat is enabled + ConfigcatEnabled bool `protobuf:"varint,18,opt,name=configcat_enabled,json=configcatEnabled,proto3" json:"configcat_enabled,omitempty"` } func (x *WorkspaceInfoResponse) Reset() { @@ -314,6 +316,13 @@ func (x *WorkspaceInfoResponse) GetDebugWorkspaceType() DebugWorkspaceType { return DebugWorkspaceType_noDebug } +func (x *WorkspaceInfoResponse) GetConfigcatEnabled() bool { + if x != nil { + return x.ConfigcatEnabled + } + return false +} + type isWorkspaceInfoResponse_WorkspaceLocation interface { isWorkspaceInfoResponse_WorkspaceLocation() } @@ -519,8 +528,8 @@ var file_info_proto_rawDesc = []byte{ 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x16, 0x0a, 0x14, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, - 0x61, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xd9, - 0x08, 0x0a, 0x15, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, + 0x61, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x86, + 0x09, 0x0a, 0x15, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x69, @@ -574,39 +583,42 @@ var file_info_proto_rawDesc = []byte{ 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x73, 0x75, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x12, 0x64, 0x65, 0x62, 0x75, 0x67, 0x57, 0x6f, 0x72, 0x6b, 0x73, - 0x70, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x1a, 0x3b, 0x0a, 0x09, 0x47, 0x69, 0x74, 0x70, - 0x6f, 0x64, 0x41, 0x50, 0x49, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, - 0x74, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x68, 0x6f, 0x73, 0x74, 0x1a, 0x36, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x6f, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x1a, 0x65, 0x0a, - 0x0e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, - 0x21, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, - 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x14, 0x0a, 0x12, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x5f, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x3c, 0x0a, 0x12, 0x44, 0x65, - 0x62, 0x75, 0x67, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, - 0x12, 0x0b, 0x0a, 0x07, 0x6e, 0x6f, 0x44, 0x65, 0x62, 0x75, 0x67, 0x10, 0x00, 0x12, 0x0b, 0x0a, - 0x07, 0x72, 0x65, 0x67, 0x75, 0x6c, 0x61, 0x72, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x70, 0x72, - 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x02, 0x32, 0x7f, 0x0a, 0x0b, 0x49, 0x6e, 0x66, 0x6f, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x70, 0x0a, 0x0d, 0x57, 0x6f, 0x72, 0x6b, 0x73, - 0x70, 0x61, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x20, 0x2e, 0x73, 0x75, 0x70, 0x65, 0x72, - 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x49, - 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x73, 0x75, 0x70, - 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1a, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x2f, - 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, 0x46, 0x0a, 0x18, 0x69, 0x6f, 0x2e, - 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x73, 0x75, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, - 0x72, 0x2e, 0x61, 0x70, 0x69, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2d, 0x69, 0x6f, 0x2f, 0x67, 0x69, 0x74, 0x70, - 0x6f, 0x64, 0x2f, 0x73, 0x75, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2f, 0x61, 0x70, - 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2b, 0x0a, 0x11, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x63, 0x61, 0x74, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x12, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x10, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x63, 0x61, 0x74, 0x45, 0x6e, + 0x61, 0x62, 0x6c, 0x65, 0x64, 0x1a, 0x3b, 0x0a, 0x09, 0x47, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x41, + 0x50, 0x49, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x12, + 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, + 0x73, 0x74, 0x1a, 0x36, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, + 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x1a, 0x65, 0x0a, 0x0e, 0x57, 0x6f, + 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x0c, + 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x42, 0x14, 0x0a, 0x12, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6c, + 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x3c, 0x0a, 0x12, 0x44, 0x65, 0x62, 0x75, 0x67, + 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, + 0x07, 0x6e, 0x6f, 0x44, 0x65, 0x62, 0x75, 0x67, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x72, 0x65, + 0x67, 0x75, 0x6c, 0x61, 0x72, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x70, 0x72, 0x65, 0x62, 0x75, + 0x69, 0x6c, 0x64, 0x10, 0x02, 0x32, 0x7f, 0x0a, 0x0b, 0x49, 0x6e, 0x66, 0x6f, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x70, 0x0a, 0x0d, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x20, 0x2e, 0x73, 0x75, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, + 0x6f, 0x72, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x73, 0x75, 0x70, 0x65, 0x72, 0x76, + 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x49, 0x6e, + 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, + 0x02, 0x14, 0x12, 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x2f, 0x77, 0x6f, 0x72, + 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, 0x46, 0x0a, 0x18, 0x69, 0x6f, 0x2e, 0x67, 0x69, 0x74, + 0x70, 0x6f, 0x64, 0x2e, 0x73, 0x75, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x61, + 0x70, 0x69, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, + 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2d, 0x69, 0x6f, 0x2f, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2f, + 0x73, 0x75, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/components/supervisor-api/info.proto b/components/supervisor-api/info.proto index 0b9290f11b..112a5a8186 100644 --- a/components/supervisor-api/info.proto +++ b/components/supervisor-api/info.proto @@ -97,6 +97,9 @@ message WorkspaceInfoResponse { // debug_workspace_type indicates whether it is a regular or prebuild debug workspace DebugWorkspaceType debug_workspace_type = 17; + + // configcat_enabled controls whether configcat is enabled + bool configcat_enabled = 18; } enum DebugWorkspaceType { diff --git a/components/supervisor/pkg/serverapi/publicapi.go b/components/supervisor/pkg/serverapi/publicapi.go index 29e2cf9c72..11a760217f 100644 --- a/components/supervisor/pkg/serverapi/publicapi.go +++ b/components/supervisor/pkg/serverapi/publicapi.go @@ -52,6 +52,7 @@ type ServiceConfig struct { WorkspaceID string OwnerID string SupervisorVersion string + ConfigcatEnabled bool } type Service struct { @@ -109,11 +110,15 @@ func NewServerApiService(ctx context.Context, cfg *ServiceConfig, tknsrv api.Tok return nil } + opts := []experiments.ClientOpt{} + if cfg.ConfigcatEnabled { + opts = append(opts, experiments.WithGitpodProxy(cfg.Host)) + } service := &Service{ token: tknres.Token, gitpodService: gitpodService, cfg: cfg, - experiments: experiments.NewClient(), + experiments: experiments.NewClient(opts...), apiMetrics: NewClientMetrics(), onUsingPublicAPI: make(chan struct{}), subs: make(map[chan *gitpod.WorkspaceInstance]struct{}), diff --git a/components/supervisor/pkg/supervisor/config.go b/components/supervisor/pkg/supervisor/config.go index 2abb0c4856..9d0d72d56b 100644 --- a/components/supervisor/pkg/supervisor/config.go +++ b/components/supervisor/pkg/supervisor/config.go @@ -298,6 +298,9 @@ type WorkspaceConfig struct { // DebugWorkspaceContenSource indicates where the debug workspace content came from DebugWorkspaceContenSource api.ContentSource `env:"SUPERVISOR_DEBUG_WORKSPACE_CONTENT_SOURCE"` + + // ConfigcatEnabled controls whether configcat is enabled + ConfigcatEnabled bool `env:"GITPOD_CONFIGCAT_ENABLED"` } // WorkspaceGitpodToken is a list of tokens that should be added to supervisor's token service. diff --git a/components/supervisor/pkg/supervisor/services.go b/components/supervisor/pkg/supervisor/services.go index c4571ae88a..8549a3cde0 100644 --- a/components/supervisor/pkg/supervisor/services.go +++ b/components/supervisor/pkg/supervisor/services.go @@ -670,6 +670,7 @@ func (is *InfoService) WorkspaceInfo(context.Context, *api.WorkspaceInfoRequest) WorkspaceClass: &api.WorkspaceInfoResponse_WorkspaceClass{Id: is.cfg.WorkspaceClass}, OwnerId: is.cfg.OwnerId, DebugWorkspaceType: is.cfg.DebugWorkspaceType, + ConfigcatEnabled: is.cfg.ConfigcatEnabled, } if is.cfg.WorkspaceClassInfo != nil { resp.WorkspaceClass.DisplayName = is.cfg.WorkspaceClassInfo.DisplayName diff --git a/components/supervisor/pkg/supervisor/supervisor.go b/components/supervisor/pkg/supervisor/supervisor.go index 609d07df88..17f983b899 100644 --- a/components/supervisor/pkg/supervisor/supervisor.go +++ b/components/supervisor/pkg/supervisor/supervisor.go @@ -262,6 +262,7 @@ func Run(options ...RunOption) { WorkspaceID: cfg.WorkspaceID, OwnerID: cfg.OwnerId, SupervisorVersion: Version, + ConfigcatEnabled: cfg.ConfigcatEnabled, }, tokenService) } diff --git a/install/installer/pkg/common/common.go b/install/installer/pkg/common/common.go index d4c58c43b5..a4cc0ea22c 100644 --- a/install/installer/pkg/common/common.go +++ b/install/installer/pkg/common/common.go @@ -424,7 +424,11 @@ func ConfigcatEnv(ctx *RenderContext) []corev1.EnvVar { return []corev1.EnvVar{ { Name: "CONFIGCAT_SDK_KEY", - Value: sdkKey, + Value: "gitpod", + }, + { + Name: "CONFIGCAT_BASE_URL", + Value: "https://" + ctx.Config.Domain + "/configcat", }, } } diff --git a/install/installer/pkg/components/ide-service/deployment.go b/install/installer/pkg/components/ide-service/deployment.go index 0cb5ebfa6c..a6816a661c 100644 --- a/install/installer/pkg/components/ide-service/deployment.go +++ b/install/installer/pkg/components/ide-service/deployment.go @@ -79,6 +79,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { }, Env: common.CustomizeEnvvar(ctx, Component, common.MergeEnv( common.DefaultEnv(&ctx.Config), + common.ConfigcatEnv(ctx), )), VolumeMounts: []corev1.VolumeMount{ {