v2.0.0 ae3e752

helpers.go RawHistoryFolder

1package container
2
3import (
4	"crypto/sha256"
5	"fmt"
6	"regexp"
7	"strings"
8)
9
10// generateVolumeName creates a deterministic volume name for a domain and path
11func generateVolumeName(prefix, domain, path string) string {
12	// Sanitize domain name for use in volume name
13	sanitizedDomain := sanitizeDomainForVolume(domain)
14
15	// Create a short hash of the path to handle long paths and special characters
16	hasher := sha256.New()
17	hasher.Write([]byte(path))
18	pathHash := fmt.Sprintf("%x", hasher.Sum(nil))[:8]
19
20	return fmt.Sprintf("%s-%s-%s", prefix, sanitizedDomain, pathHash)
21}
22
23// sanitizeDomainForVolume converts domain to volume-safe format
24func sanitizeDomainForVolume(domain string) string {
25	// Replace dots and other special characters with hyphens
26	reg := regexp.MustCompile(`[^a-zA-Z0-9\-]`)
27	sanitized := reg.ReplaceAllString(domain, "-")
28
29	// Remove leading/trailing hyphens and convert to lowercase
30	sanitized = strings.Trim(sanitized, "-")
31	sanitized = strings.ToLower(sanitized)
32
33	return sanitized
34}
35
36// normalizeImageRef normalizes image references for comparison
37func normalizeImageRef(imageRef string) string {
38	// Split image and tag
39	parts := strings.Split(imageRef, ":")
40	image := parts[0]
41	tag := "latest"
42	if len(parts) > 1 {
43		tag = parts[1]
44	}
45
46	// Normalize Docker Hub references
47	if !strings.Contains(image, "/") {
48		// Official library image (e.g., "nginx" -> "docker.io/library/nginx")
49		image = "docker.io/library/" + image
50	} else if strings.Count(image, "/") == 1 && !strings.Contains(strings.Split(image, "/")[0], ".") {
51		// User repository (e.g., "user/repo" -> "docker.io/user/repo")
52		image = "docker.io/" + image
53	}
54
55	return image + ":" + tag
56}
57
58// mergeEnvironmentVariables merges Dockerfile ENV directives with user-provided env vars
59// User-provided env vars take precedence over Dockerfile ENV directives
60func mergeEnvironmentVariables(dockerfileEnv, userEnv []string) []string {
61	// Create a map to store environment variables by key
62	envMap := make(map[string]string)
63
64	// First, add Dockerfile ENV directives
65	for _, env := range dockerfileEnv {
66		parts := strings.SplitN(env, "=", 2)
67		if len(parts) == 2 {
68			envMap[parts[0]] = parts[1]
69		}
70	}
71
72	// Then, add user-provided env vars (these override Dockerfile ENV)
73	for _, env := range userEnv {
74		parts := strings.SplitN(env, "=", 2)
75		if len(parts) == 2 {
76			envMap[parts[0]] = parts[1]
77		}
78	}
79
80	// Convert back to slice format
81	var result []string
82	for key, value := range envMap {
83		result = append(result, fmt.Sprintf("%s=%s", key, value))
84	}
85
86	return result
87}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close