Fix go lint errors
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
@@ -20,6 +20,9 @@ const (
|
||||
KindCommitted
|
||||
)
|
||||
|
||||
// ParseKind parses the provided string into a Kind
|
||||
//
|
||||
// If the string cannot be parsed KindUnknown is returned
|
||||
func ParseKind(s string) Kind {
|
||||
s = strings.ToLower(s)
|
||||
switch s {
|
||||
@@ -34,6 +37,7 @@ func ParseKind(s string) Kind {
|
||||
return KindUnknown
|
||||
}
|
||||
|
||||
// String returns the string representation of the Kind
|
||||
func (k Kind) String() string {
|
||||
switch k {
|
||||
case KindView:
|
||||
@@ -47,10 +51,12 @@ func (k Kind) String() string {
|
||||
return "Unknown"
|
||||
}
|
||||
|
||||
// MarshalJSON the Kind to JSON
|
||||
func (k Kind) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(k.String())
|
||||
}
|
||||
|
||||
// UnmarshalJSON the Kind from JSON
|
||||
func (k *Kind) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(b, &s); err != nil {
|
||||
@@ -81,6 +87,7 @@ type Usage struct {
|
||||
Size int64 // provides usage, in bytes, of snapshot
|
||||
}
|
||||
|
||||
// Add the provided usage to the current usage
|
||||
func (u *Usage) Add(other Usage) {
|
||||
u.Size += other.Size
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ func GetInfo(ctx context.Context, key string) (string, snapshot.Info, snapshot.U
|
||||
return fmt.Sprintf("%d", id), si, su, nil
|
||||
}
|
||||
|
||||
// UpdateInfo updates an existing snapshot info's data
|
||||
func UpdateInfo(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) {
|
||||
updated := snapshot.Info{
|
||||
Name: info.Name,
|
||||
@@ -131,11 +132,7 @@ func UpdateInfo(ctx context.Context, info snapshot.Info, fieldpaths ...string) (
|
||||
return err
|
||||
}
|
||||
|
||||
if err := boltutil.WriteLabels(sbkt, updated.Labels); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return boltutil.WriteLabels(sbkt, updated.Labels)
|
||||
})
|
||||
if err != nil {
|
||||
return snapshot.Info{}, err
|
||||
@@ -534,12 +531,7 @@ func putSnapshot(bkt *bolt.Bucket, id uint64, si snapshot.Info) error {
|
||||
if err := boltutil.WriteTimestamps(bkt, si.Created, si.Updated); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := boltutil.WriteLabels(bkt, si.Labels); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return boltutil.WriteLabels(bkt, si.Labels)
|
||||
}
|
||||
|
||||
func getUsage(bkt *bolt.Bucket, usage *snapshot.Usage) {
|
||||
@@ -569,7 +561,7 @@ func putUsage(bkt *bolt.Bucket, usage snapshot.Usage) error {
|
||||
func encodeSize(size int64) ([]byte, error) {
|
||||
var (
|
||||
buf [binary.MaxVarintLen64]byte
|
||||
sizeEncoded []byte = buf[:]
|
||||
sizeEncoded = buf[:]
|
||||
)
|
||||
sizeEncoded = sizeEncoded[:binary.PutVarint(sizeEncoded, size)]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user