Path: blob/main/components/content-service-api/go/config/config.go
2499 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 config56import (7"os"89"github.com/gitpod-io/gitpod/common-go/baseserver"10)1112// StorageConfig configures the remote storage we use13type StorageConfig struct {14// Stage represents the deployment environment in which we're operating15Stage Stage `json:"stage"`1617// Kind determines the type of storage we ought to use18Kind RemoteStorageType `json:"kind"`1920// GCloudConfig configures the Google Bucket remote storage21GCloudConfig GCPConfig `json:"gcloud,omitempty"`2223// MinIOConfig configures the MinIO remote storage24MinIOConfig MinIOConfig `json:"minio,omitempty"`2526// S3Config configures the S3 remote storage27S3Config *S3Config `json:"s3,omitempty"`2829BlobQuota int64 `json:"blobQuota"`30}3132// Stage represents the deployment environment in which we're operating33type Stage string3435const (36// StageProduction is the live environment in which our users live37StageProduction Stage = "prod"3839// StageStaging is our staging environment which runs very closely to production (hence the name)40StageStaging Stage = "prodcopy"4142// StageDevStaging is our local or branch-built development environment43StageDevStaging Stage = "dev"44)4546// RemoteStorageType is a kind of storage where we persist/backup workspaces to47type RemoteStorageType string4849const (50// GCloudStorage stores workspaces in GCloud buckets51GCloudStorage RemoteStorageType = "gcloud"5253// MinIOStorage stores workspaces in a MinIO/S3 storage54MinIOStorage RemoteStorageType = "minio"5556// S3Storage stores workspaces in a S3 storage. It assumes the AWS-typical credentials57// exist in the environment. See https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/config#LoadDefaultConfig for more details.58S3Storage RemoteStorageType = "s3"5960// NullStorage does not synchronize workspaces at all61NullStorage RemoteStorageType = ""62)6364// GetStage reads the KUBE_STAGE envvar and maps its value to the storage stage naming65func getStageFromEnv() Stage {66// the stage does not have to be explicitly set in the storage config (as that would duplicate the67// info in our Helm values.yaml), but can be supplied as env var, as the default env vars in our68// Helm charts do.69stg := os.Getenv("KUBE_STAGE")70switch stg {71case "production":72return StageProduction73case "staging":74return StageStaging75default:76return StageDevStaging77}78}7980// GetStage provides the storage stage from either this config or the environment81func (c *StorageConfig) GetStage() Stage {82if c.Stage == "" {83return getStageFromEnv()84}8586return c.Stage87}8889// GCPConfig controls the access to GCloud resources/buckets90type GCPConfig struct {91CredentialsFile string `json:"credentialsFile"`92Region string `json:"region"`93Project string `json:"projectId"`94}9596// MinIOConfig MinIOconfigures the MinIO remote storage backend97type MinIOConfig struct {98Endpoint string `json:"endpoint"`99AccessKeyID string `json:"accessKey"`100AccessKeyIdFile string `json:"accessKeyFile"`101SecretAccessKey string `json:"secretKey"`102SecretAccessKeyFile string `json:"secretKeyFile"`103Secure bool `json:"secure,omitempty"`104105Region string `json:"region"`106ParallelUpload uint `json:"parallelUpload,omitempty"`107108BucketName string `json:"bucket,omitempty"`109}110111// S3Config configures the S3 remote storage backend112type S3Config struct {113Bucket string `json:"bucket"`114Region string `json:"region"`115CredentialsFile string `json:"credentialsFile"`116}117118type PProf struct {119Addr string `json:"address"`120}121122// UsageReportConfig configures the upload of workspace instance usage reports123type UsageReportConfig struct {124BucketName string `json:"bucketName"`125}126127type ServiceConfig struct {128Service baseserver.ServerConfiguration `json:"service"`129Storage StorageConfig `json:"storage"`130// Deprecated131_ UsageReportConfig `json:"usageReport"`132}133134135