config.go 2.89 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package config

import (
	"context"
	"os"

24
	"github.com/ai-dynamo/dynamo/deploy/cloud/operator/internal/consts"
25
26
)

27
28
func GetDynamoImageBuilderNamespace(ctx context.Context) (namespace string, err error) {
	return os.Getenv(consts.EnvDynamoImageBuilderNamespace), nil
29
30
31
}

type DockerRegistryConfig struct {
32
33
	DynamoComponentsRepositoryName string `yaml:"dynamo_components_repository_name"`
	Server                         string `yaml:"server"`
34
	SecretName                     string `yaml:"secret_name"`
35
	Secure                         bool   `yaml:"secure"`
36
37
}

38
func GetDockerRegistryConfig() *DockerRegistryConfig {
39
	return &DockerRegistryConfig{
40
41
		DynamoComponentsRepositoryName: os.Getenv(consts.EnvDockerRegistryDynamoComponentsRepositoryName),
		Server:                         os.Getenv(consts.EnvDockerRegistryServer),
42
		SecretName:                     os.Getenv(consts.EnvDockerRegistrySecret),
43
		Secure:                         os.Getenv(consts.EnvDockerRegistrySecure) == "true",
44
	}
45
46
}

47
type ApiStoreConfig struct {
48
49
50
51
52
	Endpoint    string `yaml:"endpoint"`
	ClusterName string `yaml:"cluster_name"`
	ApiToken    string `yaml:"api_token"`
}

53
54
55
56
57
func GetApiStoreConfig(ctx context.Context) (conf *ApiStoreConfig, err error) {
	return &ApiStoreConfig{
		Endpoint:    os.Getenv(consts.EnvApiStoreEndpoint),
		ClusterName: os.Getenv(consts.EnvApiStoreClusterName),
		ApiToken:    os.Getenv(consts.EnvApiStoreApiToken),
58
59
60
61
62
63
64
65
66
67
68
	}, nil
}

func getEnv(key, fallback string) string {
	if value, ok := os.LookupEnv(key); ok {
		return value
	}
	return fallback
}

type InternalImages struct {
69
70
71
72
	DynamoComponentsDownloader string
	Kaniko                     string
	Buildkit                   string
	BuildkitRootless           string
73
74
75
76
}

func GetInternalImages() (conf *InternalImages) {
	conf = &InternalImages{}
77
	conf.DynamoComponentsDownloader = getEnv(consts.EnvInternalImagesDynamoComponentsDownloader, consts.InternalImagesDynamoComponentsDownloaderDefault)
78
79
80
81
82
	conf.Kaniko = getEnv(consts.EnvInternalImagesKaniko, consts.InternalImagesKanikoDefault)
	conf.Buildkit = getEnv(consts.EnvInternalImagesBuildkit, consts.InternalImagesBuildkitDefault)
	conf.BuildkitRootless = getEnv(consts.EnvInternalImagesBuildkitRootless, consts.InternalImagesBuildkitRootlessDefault)
	return
}