Skip to content

Commit 06e23e6

Browse files
authored
Merge pull request #197 from adrianreber/2026-02-12-annotations
lib: Add Annotations field to CheckpointedPodOptions
2 parents e740b9d + 9a26328 commit 06e23e6

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

lib/metadata.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ type CheckpointedPodOptions struct {
8585
Version int `json:"version"`
8686
// Containers is a map with the short container name as key and the full name as value
8787
Containers map[string]string `json:"containers"`
88+
// Annotations stores checkpoint-related annotations (keys defined in annotations.go)
89+
Annotations map[string]string `json:"annotations,omitempty"`
8890
}
8991

9092
func ReadContainerCheckpointSpecDump(checkpointDirectory string) (*spec.Spec, string, error) {

lib/metadata_test.go

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import (
88

99
func TestReadContainerCheckpointPodOptions(t *testing.T) {
1010
tests := []struct {
11-
name string
12-
podOptions CheckpointedPodOptions
13-
wantVersion int
14-
wantContLen int
11+
name string
12+
podOptions CheckpointedPodOptions
13+
wantVersion int
14+
wantContLen int
15+
wantAnnotations map[string]string
1516
}{
1617
{
1718
name: "valid pod options",
@@ -34,6 +35,27 @@ func TestReadContainerCheckpointPodOptions(t *testing.T) {
3435
wantVersion: 2,
3536
wantContLen: 0,
3637
},
38+
{
39+
name: "with annotations",
40+
podOptions: CheckpointedPodOptions{
41+
Version: 1,
42+
Containers: map[string]string{
43+
"test": "test-container",
44+
},
45+
Annotations: map[string]string{
46+
CheckpointAnnotationEngine: "podman",
47+
CheckpointAnnotationEngineVersion: "4.0.0",
48+
CheckpointAnnotationPod: "test-pod",
49+
},
50+
},
51+
wantVersion: 1,
52+
wantContLen: 1,
53+
wantAnnotations: map[string]string{
54+
CheckpointAnnotationEngine: "podman",
55+
CheckpointAnnotationEngineVersion: "4.0.0",
56+
CheckpointAnnotationPod: "test-pod",
57+
},
58+
},
3759
}
3860

3961
for _, tt := range tests {
@@ -57,6 +79,17 @@ func TestReadContainerCheckpointPodOptions(t *testing.T) {
5779
if len(podOptions.Containers) != tt.wantContLen {
5880
t.Errorf("expected %d containers, got %d", tt.wantContLen, len(podOptions.Containers))
5981
}
82+
83+
if tt.wantAnnotations != nil {
84+
if len(podOptions.Annotations) != len(tt.wantAnnotations) {
85+
t.Errorf("expected %d annotations, got %d", len(tt.wantAnnotations), len(podOptions.Annotations))
86+
}
87+
for k, v := range tt.wantAnnotations {
88+
if podOptions.Annotations[k] != v {
89+
t.Errorf("expected annotation %s=%s, got %s", k, v, podOptions.Annotations[k])
90+
}
91+
}
92+
}
6093
})
6194
}
6295
}

0 commit comments

Comments
 (0)