Skip to content

Commit

Permalink
Fix linter discovered issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkoyun committed Apr 11, 2020
1 parent df63afe commit a63fae4
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ linters-settings:
lll:
line-length: 120
funlen:
lines: 85
statements: 45
lines: 70
statements: 40

2 changes: 2 additions & 0 deletions archive/tar/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ func relative(parent string, path string) (string, error) {
for strings.HasPrefix(rel, "../") {
rel = strings.TrimPrefix(rel, "../")
}

rel = filepath.ToSlash(rel)

return strings.TrimPrefix(filepath.Join(rel, name), "/"), nil
}

Expand Down
6 changes: 4 additions & 2 deletions cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ func New(logger log.Logger, s storage.Storage, a archive.Archive, g key.Generato
}

return &cache{
NewRebuilder(log.With(logger, "component", "rebuilder"), s, a, g, options.fallbackGenerator, options.namespace, options.override),
NewRestorer(log.With(logger, "component", "restorer"), s, a, g, options.fallbackGenerator, options.namespace),
NewRebuilder(log.With(logger, "component", "rebuilder"), s, a, g,
options.fallbackGenerator, options.namespace, options.override),
NewRestorer(log.With(logger, "component", "restorer"), s, a, g,
options.fallbackGenerator, options.namespace),
NewFlusher(log.With(logger, "component", "flusher"), s, time.Hour),
}
}
2 changes: 1 addition & 1 deletion internal/plugin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ type Config struct {

// Optional
SkipSymlinks bool
Override bool
CompressionLevel int
StorageOperationTimeout time.Duration
Override bool

Mount []string

Expand Down
2 changes: 1 addition & 1 deletion internal/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func New(logger log.Logger) *Plugin {
}

// Exec entry point of Plugin, where the magic happens.
func (p *Plugin) Exec() error {
func (p *Plugin) Exec() error { //nolint:funlen
cfg := p.Config

// 1. Check parameters
Expand Down
2 changes: 2 additions & 0 deletions storage/backend/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ func (b *Backend) Exists(ctx context.Context, p string) (bool, error) {
b.logger.Log("msg", "checking if the object already exists", "name", p)

blobURL := b.containerURL.NewBlockBlobURL(p)

get, err := blobURL.GetProperties(ctx, azblob.BlobAccessConditions{})
if err != nil {
return false, fmt.Errorf("check if object exists, %w", err)
}

return get.StatusCode() == http.StatusOK, nil
}
1 change: 1 addition & 0 deletions storage/backend/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,6 @@ func (b *Backend) Exists(ctx context.Context, p string) (bool, error) {
if err != nil && !os.IsNotExist(err) {
return false, fmt.Errorf("check the object exists, %w", err)
}

return err == nil, nil
}
2 changes: 1 addition & 1 deletion storage/backend/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (b *Backend) Exists(ctx context.Context, p string) (bool, error) {
return false, fmt.Errorf("head the object, %w", err)
}

// Normaly if file not exists it will be already detected by error above but in some cases
// Normally if file not exists it will be already detected by error above but in some cases
// Minio can return success status for without ETag, detect that here.
return *out.ETag != "", nil
}

0 comments on commit a63fae4

Please sign in to comment.