-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathconfig.go
78 lines (62 loc) · 2.62 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright (c) 2020 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 content
import (
"fmt"
"strings"
"github.com/gitpod-io/gitpod/common-go/util"
"github.com/gitpod-io/gitpod/content-service/pkg/storage"
"github.com/gitpod-io/gitpod/ws-daemon/api"
"github.com/gitpod-io/gitpod/ws-daemon/pkg/quota"
)
// Config configures the workspace content service
type Config struct {
// WorkingArea is the location on-disk where we create workspaces
WorkingArea string `json:"workingArea"`
// WorkingAreaNode is the location on-disk where we create workspaces,
// as seen from the root/node mount namespace. This is the same path as WorkingArea,
// except not from within the container, but on the node (the "other side" of the hostPath volume
// of the ws-daemon pod).
WorkingAreaNode string `json:"workingAreaNode"`
// TmpDir is the temp working diretory for creating tar files during upload
TmpDir string `json:"tempDir"`
// Limit limits the size of a sandbox
WorkspaceSizeLimit quota.Size `json:"workspaceSizeLimit"`
// Storage is some form of permanent file store to which we back up workspaces
Storage storage.Config `json:"storage"`
// Backup configures the behaviour of ws-daemon during backup
Backup struct {
// Timeout configures the maximum time the remote storage upload can take
// per attempt. Defaults to 10 minutes.
Timeout util.Duration `json:"timeout,omitempty"`
// Attempts configures how many backup attempts we will make.
// Detaults to 3
Attempts int `json:"attempts"`
// Period is the time between regular workspace backups
Period util.Duration `json:"period"`
} `json:"backup,omitempty"`
// UserNamespaces configures the behaviour of the user-namespace support
UserNamespaces struct {
FSShift FSShiftMethod `json:"fsShift"`
} `json:"userNamespaces,omitempty"`
// Initializer configures the isolated content initializer runtime
Initializer struct {
// Command is the path to content-initializer executable
Command string `json:"command"`
// Args are additional arguments to pass to the CI runtime
Args []string `json:"args"`
} `json:"initializer"`
}
type FSShiftMethod api.FSShiftMethod
// UnmarshalJSON unmarshals the lowercase shift method string as defined in
// api.FSShiftMethod_value to api.FSShiftMethod
func (m *FSShiftMethod) UnmarshalJSON(data []byte) error {
input := strings.ToUpper(strings.Trim(string(data), "\""))
v, ok := api.FSShiftMethod_value[input]
if !ok {
return fmt.Errorf("invalid shift method: %v", input)
}
*m = FSShiftMethod(v)
return nil
}