mirror of
https://github.com/gitpod-io/gitpod.git
synced 2025-12-08 17:36:30 +00:00
58 lines
1.7 KiB
Go
58 lines
1.7 KiB
Go
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
|
|
// Licensed under the GNU Affero General Public License (AGPL).
|
|
// See License.AGPL.txt in the project root for license information.
|
|
|
|
package agentsmith
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/gitpod-io/gitpod/agent-smith/pkg/config"
|
|
"github.com/gitpod-io/gitpod/common-go/baseserver"
|
|
"github.com/gitpod-io/gitpod/installer/pkg/common"
|
|
|
|
corev1 "k8s.io/api/core/v1"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/apimachinery/pkg/runtime"
|
|
)
|
|
|
|
func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
|
|
ascfg := config.ServiceConfig{
|
|
PProfAddr: common.LocalhostAddressFromPort(baseserver.BuiltinDebugPort),
|
|
PrometheusAddr: common.LocalhostPrometheusAddr(),
|
|
Namespace: ctx.Namespace,
|
|
Config: config.Config{
|
|
Kubernetes: config.Kubernetes{Enabled: true},
|
|
KubernetesNamespace: ctx.Namespace,
|
|
GitpodAPI: config.GitpodAPI{
|
|
HostURL: fmt.Sprintf("https://%s", ctx.Config.Domain),
|
|
},
|
|
},
|
|
}
|
|
|
|
if ctx.Config.Components != nil && ctx.Config.Components.AgentSmith != nil {
|
|
ascfg.Config = *ctx.Config.Components.AgentSmith
|
|
ascfg.Config.KubernetesNamespace = ctx.Namespace
|
|
}
|
|
|
|
fc, err := common.ToJSONString(ascfg)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal agent-smith config: %w", err)
|
|
}
|
|
|
|
return []runtime.Object{
|
|
&corev1.ConfigMap{
|
|
TypeMeta: common.TypeMetaConfigmap,
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: Component,
|
|
Namespace: ctx.Namespace,
|
|
Labels: common.CustomizeLabel(ctx, Component, common.TypeMetaConfigmap),
|
|
Annotations: common.CustomizeAnnotation(ctx, Component, common.TypeMetaConfigmap),
|
|
},
|
|
Data: map[string]string{
|
|
"config.json": string(fc),
|
|
},
|
|
},
|
|
}, nil
|
|
}
|