From 12a5bdec00800cb3347d805ff96901720a9de55a Mon Sep 17 00:00:00 2001 From: sshukun Date: Thu, 19 Dec 2019 12:53:33 +0900 Subject: [PATCH] Fix go-lint issues in package pkg/kubelet/checkpointmanager/testing/example_checkpoint_formats/v1 --- hack/.golint_failures | 1 - .../testing/example_checkpoint_formats/v1/types.go | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hack/.golint_failures b/hack/.golint_failures index 13a88b0d7fe..f6adf66a4f6 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -104,7 +104,6 @@ pkg/kubeapiserver/options pkg/kubectl/cmd/convert pkg/kubelet/apis/config pkg/kubelet/apis/config/v1beta1 -pkg/kubelet/checkpointmanager/testing/example_checkpoint_formats/v1 pkg/kubelet/cm pkg/kubelet/config pkg/kubelet/container diff --git a/pkg/kubelet/checkpointmanager/testing/example_checkpoint_formats/v1/types.go b/pkg/kubelet/checkpointmanager/testing/example_checkpoint_formats/v1/types.go index 7a883d5b5c8..ef0c53129b7 100644 --- a/pkg/kubelet/checkpointmanager/testing/example_checkpoint_formats/v1/types.go +++ b/pkg/kubelet/checkpointmanager/testing/example_checkpoint_formats/v1/types.go @@ -24,7 +24,7 @@ import ( type protocol string -// portMapping is the port mapping configurations of a sandbox. +// PortMapping is the port mapping configurations of a sandbox. type PortMapping struct { // protocol of the port mapping. Protocol *protocol @@ -34,7 +34,7 @@ type PortMapping struct { HostPort *int32 } -// CheckpointData contains all types of data that can be stored in the checkpoint. +// Data contains all types of data that can be stored in the checkpoint. type Data struct { PortMappings []*PortMapping `json:"port_mappings,omitempty"` HostNetwork bool `json:"host_network,omitempty"` @@ -48,15 +48,18 @@ type CheckpointData struct { Checksum checksum.Checksum } +// MarshalCheckpoint tries to marshal the CheckpointData into JSON data. func (cp *CheckpointData) MarshalCheckpoint() ([]byte, error) { cp.Checksum = checksum.New(*cp.Data) return json.Marshal(*cp) } +// UnmarshalCheckpoint tries to unmarshal the passed JSON data into CheckpointData. func (cp *CheckpointData) UnmarshalCheckpoint(blob []byte) error { return json.Unmarshal(blob, cp) } +// VerifyChecksum verifies that CheckpointData's checksum is same as the checksum calculated by its data. func (cp *CheckpointData) VerifyChecksum() error { return cp.Checksum.Verify(*cp.Data) }