Path: blob/main/install/installer/pkg/components/agent-smith/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 agentsmith56import (7"fmt"8"time"910"github.com/gitpod-io/gitpod/agent-smith/pkg/config"11"github.com/gitpod-io/gitpod/common-go/baseserver"12"github.com/gitpod-io/gitpod/installer/pkg/common"1314wsmanagermk2 "github.com/gitpod-io/gitpod/installer/pkg/components/ws-manager-mk2"15corev1 "k8s.io/api/core/v1"16metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"17"k8s.io/apimachinery/pkg/runtime"18)1920func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {21ascfg := config.ServiceConfig{22PProfAddr: common.LocalhostAddressFromPort(baseserver.BuiltinDebugPort),23PrometheusAddr: common.LocalhostPrometheusAddr(),24Namespace: ctx.Namespace,25Config: config.Config{26WorkspaceManager: config.WorkspaceManagerConfig{27Address: fmt.Sprintf("%s:%d", common.WSManagerMk2Component, wsmanagermk2.RPCPort),28TLS: config.TLS{29Authority: "/wsman-certs/ca.crt",30Certificate: "/wsman-certs/tls.crt",31PrivateKey: "/wsman-certs/tls.key",32},33},34Kubernetes: config.Kubernetes{Enabled: true},35KubernetesNamespace: ctx.Namespace,36GitpodAPI: config.GitpodAPI{37HostURL: fmt.Sprintf("https://%s", ctx.Config.Domain),38},39},40}4142if ctx.Config.Components != nil && ctx.Config.Components.AgentSmith != nil {43ascfg.Config = *ctx.Config.Components.AgentSmith44ascfg.Config.KubernetesNamespace = ctx.Namespace4546// Set working area path if filesystem scanning is enabled47if ascfg.Config.FilesystemScanning != nil && ascfg.Config.FilesystemScanning.Enabled {48ascfg.Config.FilesystemScanning.Enabled = true49ascfg.Config.FilesystemScanning.WorkingArea = ContainerWorkingAreaMk250ascfg.Config.FilesystemScanning.ScanInterval = config.Duration{Duration: 5 * time.Minute}51}52}5354fc, err := common.ToJSONString(ascfg)55if err != nil {56return nil, fmt.Errorf("failed to marshal agent-smith config: %w", err)57}5859return []runtime.Object{60&corev1.ConfigMap{61TypeMeta: common.TypeMetaConfigmap,62ObjectMeta: metav1.ObjectMeta{63Name: Component,64Namespace: ctx.Namespace,65Labels: common.CustomizeLabel(ctx, Component, common.TypeMetaConfigmap),66Annotations: common.CustomizeAnnotation(ctx, Component, common.TypeMetaConfigmap),67},68Data: map[string]string{69"config.json": string(fc),70},71},72}, nil73}747576