From ee94b7c2d9acd1eb3b9c105c79e860dbbf2a5121 Mon Sep 17 00:00:00 2001 From: Richard Kovacs Date: Tue, 6 Sep 2022 17:57:10 +0200 Subject: [PATCH 1/4] Otherwise git hook fails if only untracked --- .husky/hooks/pre-push | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/hooks/pre-push b/.husky/hooks/pre-push index 96f07a56..5453c613 100755 --- a/.husky/hooks/pre-push +++ b/.husky/hooks/pre-push @@ -1,6 +1,6 @@ #!/bin/bash -if [[ -n "$(git status --short)" ]]; then +if [[ -n "$(git status --short | grep -v "??")" ]]; then git stash function unstash() { git reset --hard From a56296df4b341760951dfb35dac84f431d677c6d Mon Sep 17 00:00:00 2001 From: Richard Kovacs Date: Tue, 6 Sep 2022 18:14:06 +0200 Subject: [PATCH 2/4] Simplify git hook --- .husky/hooks/pre-push | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/hooks/pre-push b/.husky/hooks/pre-push index 5453c613..100269be 100755 --- a/.husky/hooks/pre-push +++ b/.husky/hooks/pre-push @@ -1,6 +1,6 @@ #!/bin/bash -if [[ -n "$(git status --short | grep -v "??")" ]]; then +if git status --short | grep -v "??"; then git stash function unstash() { git reset --hard From 1f9ead2e974a8d964ad4f60eb18c0948ae57ebc8 Mon Sep 17 00:00:00 2001 From: Richard Kovacs Date: Tue, 6 Sep 2022 18:14:59 +0200 Subject: [PATCH 3/4] Simplify git hook --- .husky/hooks/pre-push | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/hooks/pre-push b/.husky/hooks/pre-push index 100269be..56ed56ce 100755 --- a/.husky/hooks/pre-push +++ b/.husky/hooks/pre-push @@ -1,6 +1,6 @@ #!/bin/bash -if git status --short | grep -v "??"; then +if git status --short | grep -qv "??"; then git stash function unstash() { git reset --hard From 7e7a62d8ad478ba0fff7e85f384a8257a95a8070 Mon Sep 17 00:00:00 2001 From: Richard Kovacs Date: Wed, 7 Sep 2022 09:00:23 +0200 Subject: [PATCH 4/4] Replace deprecated ioutils --- pkg/utils/file.go | 4 ++-- pkg/utils/http.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/utils/file.go b/pkg/utils/file.go index 723e7ebc..ee3a552c 100644 --- a/pkg/utils/file.go +++ b/pkg/utils/file.go @@ -17,13 +17,13 @@ package utils import ( "fmt" - "io/ioutil" + "os" "strings" ) // ReadFile reads a file from the given path. func ReadFile(path string) (string, error) { - content, err := ioutil.ReadFile(path) + content, err := os.ReadFile(path) if err != nil { return "", fmt.Errorf("unable to read secret: %s, error: %s", path, err) } diff --git a/pkg/utils/http.go b/pkg/utils/http.go index 3aa57aa5..eff42157 100644 --- a/pkg/utils/http.go +++ b/pkg/utils/http.go @@ -20,7 +20,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "strings" "time" @@ -77,7 +76,7 @@ func doHttpRequest(method, url string, body io.Reader, headers map[string]string } defer resp.Body.Close() - content, err := ioutil.ReadAll(resp.Body) + content, err := io.ReadAll(resp.Body) if err != nil { logger.Error(err, "Unable to read content") return nil, resp.StatusCode, errors.Wrap(err, "unable to read HTTP response")