Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Commit

Permalink
Fix typos and wrap errors (#82)
Browse files Browse the repository at this point in the history
* Fix typo

* Fix golint warnings

* wrap errors

* fix

* fix
  • Loading branch information
yiranwang52 authored Nov 29, 2018
1 parent c4194f3 commit 2d649e2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
6 changes: 3 additions & 3 deletions cli/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ func (app *BuildApplication) PostFlagParse() error {

logger, err := app.getLogger()
if err != nil {
return fmt.Errorf("build logger: %v", err)
return fmt.Errorf("build logger: %s", err)
}
log.SetLogger(logger.Sugar())

if app.Profile {
if err := app.setupProfiler(); err != nil {
return fmt.Errorf("setup profiler: %v", err)
return fmt.Errorf("setup profiler: %s", err)
}
}

if err := app.BuildFlags.postInit(); err != nil {
return err
return fmt.Errorf("process flags: %s", err)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion lib/builder/build_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (stage *buildStage) saveImage(store storage.ImageStore, repo, tag string) (
}

manifestPath := manifestFile.Name()
// Remove temp file after hardlinked to manifest store
// Remove temp file after hard-linked to manifest store
defer os.Remove(manifestPath)

if err := ioutil.WriteFile(manifestPath, manifestJSON, 0755); err != nil {
Expand Down
19 changes: 12 additions & 7 deletions lib/cache/fs_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package cache

import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"sync"
Expand Down Expand Up @@ -52,11 +53,11 @@ func NewFSStore(fullpath string, sandboxDir string, ttlsec int64) (KVStore, erro
if os.IsNotExist(err) {
return s, nil
} else if err != nil {
return nil, err
return nil, fmt.Errorf("read cache id file: %s", err)
}
if err := json.Unmarshal(contents, &s.entries); err != nil {
if err := os.Remove(fullpath); err != nil {
return nil, err
return nil, fmt.Errorf("remove cache id file: %s", err)
}
return s, nil
}
Expand Down Expand Up @@ -99,20 +100,20 @@ func (s *fsStore) Put(key, value string) error {

content, err := json.Marshal(s.entries)
if err != nil {
return err
return fmt.Errorf("marshal cache id file: %s", err)
}

tempFile, err := ioutil.TempFile(s.sandboxDir, "cache")
if err != nil {
return err
return fmt.Errorf("create temp cache id file: %s", err)
}
defer os.Remove(tempFile.Name())

if err := ioutil.WriteFile(tempFile.Name(), content, 0755); err != nil {
return err
return fmt.Errorf("write to temp cache id file: %s", err)
}
if err := os.Rename(tempFile.Name(), s.fullpath); err != nil {
return err
return fmt.Errorf("rename cache id file: %s", err)
}

return nil
Expand All @@ -124,5 +125,9 @@ func (s *fsStore) Cleanup() error {

s.entries = make(map[string]*cacheEntry)

return os.Remove(s.fullpath)
if err := os.Remove(s.fullpath); err != nil {
return fmt.Errorf("remove cache id file: %s", err)
}

return nil
}
2 changes: 1 addition & 1 deletion lib/context/build_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type BuildContext struct {
// persisted.
StageVars map[string]string

// MemFS and ImageStore can be shared accross all copies of the BuildContext.
// MemFS and ImageStore can be shared across all copies of the BuildContext.
MemFS *snapshot.MemFS // Merged view of base layers. Layers should be merged in order.
ImageStore storage.ImageStore // Stores image layers and manifests.

Expand Down
12 changes: 3 additions & 9 deletions lib/snapshot/testutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func findNode(fs *MemFS, p string, followSymlink bool, depth int) (*memFSNode, e
}

func writeTarHelper(m *memFile, srcRoot string, w *tar.Writer) error {
if err := filepath.Walk(srcRoot, func(p string, fi os.FileInfo, err error) error {
return filepath.Walk(srcRoot, func(p string, fi os.FileInfo, err error) error {
if err != nil {
return err
}
Expand All @@ -213,14 +213,8 @@ func writeTarHelper(m *memFile, srcRoot string, w *tar.Writer) error {
return err
}

if err := tario.WriteEntry(w, p, h); err != nil {
return err
}
return nil
}); err != nil {
return err
}
return nil
return tario.WriteEntry(w, p, h)
})
}

func readTarHelper(r *tar.Reader) (map[string]*tar.Header, error) {
Expand Down

0 comments on commit 2d649e2

Please sign in to comment.