Path: blob/main/install/installer/pkg/components/blobserve/configmap.go
2501 views
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package blobserve56import (7"fmt"8"time"910blobserve_config "github.com/gitpod-io/gitpod/blobserve/pkg/config"11"github.com/gitpod-io/gitpod/common-go/baseserver"12"github.com/gitpod-io/gitpod/common-go/util"13"github.com/gitpod-io/gitpod/installer/pkg/common"14"github.com/gitpod-io/gitpod/installer/pkg/components/workspace"15"github.com/gitpod-io/gitpod/installer/pkg/components/workspace/ide"1617corev1 "k8s.io/api/core/v1"18metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"19"k8s.io/apimachinery/pkg/runtime"20)2122func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {23bscfg := blobserve_config.Config{24BlobServe: blobserve_config.BlobServe{25Port: ContainerPort,26Timeout: util.Duration(time.Second * 5),27Repos: map[string]blobserve_config.Repo{28ctx.RepoName(ctx.Config.Repository, ide.CodeIDEImage): {29PrePull: []string{},30Workdir: "/ide",31// TODO consider to provide it as a part of image label or rather inline ${ide} and ${supervisor} in index.html32// to decouple blobserve and code image33InlineStatic: []blobserve_config.InlineReplacement{{34Search: "{{WORKBENCH_WEB_BASE_URL}}",35Replacement: "${ide}",36}, {37Search: "{{WORKBENCH_NLS_FALLBACK_URL}}",38Replacement: "${ide}/out/nls.messages.js",39}, {40Search: "{{WORKBENCH_NLS_URL}}",41Replacement: "${ide}/out/nls.messages.js",42}, {43Search: "/_supervisor/frontend",44Replacement: "${supervisor}",45}},46},47ctx.RepoName(ctx.Config.Repository, workspace.SupervisorImage): {48PrePull: []string{},49Workdir: "/.supervisor/frontend",50},51ctx.RepoName(ctx.Config.Repository, ide.XtermIDEImage): {52PrePull: []string{},53Workdir: "/ide/xterm",54InlineStatic: []blobserve_config.InlineReplacement{{55Search: "/_supervisor/frontend",56Replacement: "${supervisor}",57}},58},59},60BlobSpace: blobserve_config.BlobSpace{61Location: "/mnt/cache/blobserve",62MaxSize: MaxSizeBytes,63},64},65AuthCfg: "/mnt/pull-secret/pull-secret.json",66PProfAddr: common.LocalhostAddressFromPort(baseserver.BuiltinDebugPort),67PrometheusAddr: common.LocalhostPrometheusAddr(),68ReadinessProbeAddr: fmt.Sprintf(":%v", ReadinessPort),69}7071fc, err := common.ToJSONString(bscfg)72if err != nil {73return nil, fmt.Errorf("failed to marshal blobserve config: %w", err)74}7576return []runtime.Object{77&corev1.ConfigMap{78TypeMeta: common.TypeMetaConfigmap,79ObjectMeta: metav1.ObjectMeta{80Name: Component,81Namespace: ctx.Namespace,82Labels: common.CustomizeLabel(ctx, Component, common.TypeMetaConfigmap),83Annotations: common.CustomizeAnnotation(ctx, Component, common.TypeMetaConfigmap),84},85Data: map[string]string{86"config.json": string(fc),87},88},89}, nil90}919293