Path: blob/main/components/ws-daemon/pkg/content/config.go
2500 views
// Copyright (c) 2020 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 content56import (7"encoding/json"8"strings"910"github.com/gitpod-io/gitpod/common-go/util"11cntntcfg "github.com/gitpod-io/gitpod/content-service/api/config"12"github.com/gitpod-io/gitpod/ws-daemon/api"13"golang.org/x/xerrors"14)1516// Config configures the workspace content service17type Config struct {18// WorkingArea is the location on-disk where we create workspaces19WorkingArea string `json:"workingArea"`2021// WorkingAreaNode is the location on-disk where we create workspaces,22// as seen from the root/node mount namespace. This is the same path as WorkingArea,23// except not from within the container, but on the node (the "other side" of the hostPath volume24// of the ws-daemon pod).25WorkingAreaNode string `json:"workingAreaNode"`2627// TmpDir is the temp working diretory for creating tar files during upload28TmpDir string `json:"tempDir"`2930// Storage is some form of permanent file store to which we back up workspaces31Storage cntntcfg.StorageConfig `json:"storage"`3233// Backup configures the behaviour of ws-daemon during backup34Backup BackupConfig `json:"backup,omitempty"`3536// UserNamespaces configures the behaviour of the user-namespace support37UserNamespaces UserNamespacesConfig `json:"userNamespaces,omitempty"`3839// Initializer configures the isolated content initializer runtime40Initializer InitializerConfig `json:"initializer"`41}4243type BackupConfig struct {44// Timeout configures the maximum time the remote storage upload can take45// per attempt. Defaults to 10 minutes.46Timeout util.Duration `json:"timeout,omitempty"`4748// Attempts configures how many backup attempts we will make.49// Detaults to 350Attempts int `json:"attempts"`5152// Period is the time between regular workspace backups53Period util.Duration `json:"period"`54}5556type UserNamespacesConfig struct {57FSShift FSShiftMethod `json:"fsShift"`58}5960type FSShiftMethod api.FSShiftMethod6162// MarshalJSON marshals the api.FSShiftMethod to the api.FSShiftMethod_value63func (m FSShiftMethod) MarshalJSON() ([]byte, error) {64methodInt := int32(m)65v, ok := api.FSShiftMethod_name[methodInt]66if !ok {67return nil, xerrors.Errorf("invalid shift method: %i", methodInt)68}69return json.Marshal(v)70}7172// UnmarshalJSON unmarshals the lowercase shift method string as defined in73// api.FSShiftMethod_value to api.FSShiftMethod74func (m *FSShiftMethod) UnmarshalJSON(data []byte) error {75input := strings.ToUpper(strings.Trim(string(data), "\""))76v, ok := api.FSShiftMethod_value[input]77if !ok {78return xerrors.Errorf("invalid shift method: %v", input)79}80*m = FSShiftMethod(v)81return nil82}8384type InitializerConfig struct {85// Command is the path to content-initializer executable86Command string `json:"command"`8788// Args are additional arguments to pass to the CI runtime89Args []string `json:"args"`90}919293