v3.5.0 8345e76

annotations.go RawHistoryFolder

1package manifest
2
3import (
4	"encoding/json"
5	"fmt"
6)
7
8// ParseManifestAnnotations extracts annotations from manifest data
9func ParseManifestAnnotations(manifestData []byte, contentType string) (map[string]string, error) {
10	switch contentType {
11	case "application/vnd.oci.image.manifest.v1+json":
12		return parseOCIManifestAnnotations(manifestData)
13	case "application/vnd.docker.distribution.manifest.v2+json":
14		// Docker v2.2 manifests don't support annotations at manifest level
15		return map[string]string{}, nil
16	case "application/vnd.oci.image.index.v1+json",
17		"application/vnd.docker.distribution.manifest.list.v2+json":
18		return parseManifestListAnnotations(manifestData)
19	default:
20		return map[string]string{}, fmt.Errorf("unsupported manifest media type: %s", contentType)
21	}
22}
23
24// parseOCIManifestAnnotations parses annotations from an OCI image manifest
25func parseOCIManifestAnnotations(manifestData []byte) (map[string]string, error) {
26	var manifest OCIManifest
27	if err := json.Unmarshal(manifestData, &manifest); err != nil {
28		return nil, fmt.Errorf("failed to parse OCI manifest: %w", err)
29	}
30
31	if manifest.Annotations == nil {
32		return map[string]string{}, nil
33	}
34
35	return manifest.Annotations, nil
36}
37
38// parseManifestListAnnotations parses annotations from a manifest list
39func parseManifestListAnnotations(manifestData []byte) (map[string]string, error) {
40	var manifestList ManifestList
41	if err := json.Unmarshal(manifestData, &manifestList); err != nil {
42		return nil, fmt.Errorf("failed to parse manifest list: %w", err)
43	}
44
45	if manifestList.Annotations == nil {
46		return map[string]string{}, nil
47	}
48
49	return manifestList.Annotations, nil
50}
51
52// IsVersionedDeployment checks if manifest contains version annotations for deployment
53func IsVersionedDeployment(annotations map[string]string) bool {
54	// Just check for the "version" annotation - keep it simple
55	_, exists := annotations["version"]
56	return exists
57}
58
59// GetDeploymentVersion extracts the deployment version from annotations
60func GetDeploymentVersion(annotations map[string]string) string {
61	// Just use the "version" annotation - keep it simple
62	if version, exists := annotations["version"]; exists && version != "" {
63		return version
64	}
65
66	return ""
67}

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