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
This commit is contained in:
Pudong 2023-03-23 18:01:15 +08:00 committed by GitHub
parent 555ee279fe
commit b465d06617
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 104 additions and 55 deletions

View File

@ -32,32 +32,43 @@ type Attributes struct {
VSCodeClientID string 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. // 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. // 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. // Otherwise, it returns a client which always returns the default value. This client is used for Self-Hosted installations.
func NewClient() Client { func NewClient(opts ...ClientOpt) Client {
// TODO: get rid fo GITPOD_HOST is implementaion detail of supervisor, it is a subject to change opt := &options{
// gitpodHost should be provided as an option instead sdkKey: os.Getenv("CONFIGCAT_SDK_KEY"),
gitpodHost := os.Getenv("GITPOD_HOST") baseURL: os.Getenv("CONFIGCAT_BASE_URL"),
if gitpodHost == "" { pollInterval: 3 * time.Minute,
gitpodHost = os.Getenv("HOST_URL")
} }
if gitpodHost != "" { for _, o := range opts {
return newConfigCatClient(configcat.Config{ o(opt)
SDKKey: "gitpod",
BaseURL: fmt.Sprintf("%s%s", gitpodHost, "/configcat"),
PollInterval: 1 * time.Minute,
HTTPTimeout: 3 * time.Second,
})
} }
sdkKey := os.Getenv("CONFIGCAT_SDK_KEY")
if sdkKey == "" { if opt.sdkKey == "" {
return NewAlwaysReturningDefaultValueClient() return NewAlwaysReturningDefaultValueClient()
} }
return newConfigCatClient(configcat.Config{ return newConfigCatClient(configcat.Config{
SDKKey: sdkKey, SDKKey: opt.sdkKey,
PollInterval: 3 * time.Minute, BaseURL: opt.baseURL,
PollInterval: opt.pollInterval,
HTTPTimeout: 3 * time.Second, HTTPTimeout: 3 * time.Second,
Logger: &configCatLogger{log.Log}, Logger: &configCatLogger{log.Log},
}) })

View File

@ -35,6 +35,7 @@ export function getExperimentsClientForBackend(): Client {
requestTimeoutMs: 2000, requestTimeoutMs: 2000,
logger: configcat.createConsoleLogger(LogLevel.Error), logger: configcat.createConsoleLogger(LogLevel.Error),
maxInitWaitTimeSeconds: 0, maxInitWaitTimeSeconds: 0,
baseUrl: process.env.CONFIGCAT_BASE_URL,
}); });
client = new ConfigCatClient(configCatClient); client = new ConfigCatClient(configCatClient);

View File

@ -254,6 +254,13 @@ func (s *IDEServiceServer) ResolveWorkspaceConfig(ctx context.Context, req *api.
IdeImageLayers: defaultIde.ImageLayers, 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 var wsConfig *gitpodapi.GitpodConfig
if req.WorkspaceConfig != "" { if req.WorkspaceConfig != "" {

View File

@ -154,6 +154,8 @@ type WorkspaceInfoResponse struct {
OwnerId string `protobuf:"bytes,16,opt,name=owner_id,json=ownerId,proto3" json:"owner_id,omitempty"` 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 // 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"` 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() { func (x *WorkspaceInfoResponse) Reset() {
@ -314,6 +316,13 @@ func (x *WorkspaceInfoResponse) GetDebugWorkspaceType() DebugWorkspaceType {
return DebugWorkspaceType_noDebug return DebugWorkspaceType_noDebug
} }
func (x *WorkspaceInfoResponse) GetConfigcatEnabled() bool {
if x != nil {
return x.ConfigcatEnabled
}
return false
}
type isWorkspaceInfoResponse_WorkspaceLocation interface { type isWorkspaceInfoResponse_WorkspaceLocation interface {
isWorkspaceInfoResponse_WorkspaceLocation() 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, 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, 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, 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, 0x61, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x86,
0x08, 0x0a, 0x15, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 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, 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, 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, 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, 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, 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, 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, 0x70, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2b, 0x0a, 0x11, 0x63, 0x6f, 0x6e, 0x66,
0x6f, 0x64, 0x41, 0x50, 0x49, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x69, 0x67, 0x63, 0x61, 0x74, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x12, 0x20,
0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x01, 0x28, 0x08, 0x52, 0x10, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x63, 0x61, 0x74, 0x45, 0x6e,
0x74, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x1a, 0x3b, 0x0a, 0x09, 0x47, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x41,
0x04, 0x68, 0x6f, 0x73, 0x74, 0x1a, 0x36, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x50, 0x49, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01,
0x6f, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x12,
0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x1a, 0x65, 0x0a, 0x73, 0x74, 0x1a, 0x36, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79,
0x0e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x12, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02,
0x21, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x1a, 0x65, 0x0a, 0x0e, 0x57, 0x6f,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x12, 0x0e, 0x0a, 0x02,
0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x0c,
0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01,
0x74, 0x69, 0x6f, 0x6e, 0x42, 0x14, 0x0a, 0x12, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12,
0x65, 0x5f, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x3c, 0x0a, 0x12, 0x44, 0x65, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03,
0x62, 0x75, 0x67, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f,
0x12, 0x0b, 0x0a, 0x07, 0x6e, 0x6f, 0x44, 0x65, 0x62, 0x75, 0x67, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x6e, 0x42, 0x14, 0x0a, 0x12, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6c,
0x07, 0x72, 0x65, 0x67, 0x75, 0x6c, 0x61, 0x72, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x3c, 0x0a, 0x12, 0x44, 0x65, 0x62, 0x75, 0x67,
0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x02, 0x32, 0x7f, 0x0a, 0x0b, 0x49, 0x6e, 0x66, 0x6f, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x70, 0x0a, 0x0d, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x07, 0x6e, 0x6f, 0x44, 0x65, 0x62, 0x75, 0x67, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x72, 0x65,
0x70, 0x61, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x20, 0x2e, 0x73, 0x75, 0x70, 0x65, 0x72, 0x67, 0x75, 0x6c, 0x61, 0x72, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x70, 0x72, 0x65, 0x62, 0x75,
0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x49, 0x69, 0x6c, 0x64, 0x10, 0x02, 0x32, 0x7f, 0x0a, 0x0b, 0x49, 0x6e, 0x66, 0x6f, 0x53, 0x65, 0x72,
0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x73, 0x75, 0x70, 0x76, 0x69, 0x63, 0x65, 0x12, 0x70, 0x0a, 0x0d, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63,
0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x20, 0x2e, 0x73, 0x75, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73,
0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1a, 0x82, 0x6f, 0x72, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f,
0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x2f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x73, 0x75, 0x70, 0x65, 0x72, 0x76,
0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, 0x46, 0x0a, 0x18, 0x69, 0x6f, 0x2e, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x49, 0x6e,
0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x73, 0x75, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93,
0x72, 0x2e, 0x61, 0x70, 0x69, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x02, 0x14, 0x12, 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x2f, 0x77, 0x6f, 0x72,
0x6d, 0x2f, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2d, 0x69, 0x6f, 0x2f, 0x67, 0x69, 0x74, 0x70, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, 0x46, 0x0a, 0x18, 0x69, 0x6f, 0x2e, 0x67, 0x69, 0x74,
0x6f, 0x64, 0x2f, 0x73, 0x75, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2f, 0x61, 0x70, 0x70, 0x6f, 0x64, 0x2e, 0x73, 0x75, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x61,
0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 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 ( var (

View File

@ -97,6 +97,9 @@ message WorkspaceInfoResponse {
// debug_workspace_type indicates whether it is a regular or prebuild debug workspace // debug_workspace_type indicates whether it is a regular or prebuild debug workspace
DebugWorkspaceType debug_workspace_type = 17; DebugWorkspaceType debug_workspace_type = 17;
// configcat_enabled controls whether configcat is enabled
bool configcat_enabled = 18;
} }
enum DebugWorkspaceType { enum DebugWorkspaceType {

View File

@ -52,6 +52,7 @@ type ServiceConfig struct {
WorkspaceID string WorkspaceID string
OwnerID string OwnerID string
SupervisorVersion string SupervisorVersion string
ConfigcatEnabled bool
} }
type Service struct { type Service struct {
@ -109,11 +110,15 @@ func NewServerApiService(ctx context.Context, cfg *ServiceConfig, tknsrv api.Tok
return nil return nil
} }
opts := []experiments.ClientOpt{}
if cfg.ConfigcatEnabled {
opts = append(opts, experiments.WithGitpodProxy(cfg.Host))
}
service := &Service{ service := &Service{
token: tknres.Token, token: tknres.Token,
gitpodService: gitpodService, gitpodService: gitpodService,
cfg: cfg, cfg: cfg,
experiments: experiments.NewClient(), experiments: experiments.NewClient(opts...),
apiMetrics: NewClientMetrics(), apiMetrics: NewClientMetrics(),
onUsingPublicAPI: make(chan struct{}), onUsingPublicAPI: make(chan struct{}),
subs: make(map[chan *gitpod.WorkspaceInstance]struct{}), subs: make(map[chan *gitpod.WorkspaceInstance]struct{}),

View File

@ -298,6 +298,9 @@ type WorkspaceConfig struct {
// DebugWorkspaceContenSource indicates where the debug workspace content came from // DebugWorkspaceContenSource indicates where the debug workspace content came from
DebugWorkspaceContenSource api.ContentSource `env:"SUPERVISOR_DEBUG_WORKSPACE_CONTENT_SOURCE"` 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. // WorkspaceGitpodToken is a list of tokens that should be added to supervisor's token service.

View File

@ -670,6 +670,7 @@ func (is *InfoService) WorkspaceInfo(context.Context, *api.WorkspaceInfoRequest)
WorkspaceClass: &api.WorkspaceInfoResponse_WorkspaceClass{Id: is.cfg.WorkspaceClass}, WorkspaceClass: &api.WorkspaceInfoResponse_WorkspaceClass{Id: is.cfg.WorkspaceClass},
OwnerId: is.cfg.OwnerId, OwnerId: is.cfg.OwnerId,
DebugWorkspaceType: is.cfg.DebugWorkspaceType, DebugWorkspaceType: is.cfg.DebugWorkspaceType,
ConfigcatEnabled: is.cfg.ConfigcatEnabled,
} }
if is.cfg.WorkspaceClassInfo != nil { if is.cfg.WorkspaceClassInfo != nil {
resp.WorkspaceClass.DisplayName = is.cfg.WorkspaceClassInfo.DisplayName resp.WorkspaceClass.DisplayName = is.cfg.WorkspaceClassInfo.DisplayName

View File

@ -262,6 +262,7 @@ func Run(options ...RunOption) {
WorkspaceID: cfg.WorkspaceID, WorkspaceID: cfg.WorkspaceID,
OwnerID: cfg.OwnerId, OwnerID: cfg.OwnerId,
SupervisorVersion: Version, SupervisorVersion: Version,
ConfigcatEnabled: cfg.ConfigcatEnabled,
}, tokenService) }, tokenService)
} }

View File

@ -424,7 +424,11 @@ func ConfigcatEnv(ctx *RenderContext) []corev1.EnvVar {
return []corev1.EnvVar{ return []corev1.EnvVar{
{ {
Name: "CONFIGCAT_SDK_KEY", Name: "CONFIGCAT_SDK_KEY",
Value: sdkKey, Value: "gitpod",
},
{
Name: "CONFIGCAT_BASE_URL",
Value: "https://" + ctx.Config.Domain + "/configcat",
}, },
} }
} }

View File

@ -79,6 +79,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
}, },
Env: common.CustomizeEnvvar(ctx, Component, common.MergeEnv( Env: common.CustomizeEnvvar(ctx, Component, common.MergeEnv(
common.DefaultEnv(&ctx.Config), common.DefaultEnv(&ctx.Config),
common.ConfigcatEnv(ctx),
)), )),
VolumeMounts: []corev1.VolumeMount{ VolumeMounts: []corev1.VolumeMount{
{ {