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 44cc3e6
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 15 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

8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ all: drone-cache

.PHONY: setup
setup: ## Setups dev environment
setup: install-tools ; $(info $(M) running setup )
setup: vendor ; $(info $(M) running setup for development )
$(Q) make $(GOTEST_BIN) $(EMBEDMD_BIN) $(LICHE_BIN) $(GOLANGCI_LINT_BIN)

drone-cache: ## Runs drone-cache target
drone-cache: vendor main.go $(wildcard *.go) $(wildcard */*.go) ; $(info $(M) running drone-cache )
Expand Down Expand Up @@ -152,11 +153,6 @@ format: ; $(info $(M) running format )
help: ## Shows this help message
$(Q) awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m\t %s\n", $$1, $$2 }' $(MAKEFILE_LIST)

.PHONY: install-tools
install-tools: ## Install tools
install-tools: vendor ; $(info $(M) installing tools)
$(Q) make $(GOTEST_BIN) $(EMBEDMD_BIN) $(LICHE_BIN) $(GOLANGCI_LINT_BIN)

# Dependencies

$(GOTEST_BIN): ; $(info $(M) getting gotest )
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ Targets:
setup Setups dev environment
drone-cache Runs drone-cache target
build Runs build target, always builds
release Release dron-cache
snapshot Creates snapshot release without publishing it
clean Cleans build resourcess
docs Generates docs
generate Generate documentation, website and yaml files,
Expand Down
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 44cc3e6

Please sign in to comment.