Skip to content

Commit be5c727

Browse files
committed
[installer] add configcat env for proxy
1 parent 6fdb500 commit be5c727

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

.werft/jobs/build/installer/installer.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,9 @@ EOF`);
248248

249249
private configureConfigCat(slice: string) {
250250
// This key is not a secret, it is a unique identifier of our ConfigCat application
251-
exec(
252-
`yq w -i ${this.options.installerConfigPath} experimental.webapp.configcatKey "WBLaCPtkjkqKHlHedziE9g/LEAOCNkbuUKiqUZAcVg7dw"`,
253-
{ slice: slice },
254-
);
251+
exec(`yq w -i ${this.options.installerConfigPath} experimental.webapp.configcatKey "WBLaCPtkjkqKHlHedziE9g/LEAOCNkbuUKiqUZAcVg7dw"`, { slice: slice });
252+
exec(`yq w -i ${this.options.installerConfigPath} experimental.webapp.proxy.configcat.baseUrl "https://cdn-global.configcat.com"`,{ slice: slice });
253+
exec(`yq w -i ${this.options.installerConfigPath} experimental.webapp.proxy.configcat.pollInterval "1m"`,{ slice: slice });
255254
}
256255

257256
private includeAnalytics(slice: string): void {

install/installer/pkg/common/common.go

+37
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,43 @@ func ConfigcatEnv(ctx *RenderContext) []corev1.EnvVar {
284284
}
285285
}
286286

287+
func ConfigcatProxyEnv(ctx *RenderContext) []corev1.EnvVar {
288+
var (
289+
sdkKey string
290+
baseUrl string
291+
pollInterval string
292+
)
293+
_ = ctx.WithExperimental(func(cfg *experimental.Config) error {
294+
if cfg.WebApp != nil && cfg.WebApp.ConfigcatKey != "" {
295+
sdkKey = cfg.WebApp.ConfigcatKey
296+
}
297+
if cfg.WebApp != nil && cfg.WebApp.ProxyConfig != nil && cfg.WebApp.ProxyConfig.Configcat != nil {
298+
baseUrl = cfg.WebApp.ProxyConfig.Configcat.BaseUrl
299+
pollInterval = cfg.WebApp.ProxyConfig.Configcat.PollInterval
300+
}
301+
return nil
302+
})
303+
304+
if sdkKey == "" {
305+
return nil
306+
}
307+
308+
return []corev1.EnvVar{
309+
{
310+
Name: "CONFIGCAT_SDK_KEY",
311+
Value: sdkKey,
312+
},
313+
{
314+
Name: "CONFIGCAT_BASE_URL",
315+
Value: baseUrl,
316+
},
317+
{
318+
Name: "CONFIGCAT_POLL_INTERVAL",
319+
Value: pollInterval,
320+
},
321+
}
322+
}
323+
287324
func DatabaseWaiterContainer(ctx *RenderContext) *corev1.Container {
288325
return &corev1.Container{
289326
Name: "database-waiter",

install/installer/pkg/components/proxy/deployment.go

+1
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
246246
VolumeMounts: volumeMounts,
247247
Env: common.CustomizeEnvvar(ctx, Component, common.MergeEnv(
248248
common.DefaultEnv(&ctx.Config),
249+
common.ConfigcatProxyEnv(ctx),
249250
[]corev1.EnvVar{{
250251
Name: "PROXY_DOMAIN",
251252
Value: ctx.Config.Domain,

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

+7
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,13 @@ type ProxyConfig struct {
227227

228228
// @deprecated use components.proxy.service.serviceType instead
229229
ServiceType *corev1.ServiceType `json:"serviceType,omitempty" validate:"omitempty,service_config_type"`
230+
231+
Configcat *ConfigcatProxyConfig `json:"configcat,omitempty"`
232+
}
233+
234+
type ConfigcatProxyConfig struct {
235+
BaseUrl string `json:"baseUrl"`
236+
PollInterval string `json:"pollInterval"`
230237
}
231238

232239
type PublicAPIConfig struct {

0 commit comments

Comments
 (0)