Skip to content

Commit

Permalink
Upgrade linter version
Browse files Browse the repository at this point in the history
  • Loading branch information
mortent authored and phanimarupaka committed Oct 16, 2020
1 parent f881eaf commit 6596050
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ license:
GOBIN=$(GOBIN) scripts/update-license.sh

lint:
(which golangci-lint || go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.22.2)
(which golangci-lint || go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.31.0)
$(GOBIN)/golangci-lint run ./...

# TODO: enable this as part of `all` target when it works for go-errors
Expand Down
85 changes: 85 additions & 0 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/cmdexport/cmdexport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (t *TestCase) ReplaceDIRMacro() error {

var params []string
for _, param := range t.params {
param = strings.Replace(param, "{DIR}", cwd, -1)
param = strings.ReplaceAll(param, "{DIR}", cwd)

params = append(params, param)
}
Expand Down
3 changes: 1 addition & 2 deletions internal/testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ func Replace(t *testing.T, path, old, new string) {
t.FailNow()
}
// update the expected contents to reflect the set command
b = []byte(strings.Replace(
string(b), old, new, -1))
b = []byte(strings.ReplaceAll(string(b), old, new))
if !assert.NoError(t, ioutil.WriteFile(path, b, 0)) {
t.FailNow()
}
Expand Down
2 changes: 1 addition & 1 deletion internal/util/update/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func TestCommand_Run_localPackageChanges(t *testing.T) {
// Update upstream to Dataset2
UpstreamChanges: []Content{{Data: testutil.Dataset2}},
}
//defer g.Clean()
defer g.Clean()
if !g.Init() {
t.FailNow()
}
Expand Down
18 changes: 11 additions & 7 deletions release/formula/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ func main() {
os.Exit(1)
}
input := Input{Version: os.Args[1]}
input.Sha = getSha(input.Version)
var err error
input.Sha, err = getSha(input.Version)
if err != nil {
os.Exit(1)
}

// generate the formula text
t, err := template.New("formula").Parse(formula)
Expand All @@ -56,12 +60,12 @@ func main() {
}
}

func getSha(version string) string {
func getSha(version string) (string, error) {
// create the dir for the data
d, err := ioutil.TempDir("", "kpt-bin")
if err != nil {
fmt.Fprintf(os.Stderr, "%v", err)
os.Exit(1)
return "", err
}
defer os.RemoveAll(d)

Expand All @@ -72,7 +76,7 @@ func getSha(version string) string {
"https://github.com/GoogleContainerTools/kpt/archive/" + version + ".tar.gz")
if err != nil {
fmt.Fprintf(os.Stderr, "%v", err)
os.Exit(1)
return "", err
}
defer resp.Body.Close()

Expand All @@ -83,24 +87,24 @@ func getSha(version string) string {
fmt.Fprintf(os.Stderr, "%v", err)
os.Exit(1)
}
defer out.Close()

if _, err = io.Copy(out, resp.Body); err != nil {
fmt.Fprintf(os.Stderr, "%v", err)
os.Exit(1)
}
out.Close()
}()

// calculate the sha
e := exec.Command("sha256sum", filepath.Join(d, version+".tar.gz"))
o, err := e.Output()
if err != nil {
fmt.Fprintf(os.Stderr, "%v", err)
os.Exit(1)
return "", err
}
parts := strings.Split(string(o), " ")
fmt.Println("new sha: " + parts[0])
return parts[0]
return parts[0], nil
}

type Input struct {
Expand Down

0 comments on commit 6596050

Please sign in to comment.