-
Notifications
You must be signed in to change notification settings - Fork 543
Expand file tree
/
Copy pathcontext.go
More file actions
141 lines (135 loc) · 4.7 KB
/
context.go
File metadata and controls
141 lines (135 loc) · 4.7 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package config
import (
"strings"
"github.com/loft-sh/devpod/pkg/types"
)
const (
ContextOptionSSHAddPrivateKeys = "SSH_ADD_PRIVATE_KEYS"
ContextOptionGPGAgentForwarding = "GPG_AGENT_FORWARDING"
ContextOptionGitSSHSignatureForwarding = "GIT_SSH_SIGNATURE_FORWARDING"
ContextOptionSSHInjectDockerCredentials = "SSH_INJECT_DOCKER_CREDENTIALS"
ContextOptionSSHInjectGitCredentials = "SSH_INJECT_GIT_CREDENTIALS"
ContextOptionExitAfterTimeout = "EXIT_AFTER_TIMEOUT"
ContextOptionTelemetry = "TELEMETRY"
ContextOptionAgentURL = "AGENT_URL"
ContextOptionDotfilesURL = "DOTFILES_URL"
ContextOptionDotfilesScript = "DOTFILES_SCRIPT"
ContextOptionSSHAgentForwarding = "SSH_AGENT_FORWARDING"
ContextOptionSSHConfigPath = "SSH_CONFIG_PATH"
ContextOptionSSHConfigIncludePath = "SSH_CONFIG_INCLUDE_PATH"
ContextOptionAgentInjectTimeout = "AGENT_INJECT_TIMEOUT"
ContextOptionRegistryCache = "REGISTRY_CACHE"
ContextOptionSSHStrictHostKeyChecking = "SSH_STRICT_HOST_KEY_CHECKING"
)
var ContextOptions = []ContextOption{
{
Name: ContextOptionSSHAddPrivateKeys,
Description: "Specifies if DevPod should automatically add ssh-keys to the ssh-agent",
Default: "true",
Enum: []string{"true", "false"},
},
{
Name: ContextOptionExitAfterTimeout,
Description: "Specifies if DevPod should exit the process after the browser has been idle for a minute",
Default: "true",
Enum: []string{"true", "false"},
},
{
Name: ContextOptionGPGAgentForwarding,
Description: "Specifies if DevPod should do gpg-agent forwarding by default for ssh",
Default: "false",
Enum: []string{"true", "false"},
},
{
Name: ContextOptionGitSSHSignatureForwarding,
Description: "Specifies if DevPod should automatically detect ssh signature git setting and inject ssh signature helper",
Default: "true",
Enum: []string{"true", "false"},
},
{
Name: ContextOptionSSHInjectDockerCredentials,
Description: "Specifies if DevPod should inject docker credentials into the workspace",
Default: "true",
Enum: []string{"true", "false"},
},
{
Name: ContextOptionSSHInjectGitCredentials,
Description: "Specifies if DevPod should inject git credentials into the workspace",
Default: "true",
Enum: []string{"true", "false"},
},
{
Name: ContextOptionSSHAgentForwarding,
Description: "Specifies if DevPod should do agent forwarding by default into the workspace",
Default: "true",
Enum: []string{"true", "false"},
},
{
Name: ContextOptionTelemetry,
Description: "Specifies if DevPod should send telemetry information",
Default: "true",
Enum: []string{"true", "false"},
},
{
Name: ContextOptionAgentURL,
Description: "Specifies the agent url to use for DevPod",
},
{
Name: ContextOptionDotfilesURL,
Description: "Specifies the dotfiles repo url to use for DevPod",
},
{
Name: ContextOptionDotfilesScript,
Description: "Specifies the script to run after cloning dotfiles repo to install them",
},
{
Name: ContextOptionSSHConfigPath,
Description: "Specifies the path where the ssh config should be written to",
},
{
Name: ContextOptionSSHConfigIncludePath,
Description: "Specifies an alternate path where DevPod host entries should be written. Use this when your main SSH config is read-only (e.g., managed by Nix). Your main SSH config should have an Include directive pointing to this file.",
},
{
Name: ContextOptionAgentInjectTimeout,
Description: "Specifies the timeout to inject the agent",
Default: "20",
},
{
Name: ContextOptionRegistryCache,
Description: "Specifies the registry to use as a build cache, e.g. gcr.io/my-project/my-dev-env",
Default: "",
},
{
Name: ContextOptionSSHStrictHostKeyChecking,
Description: "Enables strict ssh host key checking for all operations",
Default: "false",
Enum: []string{"true", "false"},
},
}
func MergeContextOptions(contextConfig *ContextConfig, environ []string) {
envVars := map[string]string{}
for _, v := range environ {
t := strings.SplitN(v, "=", 2)
if len(t) != 2 {
continue
}
envVars[t[0]] = t[1]
}
for _, o := range ContextOptions {
// look up in env
envVal, ok := envVars[o.Name]
if !ok {
continue
}
// look up in current context options, skip if already exists
if _, ok := contextConfig.Options[o.Name]; ok {
continue
}
contextConfig.Options[o.Name] = OptionValue{
Value: envVal,
UserProvided: true,
Filled: &[]types.Time{types.Now()}[0],
}
}
}