@@ -24,7 +24,7 @@ import (
24
24
25
25
type protocol string
26
26
27
- // portMapping is the port mapping configurations of a sandbox.
27
+ // PortMapping is the port mapping configurations of a sandbox.
28
28
type PortMapping struct {
29
29
// protocol of the port mapping.
30
30
Protocol * protocol
@@ -34,7 +34,7 @@ type PortMapping struct {
34
34
HostPort * int32
35
35
}
36
36
37
- // CheckpointData contains all types of data that can be stored in the checkpoint.
37
+ // Data contains all types of data that can be stored in the checkpoint.
38
38
type Data struct {
39
39
PortMappings []* PortMapping `json:"port_mappings,omitempty"`
40
40
HostNetwork bool `json:"host_network,omitempty"`
@@ -48,15 +48,18 @@ type CheckpointData struct {
48
48
Checksum checksum.Checksum
49
49
}
50
50
51
+ // MarshalCheckpoint tries to marshal the CheckpointData into JSON data.
51
52
func (cp * CheckpointData ) MarshalCheckpoint () ([]byte , error ) {
52
53
cp .Checksum = checksum .New (* cp .Data )
53
54
return json .Marshal (* cp )
54
55
}
55
56
57
+ // UnmarshalCheckpoint tries to unmarshal the passed JSON data into CheckpointData.
56
58
func (cp * CheckpointData ) UnmarshalCheckpoint (blob []byte ) error {
57
59
return json .Unmarshal (blob , cp )
58
60
}
59
61
62
+ // VerifyChecksum verifies that CheckpointData's checksum is same as the checksum calculated by its data.
60
63
func (cp * CheckpointData ) VerifyChecksum () error {
61
64
return cp .Checksum .Verify (* cp .Data )
62
65
}
0 commit comments