Skip to content

Commit

Permalink
fix suggestions of linter
Browse files Browse the repository at this point in the history
  • Loading branch information
kobtea committed Jan 2, 2023
1 parent 7150e95 commit 2adcc18
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ setup:
go get golang.org/x/tools/cmd/goimports

lint:
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint golangci-lint run -E gofmt,goimports
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint golangci-lint run -E gofmt,goimports --timeout 5m

fmt:
go fmt ./...
Expand Down
4 changes: 2 additions & 2 deletions check/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func Check(ctx context.Context, cfg *config.Config) error {
Combine: ConftestConfig.Combine,
Policy: ConftestConfig.Policies,
}
logger.Debugw(fmt.Sprintf("conftest"), "policy", ConftestConfig.Policies, "input", files)
logger.Debugw("conftest", "policy", ConftestConfig.Policies, "input", files)
res, err := r.Run(ctx, files)
if err != nil {
return err
Expand Down Expand Up @@ -74,7 +74,7 @@ func Check(ctx context.Context, cfg *config.Config) error {
Combine: ConftestConfig.Combine,
Policy: ConftestConfig.Policies,
}
logger.Debugw(fmt.Sprintf("conftest"), "policy", ConftestConfig.Policies, "input", files)
logger.Debugw("conftest", "policy", ConftestConfig.Policies, "input", files)
res, err := r.Run(ctx, files)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions cmd/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
var checkCmd = &cobra.Command{
Use: "check",
Short: "Test policies",
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
check.Check(ctx, cfg)
return check.Check(ctx, cfg)
},
}

Expand Down
6 changes: 5 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ func initConfig() {
loggerConfig.Level = lv
loggerConfig.EncoderConfig.EncodeTime = zapcore.TimeEncoderOfLayout(time.RFC3339)
logger, err := loggerConfig.Build()
defer logger.Sync()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
defer func() {
if er := logger.Sync(); er != nil {
fmt.Println(er)
}
}()
zap.ReplaceGlobals(logger)
}
4 changes: 3 additions & 1 deletion fetch/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ func Fetch(ctx context.Context, cfg *config.Config) error {
}
}
}
storage.DoGc()
if err := storage.DoGc(); err != nil {
return err
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (s *Storage) UpdateSource(domain, name, repo, cloneUrl, tokenEnvvarName str
path := s.RepoPath(SourceDirname, domain, name, repo)
gitRepo, err := git.PlainOpen(path)
if errors.Is(err, git.ErrRepositoryNotExists) {
gitRepo, err = git.PlainClone(path, false, &git.CloneOptions{
_, err = git.PlainClone(path, false, &git.CloneOptions{
URL: cloneUrl,
Depth: 1,
Auth: &http.BasicAuth{Username: "username", Password: token},
Expand Down

0 comments on commit 2adcc18

Please sign in to comment.