Merge pull request #86409 from sshukun/fix-golint

Fix go-lint issues in package pkg/kubelet/checkpointmanager/testing/example_checkpoint_formats/v1
This commit is contained in:
Kubernetes Prow Robot 2020-04-06 15:42:01 -07:00 committed by GitHub
commit 8cdf21ab4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -100,7 +100,6 @@ pkg/kubeapiserver
pkg/kubeapiserver/options
pkg/kubectl/cmd/convert
pkg/kubelet/apis/config/v1beta1
pkg/kubelet/checkpointmanager/testing/example_checkpoint_formats/v1
pkg/kubelet/cm
pkg/kubelet/container
pkg/kubelet/container/testing

View File

@ -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)
}