GitLabgitlab-org
cli
main
1package config
3import (
4 "slices"
5 "strings"
7 "go.yaml.in/yaml/v3"
8)
10type Scope int
12const (
13 ScopeGlobal Scope = iota
14 ScopePerHost
15)
17type ValueType int
19const (
20 TypeString ValueType = iota
21 TypeBool
22 TypeList
23)
25// KeyDef is the single source of truth for a config key. It drives
26// NewBlankConfig, KnownKeys, defaultFor, ConfigKeyEquivalence,
27// EnvKeyEquivalence, and keyring eligibility.
28type KeyDef struct {
29 Name string
30 Scope Scope
31 Type ValueType
32 // Default is the YAML scalar seed value. For TypeList it's ignored
33 // and an empty sequence is emitted instead.
34 Default string
35 Description string
36 // EnvVars overrides the default env-var (uppercase Name). The first one
37 // that is set wins. CI-autologin overrides are layered on top by
38 // EnvKeyEquivalence.
39 EnvVars []string
40 Aliases []string
41 // UserSettable false keeps the key off `config set` and out of the
42 // blank config, but Get and env-var lookups still resolve it.
43 UserSettable bool
44 // HelpHidden keeps a key the CLI maintains for itself out of generated
45 // help. It stays settable.
46 HelpHidden bool
47 Keyring bool
48 // Fallback makes Default apply to runtime Get calls when the key is
49 // missing from the config, not just to the blank-config seed.
50 Fallback bool
51 // Completion candidates; not enforced by config set.
52 Values []string
53 // GlobalOnly marks state glab maintains for itself rather than settings a
54 // user tunes per repository. glab writes these to the global file, so a
55 // value in a repository's local file would win every read while every
56 // write went somewhere that is never read. Reads skip the local file for
57 // these, and `config set` routes them to the global one.
58 //
59 // Scope does not express this: ScopeGlobal means "not per host", and
60 // ordinary ScopeGlobal keys such as git_protocol are meant to be set per
61 // repository.
62 GlobalOnly bool
63}
65// globalOnlyKeys is the set of names and aliases whose values glab maintains
66// for itself. Built once from KeySchema so it cannot drift from the schema.
67var globalOnlyKeys = func() map[string]struct{} {
68 keys := map[string]struct{}{}
70 for _, def := range KeySchema {
71 if !def.GlobalOnly {
72 continue
73 }
75 keys[def.Name] = struct{}{}
76 for _, alias := range def.Aliases {
77 keys[alias] = struct{}{}
78 }
79 }
81 return keys
82}()
84// IsGlobalOnlyKey reports whether key names state glab maintains for itself,
85// which lives only in the global config file.
86func IsGlobalOnlyKey(key string) bool {
87 _, ok := globalOnlyKeys[ConfigKeyEquivalence(key)]
88 return ok
89}
91// KeySchema is the declared list of every config key glab understands.
92// Order is preserved when building the blank config.
93var KeySchema = []KeyDef{
94 // ---------------- Global ----------------
95 {
96 Name: "git_protocol", Scope: ScopeGlobal, Type: TypeString,
97 Default: "ssh", UserSettable: true, Fallback: true,
98 EnvVars: []string{"GLAB_GIT_PROTOCOL", "GIT_PROTOCOL"},
99 Description: "What protocol to use when performing Git operations. Supported values: 'ssh', 'https'.",
100 Values: []string{"ssh", "https"},
101 },
102 {
103 Name: "branch_prefix", Scope: ScopeGlobal, Type: TypeString,
104 UserSettable: true,
105 EnvVars: []string{"GLAB_BRANCH_PREFIX", "BRANCH_PREFIX"},
106 Description: "Prefix used by 'glab stack' when naming generated branches. Defaults to the\ncurrent user's username (from 'os/user.Current'), falling back to 'glab-stack' if unavailable.",
107 },
108 {
109 Name: "remote_alias", Scope: ScopeGlobal, Type: TypeString,
110 UserSettable: true,
111 Aliases: []string{"git_remote_url_var", "git_remote_alias", "remote_nickname", "git_remote_nickname"},
112 EnvVars: []string{"GLAB_REMOTE_ALIAS", "GIT_REMOTE_URL_VAR", "GIT_REMOTE_ALIAS", "REMOTE_ALIAS", "REMOTE_NICKNAME", "GIT_REMOTE_NICKNAME"},
113 Description: "Name of the 'git remote' that points at the GitLab repository. Used to\nresolve which remote to operate against when multiple are configured.",
114 },
115 {
116 Name: "editor", Scope: ScopeGlobal, Type: TypeString,
117 UserSettable: true,
118 Aliases: []string{"visual", "glab_editor"},
119 EnvVars: []string{"GLAB_EDITOR", "VISUAL", "EDITOR"},
120 Description: "What editor glab should run when creating issues, merge requests, etc. This global config cannot be overridden by hostname.",
121 },
122 {
123 Name: "browser", Scope: ScopeGlobal, Type: TypeString,
124 UserSettable: true,
125 EnvVars: []string{"GLAB_BROWSER", "BROWSER"},
126 Description: "What browser glab should run when opening links. This global config cannot be overridden by hostname.",
127 },
128 {
129 Name: "glab_pager", Scope: ScopeGlobal, Type: TypeString,
130 UserSettable: true,
131 Description: "Your desired pager command to use, such as 'less -R'. Takes precedence over the PAGER environment variable. GLAB_PAGER takes precedence over both.",
132 },
133 {
134 Name: "debug", Scope: ScopeGlobal, Type: TypeBool,
135 Default: "false", UserSettable: true,
136 EnvVars: []string{"GLAB_DEBUG"},
137 Description: "Output more logging information, including underlying Git commands, expanded aliases, and DNS error details.",
138 },
139 {
140 Name: "glamour_style", Scope: ScopeGlobal, Type: TypeString,
141 Default: "auto", UserSettable: true, Fallback: true,
142 EnvVars: []string{"GLAB_GLAMOUR_STYLE", "GLAMOUR_STYLE"},
143 Description: "Set your desired Markdown renderer style. Available options are [auto, dark, light, notty]. 'auto' detects your terminal's background color. To set a custom style, refer to https://github.com/charmbracelet/glamour#styles",
144 Values: []string{"auto", "dark", "light", "notty"},
145 },
146 {
147 Name: "color", Scope: ScopeGlobal, Type: TypeString,
148 Default: "auto", UserSettable: true, Fallback: true,
149 EnvVars: []string{"GLAB_COLOR"},
150 Description: "Set whether glab colors its output. Available options are [auto, never, always]. 'auto' detects whether the output is a terminal. This key takes precedence over the NO_COLOR environment variable; NO_COLOR applies when this is 'auto' (or unset).",
151 Values: []string{"auto", "never", "always"},
152 },
153 {
154 Name: "glamour_style_auto_migrated", Scope: ScopeGlobal, Type: TypeBool,
155 Default: "false", UserSettable: true, HelpHidden: true,
156 Description: "Set by glab once it has migrated a seeded glamour_style default of \"dark\" to \"auto\". Do not set this by hand.",
157 },
158 {
159 Name: "check_update", Scope: ScopeGlobal, Type: TypeBool,
160 Default: "true", UserSettable: true,
161 EnvVars: []string{"GLAB_CHECK_UPDATE", "CHECK_UPDATE"},
162 Description: "Allow glab to automatically check for updates and notify you when there are new updates.\nSetting the environment variable to true also forces a check, bypassing the once-a-day interval.",
163 },
164 {
165 Name: "last_update_check_timestamp", Scope: ScopeGlobal, Type: TypeString,
166 GlobalOnly: true,
167 UserSettable: true, HelpHidden: true,
168 Description: "Last update check timestamp, used for checking when the last update check was performed.",
169 },
170 {
171 Name: "show_whats_new", Scope: ScopeGlobal, Type: TypeBool,
172 Default: "true", UserSettable: true,
173 EnvVars: []string{"GLAB_SHOW_WHATS_NEW"},
174 Description: "Show a one-time post-upgrade banner pointing at 'glab whatsnew' when a new version is detected. Not shown when standard error is not a terminal, or when 'CI' or 'GITLAB_CI' is true. Set 'GLAB_SHOW_WHATS_NEW=false' to turn it off.",
175 },
176 {
177 Name: "last_seen_version", Scope: ScopeGlobal, Type: TypeString,
178 GlobalOnly: true,
179 // Seeded so the post-upgrade banner can surface immediately when
180 // existing users upgrade to the release that ships `glab whatsnew`.
181 // Bump only when intentionally re-announcing the feature.
182 Default: "v1.100.0", UserSettable: true, Fallback: true, HelpHidden: true,
183 Description: "Last glab version a post-upgrade banner was shown for (automatically set).",
184 },
185 {
186 Name: "last_whatsnew_version", Scope: ScopeGlobal, Type: TypeString,
187 GlobalOnly: true,
188 // Same seeded default as last_seen_version so the default whatsnew
189 // invocation has a non-empty baseline before the user runs it.
190 Default: "v1.100.0", UserSettable: true, Fallback: true, HelpHidden: true,
191 Description: "Last glab version 'glab whatsnew' rendered notes for (automatically set).",
192 },
193 {
194 Name: "notify_skill_updates", Scope: ScopeGlobal, Type: TypeBool,
195 Default: "true", UserSettable: true,
196 EnvVars: []string{"GLAB_NOTIFY_SKILL_UPDATES"},
197 Description: "Show a notice when an installed agent skill (bundled or remote) has updates available.",
198 },
199 {
200 Name: "display_hyperlinks", Scope: ScopeGlobal, Type: TypeBool,
201 Default: "true", UserSettable: true,
202 EnvVars: []string{"GLAB_DISPLAY_HYPERLINKS", "DISPLAY_HYPERLINKS"},
203 Description: "Whether or not to display hyperlinks in terminal output. Defaults to true (enabled for TTYs). Set to false to disable. Force hyperlinks in non-TTY environments by setting FORCE_HYPERLINKS=1.",
204 },
205 {
206 Name: "host", Scope: ScopeGlobal, Type: TypeString,
207 Default: "gitlab.com", UserSettable: true,
208 Aliases: []string{"gitlab_host", "gitlab_uri", "gl_host"},
209 EnvVars: []string{"GITLAB_HOST", "GITLAB_URI", "GL_HOST"},
210 Description: "Default GitLab hostname to use. Inside a repository, a Git remote on another host takes precedence over the config key. A host from an environment variable, such as 'GITLAB_HOST', always wins, and glab errors if no remote matches it.",
211 },
212 {
213 Name: "no_prompt", Scope: ScopeGlobal, Type: TypeBool,
214 Default: "false", UserSettable: true,
215 Aliases: []string{"prompt_disabled"},
216 EnvVars: []string{"GLAB_NO_PROMPT", "NO_PROMPT", "PROMPT_DISABLED"},
217 Description: "Set to true (1) to disable prompts, or false (0) to enable them.",
218 },
219 {
220 Name: "telemetry", Scope: ScopeGlobal, Type: TypeBool,
221 Default: "true", UserSettable: true,
222 EnvVars: []string{"GLAB_SEND_TELEMETRY"},
223 Description: "Set to false (0) to disable sending usage data to your GitLab instance or true (1) to enable.\nSee https://docs.gitlab.com/administration/settings/usage_statistics/\nfor more information",
224 },
225 // ---- Duo CLI binarymgr keys ----
226 {
227 Name: "duo_cli_auto_run", Scope: ScopeGlobal, Type: TypeString,
228 UserSettable: true,
229 EnvVars: []string{"GLAB_DUO_CLI_AUTO_RUN", "DUO_CLI_AUTO_RUN"},
230 Description: "Automatically run GitLab Duo CLI without prompting (true/false). Set to true to skip the confirmation prompt.",
231 Values: []string{"true", "false"},
232 },
233 {
234 Name: "duo_cli_auto_download", Scope: ScopeGlobal, Type: TypeString,
235 UserSettable: true,
236 EnvVars: []string{"GLAB_DUO_CLI_AUTO_DOWNLOAD", "DUO_CLI_AUTO_DOWNLOAD"},
237 Description: "Automatically download Duo CLI binary without prompting (true/false).",
238 Values: []string{"true", "false"},
239 },
240 {
241 Name: "duo_cli_binary_path", Scope: ScopeGlobal, Type: TypeString,
242 GlobalOnly: true,
243 UserSettable: true, HelpHidden: true,
244 EnvVars: []string{"GLAB_DUO_CLI_BINARY_PATH"},
245 Description: "Path to the installed Duo CLI binary (automatically set). Default: ~/.config/glab-cli/bin/duo",
246 },
247 {
248 Name: "duo_cli_binary_version", Scope: ScopeGlobal, Type: TypeString,
249 GlobalOnly: true,
250 UserSettable: true, HelpHidden: true,
251 Description: "Version of the installed Duo CLI binary (automatically set).",
252 },
253 {
254 Name: "duo_cli_binary_checksum", Scope: ScopeGlobal, Type: TypeString,
255 GlobalOnly: true,
256 UserSettable: true, HelpHidden: true,
257 Description: "SHA256 checksum of the installed Duo CLI binary (automatically set).",
258 },
259 {
260 Name: "duo_cli_last_update_check", Scope: ScopeGlobal, Type: TypeString,
261 GlobalOnly: true,
262 UserSettable: true, HelpHidden: true,
263 Description: "Last time an update check was performed (automatically set).",
264 },
265 // ---- GitLab Orbit CLI binarymgr keys ----
266 {
267 Name: "orbit_cli_auto_run", Scope: ScopeGlobal, Type: TypeString,
268 UserSettable: true,
269 EnvVars: []string{"GLAB_ORBIT_CLI_AUTO_RUN", "ORBIT_CLI_AUTO_RUN"},
270 Description: "Automatically run the GitLab Orbit CLI without prompting (true/false). Set to true to skip the confirmation prompt.",
271 Values: []string{"true", "false"},
272 },
273 {
274 Name: "orbit_cli_auto_download", Scope: ScopeGlobal, Type: TypeString,
275 UserSettable: true,
276 EnvVars: []string{"GLAB_ORBIT_CLI_AUTO_DOWNLOAD", "ORBIT_CLI_AUTO_DOWNLOAD"},
277 Description: "Automatically download the GitLab Orbit CLI binary without prompting (true/false).",
278 Values: []string{"true", "false"},
279 },
280 {
281 Name: "orbit_cli_binary_path", Scope: ScopeGlobal, Type: TypeString,
282 GlobalOnly: true,
283 UserSettable: true, HelpHidden: true,
284 EnvVars: []string{"GLAB_ORBIT_CLI_BINARY_PATH"},
285 Description: "Path to the installed GitLab Orbit CLI binary (automatically set). Default: ~/.config/glab-cli/bin/orbit",
286 },
287 {
288 Name: "orbit_cli_binary_version", Scope: ScopeGlobal, Type: TypeString,
289 GlobalOnly: true,
290 UserSettable: true, HelpHidden: true,
291 Description: "Version of the installed GitLab Orbit CLI binary (automatically set).",
292 },
293 {
294 Name: "orbit_cli_binary_checksum", Scope: ScopeGlobal, Type: TypeString,
295 GlobalOnly: true,
296 UserSettable: true, HelpHidden: true,
297 Description: "SHA256 checksum of the installed GitLab Orbit CLI binary (automatically set).",
298 },
299 {
300 Name: "orbit_cli_last_update_check", Scope: ScopeGlobal, Type: TypeString,
301 GlobalOnly: true,
302 UserSettable: true, HelpHidden: true,
303 Description: "Last time a GitLab Orbit CLI update check was performed (automatically set).",
304 },
305 // ---- GitLab Endpoint Agent Platform binarymgr keys ----
306 {
307 Name: "minder_cli_auto_run", Scope: ScopeGlobal, Type: TypeString,
308 UserSettable: true,
309 EnvVars: []string{"GLAB_MINDER_CLI_AUTO_RUN", "MINDER_CLI_AUTO_RUN"},
310 Description: "Automatically run the GitLab Endpoint Agent Platform without prompting (true/false). Set to true to skip the confirmation prompt.",
311 Values: []string{"true", "false"},
312 },
313 {
314 Name: "minder_cli_auto_download", Scope: ScopeGlobal, Type: TypeString,
315 UserSettable: true,
316 EnvVars: []string{"GLAB_MINDER_CLI_AUTO_DOWNLOAD", "MINDER_CLI_AUTO_DOWNLOAD"},
317 Description: "Automatically download the GitLab Endpoint Agent Platform binary without prompting (true/false).",
318 Values: []string{"true", "false"},
319 },
320 {
321 Name: "minder_cli_binary_path", Scope: ScopeGlobal, Type: TypeString,
322 GlobalOnly: true,
323 UserSettable: true, HelpHidden: true,
324 EnvVars: []string{"GLAB_MINDER_CLI_BINARY_PATH"},
325 Description: "Path to the installed GitLab Endpoint Agent Platform binary (automatically set). Default: ~/.config/glab-cli/bin/agent-client",
326 },
327 {
328 Name: "minder_cli_binary_version", Scope: ScopeGlobal, Type: TypeString,
329 GlobalOnly: true,
330 UserSettable: true, HelpHidden: true,
331 Description: "Version of the installed GitLab Endpoint Agent Platform binary (automatically set).",
332 },
333 {
334 Name: "minder_cli_binary_checksum", Scope: ScopeGlobal, Type: TypeString,
335 GlobalOnly: true,
336 UserSettable: true, HelpHidden: true,
337 Description: "SHA256 checksum of the installed GitLab Endpoint Agent Platform binary (automatically set).",
338 },
339 {
340 Name: "minder_cli_last_update_check", Scope: ScopeGlobal, Type: TypeString,
341 GlobalOnly: true,
342 UserSettable: true, HelpHidden: true,
343 Description: "Last time a GitLab Endpoint Agent Platform update check was performed (automatically set).",
344 },
346 // ---------------- Per-host ----------------
347 {
348 Name: "api_protocol", Scope: ScopePerHost, Type: TypeString,
349 Default: "https", UserSettable: true, Fallback: true,
350 EnvVars: []string{"GLAB_API_PROTOCOL", "API_PROTOCOL"},
351 Description: "What protocol to use to access the API endpoint. Supported values: 'http', 'https'.",
352 Values: []string{"http", "https"},
353 },
354 {
355 Name: "api_host", Scope: ScopePerHost, Type: TypeString,
356 Default: "gitlab.com", UserSettable: true,
357 Aliases: []string{"gitlab_api_host"},
358 EnvVars: []string{"GITLAB_API_HOST"},
359 Description: "Configure host for API endpoint. Defaults to the host itself.",
360 },
361 {
362 Name: "subfolder", Scope: ScopePerHost, Type: TypeString,
363 UserSettable: true,
364 Aliases: []string{"gitlab_subfolder"},
365 EnvVars: []string{"GITLAB_SUBFOLDER"},
366 Description: "Subfolder where GitLab is installed (e.g., 'gitlab' for https://example.com/gitlab/).\nUse this when GitLab is hosted at a subfolder rather than domain root.\nSupports nested paths (e.g., 'apps/gitlab' for https://example.com/apps/gitlab/).\nSlashes are automatically trimmed, so 'gitlab', '/gitlab', and 'gitlab/' are equivalent.\nOnly applies to HTTP/HTTPS operations (API and Git clone).",
367 },
368 {
369 Name: "ssh_host", Scope: ScopePerHost, Type: TypeString,
370 UserSettable: true,
371 Aliases: []string{"gitlab_ssh_host"},
372 EnvVars: []string{"GITLAB_SSH_HOST"},
373 Description: "Alternate hostname for SSH Git operations (e.g., 'ssh.example.com' or 'git.example.com').\nUse this when SSH uses a different hostname than HTTP/API operations.\nOnly affects SSH cloning and Git operations.",
374 },
375 {
376 Name: "token", Scope: ScopePerHost, Type: TypeString,
377 UserSettable: true, Keyring: true,
378 Aliases: []string{"gitlab_token", "oauth_token"},
379 EnvVars: []string{"GITLAB_TOKEN", "GITLAB_ACCESS_TOKEN", "OAUTH_TOKEN"},
380 Description: "Your GitLab access token. To get one, read https://docs.gitlab.com/user/profile/personal_access_tokens/.\nA token set through an environment variable is sent only to the host named by 'GITLAB_HOST' (or the 'host' configuration key) or 'GITLAB_REPO', and to hosts already present in your configuration file. A host named only in a command argument receives no token.",
381 },
382 {
383 Name: "job_token", Scope: ScopePerHost, Type: TypeString,
384 UserSettable: true, Keyring: true,
385 Description: "CI job token used for Job-Token authentication. Typically populated\nautomatically from CI_JOB_TOKEN when CI auto-login is enabled.",
386 },
387 {
388 Name: "user", Scope: ScopePerHost, Type: TypeString,
389 UserSettable: true, HelpHidden: true,
390 EnvVars: []string{"GLAB_USER"},
391 Description: "Username associated with the configured token. Set automatically on login.",
392 },
393 {
394 Name: "client_id", Scope: ScopePerHost, Type: TypeString,
395 UserSettable: true,
396 EnvVars: []string{"GITLAB_CLIENT_ID"},
397 Description: "OAuth application client ID. Required when authenticating with OAuth\nagainst a self-managed GitLab instance.",
398 },
399 {
400 Name: "use_keyring", Scope: ScopePerHost, Type: TypeString,
401 UserSettable: true,
402 EnvVars: []string{"GLAB_USE_KEYRING", "USE_KEYRING"},
403 Description: "Store the host's credentials in the operating system's keyring (true/false).\nSet automatically by 'glab auth login', which defaults to 'true' when a keyring\nbackend is available. Empty is treated as false (plaintext file storage).",
404 Values: []string{"true", "false"},
405 },
406 {
407 Name: "proxy", Scope: ScopePerHost, Type: TypeString,
408 UserSettable: true,
409 EnvVars: []string{"GLAB_PROXY"},
410 Description: "Custom proxy for this host. Overrides environment proxy settings when set.",
411 },
412 {
413 Name: "ca_cert", Scope: ScopePerHost, Type: TypeString,
414 UserSettable: true,
415 EnvVars: []string{"GLAB_CA_CERT", "CA_CERT"},
416 Description: "Path to a CA certificate (PEM) used to verify the GitLab server's\nTLS certificate. glab dependency-firewall commands also trust it for\npackage registries and outbound proxies. Useful for self-signed or private\ncertificate authorities.",
417 },
418 {
419 Name: "client_cert", Scope: ScopePerHost, Type: TypeString,
420 UserSettable: true,
421 EnvVars: []string{"GLAB_CLIENT_CERT", "CLIENT_CERT"},
422 Description: "Path to a client certificate used for mutual TLS authentication. Use a PEM or DER\ncertificate with client_key, or a PKCS#12 bundle (.p12, .pfx) and leave client_key unset.\nglab dependency-firewall commands also present it to an https:// outbound\nproxy, never to package registries.",
423 },
424 {
425 Name: "client_key", Scope: ScopePerHost, Type: TypeString,
426 UserSettable: true,
427 EnvVars: []string{"GLAB_CLIENT_KEY", "CLIENT_KEY"},
428 Description: "Path to the private key (PEM or DER, in PKCS#8, PKCS#1, or EC format) that matches client_cert.\nLeave unset when client_cert is a PKCS#12 bundle.",
429 },
430 {
431 Name: "client_cert_password", Scope: ScopePerHost, Type: TypeString,
432 UserSettable: true, Keyring: true,
433 EnvVars: []string{"GLAB_CLIENT_CERT_PASSWORD"},
434 Description: "Password that decrypts a PKCS#12 client_cert. Stored in the operating system's\nkeyring when use_keyring is true.",
435 },
436 {
437 Name: "skip_tls_verify", Scope: ScopePerHost, Type: TypeString,
438 UserSettable: true,
439 EnvVars: []string{"GLAB_SKIP_TLS_VERIFY", "SKIP_TLS_VERIFY"},
440 Description: "Skip TLS certificate verification when talking to this host (true/false).\nEmpty is treated as false. Use only for development; do not enable in production.",
441 Values: []string{"true", "false"},
442 },
443 {
444 Name: "container_registry_domains", Scope: ScopePerHost, Type: TypeString,
445 Default: "gitlab.com,gitlab.com:443,registry.gitlab.com", UserSettable: true,
446 EnvVars: []string{"GLAB_CONTAINER_REGISTRY_DOMAINS", "CONTAINER_REGISTRY_DOMAINS"},
447 Description: "The domains of associated container registries. These are used to configure the\nDocker credential helper.",
448 },
449 {
450 Name: "artifact_registry_domains", Scope: ScopePerHost, Type: TypeString,
451 UserSettable: true,
452 EnvVars: []string{"GLAB_ARTIFACT_REGISTRY_DOMAINS", "ARTIFACT_REGISTRY_DOMAINS"},
453 Description: "The domains of associated Artifact Registries. These are used to configure the\n" +
454 "Docker credential helper. Only list a domain here if it is actually backed by\n" +
455 "GitLab Artifact Registry: the credential helper tries this key first, and a\n" +
456 "successful token exchange is used as-is, with no fallback to\n" +
457 "container_registry_domains. A container-registry domain listed here by mistake\n" +
458 "gets an artifact-registry token the registry rejects, and 'docker pull' hard-fails.",
459 },
460 {
461 Name: "custom_headers", Scope: ScopePerHost, Type: TypeList,
462 UserSettable: true,
463 Description: "Custom HTTP headers to add to all HTTP requests made by glab. Each header must use exactly one of value, valueFromEnv, or valueFromCommand. A command must print the complete header value on one line. glab runs it once for each process.\n- name: Proxy-Authorization\n valueFromCommand: token-helper --audience example\n- name: Cf-Access-Client-Secret\n valueFromEnv: MY_SECRET_VALUE",
464 },
466 // ---------------- CLI-managed internal state ----------------
467 // These keys are written by the CLI during auth/login/refresh flows.
468 // They are NOT user-settable (config set rejects them), are NOT
469 // included in the blank config, but the runtime config reader still
470 // resolves them via env vars in the normal way.
471 {
472 Name: "is_oauth2", Scope: ScopePerHost, Type: TypeString,
473 UserSettable: false,
474 EnvVars: []string{"GLAB_IS_OAUTH2"},
475 Description: "CLI-managed flag indicating the host was authenticated via OAuth.",
476 },
477 {
478 Name: "oauth2_refresh_token", Scope: ScopePerHost, Type: TypeString,
479 UserSettable: false, Keyring: true,
480 Description: "CLI-managed OAuth refresh token. Written by 'glab auth login'.",
481 },
482 {
483 Name: "oauth2_expiry_date", Scope: ScopePerHost, Type: TypeString,
484 UserSettable: false,
485 Description: "CLI-managed OAuth token expiry timestamp.",
486 },
487 {
488 Name: "refresh_token", Scope: ScopePerHost, Type: TypeString,
489 UserSettable: false,
490 Description: "CLI-managed refresh token; superseded by oauth2_refresh_token.",
491 },
492}
494func findKeyDef(key string) *KeyDef {
495 for i := range KeySchema {
496 if KeySchema[i].Name == key {
497 return &KeySchema[i]
498 }
499 }
500 return nil
501}
503func resolveAlias(key string) string {
504 key = strings.ToLower(key)
505 for i := range KeySchema {
506 if KeySchema[i].Name == key {
507 return key
508 }
509 if slices.Contains(KeySchema[i].Aliases, key) {
510 return KeySchema[i].Name
511 }
512 }
513 return key
514}
516var defaultAliases = []struct{ Name, Command string }{
517 {"ci", "pipeline ci"},
518 {"co", "mr checkout"},
519}
521const defaultBlankHost = "gitlab.com"
523func userSettableKeys(scope Scope) []*KeyDef {
524 var out []*KeyDef
525 for i := range KeySchema {
526 kd := &KeySchema[i]
527 if kd.UserSettable && kd.Scope == scope {
528 out = append(out, kd)
529 }
530 }
531 return out
532}
534func rootConfig() *yaml.Node {
535 top := &yaml.Node{Kind: yaml.MappingNode}
537 for _, kd := range userSettableKeys(ScopeGlobal) {
538 top.Content = append(top.Content, keyNode(kd), valueNode(kd))
539 }
541 // hosts:
542 hostsKey := &yaml.Node{
543 Kind: yaml.ScalarNode,
544 Value: "hosts",
545 HeadComment: "# Configuration specific for GitLab instances.",
546 }
547 hostsMap := &yaml.Node{Kind: yaml.MappingNode}
548 hostName := &yaml.Node{Kind: yaml.ScalarNode, Value: defaultBlankHost}
549 hostBody := &yaml.Node{Kind: yaml.MappingNode}
550 for _, kd := range userSettableKeys(ScopePerHost) {
551 hostBody.Content = append(hostBody.Content, keyNode(kd), valueNode(kd))
552 }
553 hostsMap.Content = []*yaml.Node{hostName, hostBody}
554 top.Content = append(top.Content, hostsKey, hostsMap)
556 // aliases:
557 aliasesKey := &yaml.Node{
558 Kind: yaml.ScalarNode,
559 Value: "aliases",
560 HeadComment: "# Use aliases to create nicknames for glab commands. Supports shell-executable aliases that may not be glab commands.",
561 }
562 aliasesMap := &yaml.Node{Kind: yaml.MappingNode}
563 for _, a := range defaultAliases {
564 aliasesMap.Content = append(aliasesMap.Content,
565 &yaml.Node{Kind: yaml.ScalarNode, Value: a.Name},
566 &yaml.Node{Kind: yaml.ScalarNode, Value: a.Command},
567 )
568 }
569 top.Content = append(top.Content, aliasesKey, aliasesMap)
571 return &yaml.Node{Kind: yaml.DocumentNode, Content: []*yaml.Node{top}}
572}
574func keyNode(kd *KeyDef) *yaml.Node {
575 n := &yaml.Node{Kind: yaml.ScalarNode, Value: kd.Name}
576 if kd.Description != "" {
577 n.HeadComment = "# " + strings.ReplaceAll(kd.Description, "\n", "\n# ")
578 }
579 return n
580}
582func valueNode(kd *KeyDef) *yaml.Node {
583 if kd.Type == TypeList {
584 return &yaml.Node{Kind: yaml.SequenceNode}
585 }
586 return &yaml.Node{Kind: yaml.ScalarNode, Value: kd.Default}
587}
Diagnostics6 git calls · 254 ms
CallStatusSizeTime0254 ms
discover200185 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=185 git.server.agent=git/2.56.g1891de4-Linux git.server.object_format=sha1 git.server.caps=agent ls-refs fetch server-option object-format git.server.fetch=shallow wait-for-done filter git.protocol.version=2 git.pkt.frames=9 git.pkt.data=7 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=185 git.pkt.payload.max=35
ls-refs20058 KiB · hit2 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=59849 git.response.cache=HIT git.response.duration_ms=2 git.protocol.version=2 git.pkt.frames=731 git.pkt.data=730 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=59849 git.pkt.payload.max=143 git.ls_refs.count=730 git.ls_refs.head=refs/heads/main
fetchtree:0 · deepen 1020032 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=32926 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=tree:0 git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9 git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=22 git.pkt.data=20 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=32926 git.pkt.payload.max=32046 git.sideband.band1.bytes=32046 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=80 git.pack.bytes=32046 git.pack.ofs_delta=36 git.pack.ref_delta=0 git.pack.chain.max=2 git.pack.trailer=cb0bad5d7ffc514895d8b21c4dd470327f90bc91 git.pack.full=44Open pack map
fetchcombine:blob:none+tree:2 · deepen 12004.2 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=4273 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=combine:blob:none+tree:2 git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9 git.fetch.haves.count=0 git.fetch.deepen=1 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=7 git.pkt.data=5 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=4273 git.pkt.payload.max=4173 git.sideband.band1.bytes=4173 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=11 git.pack.bytes=4173 git.fetch.wide.objects=11 git.fetch.wide.extra_bytes=3930 git.fetch.wide.blobs=0
fetchtree:02001.4 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=247 git.response.bytes=1391 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=tree:0 git.fetch.wants=e9da9edfdcf44933ee5fa121d411de326220161c git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1391 git.pkt.payload.max=1364 git.sideband.band1.bytes=1364 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=1364 git.pack.trailer=bf750bd385ed98d15e1fea1289d3b00caa61d64cOpen pack map
fetch2006.7 KiB247 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=6893 git.response.cache=MISS git.response.duration_ms=247 git.fetch.wants=8b18282da3c1e50edbcc9ec41acacab850063e07 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=6893 git.pkt.payload.max=6866 git.sideband.band1.bytes=6866 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://gitlab.com/gitlab-org/cli
- Ref
- refs/heads/main
- Commit
- 0dd7574dce9e385c5c30540e6c15657adc6bdce9
- cf-ray
- a5e25a24dfd9a23e
- Request
- 0c2186f8…
- Protocol
- v2 · sha1
- Agent
- git/2.56.g1891de4-Linux
- Filter
- advertised
- Fetch
- shallow wait-for-done filter
- Capabilities
- agent ls-refs fetch server-option object-format