From b2c43042bc33929d1d37ed08dafa70422dc6d335 Mon Sep 17 00:00:00 2001 From: Karl Cardenas Date: Sun, 17 Nov 2024 08:48:32 -0700 Subject: [PATCH] fix: upgrade dependencies --- .github/workflows/build.yml | 49 ++++++++++++++------------- .github/workflows/test.yml | 17 +++++----- Makefile | 7 +++- cmd/categories.go | 2 +- cmd/events.go | 2 +- cmd/update.go | 3 +- go.mod | 14 ++++---- go.sum | 13 +++++++ {library => internal}/client.go | 18 ++++------ {library => internal}/query.go | 13 ++----- {library => internal}/query_test.go | 0 {library => internal}/structs.go | 0 {library => internal}/structs_test.go | 0 13 files changed, 71 insertions(+), 67 deletions(-) rename {library => internal}/client.go (79%) rename {library => internal}/query.go (87%) rename {library => internal}/query_test.go (100%) rename {library => internal}/structs.go (100%) rename {library => internal}/structs_test.go (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index afe5dc5..5a53ee2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,7 @@ on: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GO_VERSION: '1.23' jobs: @@ -17,12 +18,12 @@ jobs: steps: - name: "Check out code into the Go module directory" - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Node.js environment - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: '18' + node-version: '20' cache: 'npm' - name: "Get dependencies" @@ -44,19 +45,19 @@ jobs: GOOS: darwin steps: - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: ${{ env.GO_VERSION }} check-latest: true id: go - name: Check out code into the Go module directory - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: create run: go build -ldflags="-X 'github.com/karl-cardenas-coding/disaster-cli/cmd.VersionString=${{needs.next-version.outputs.version}}'" -o=disaster -v && zip disaster-v${{needs.next-version.outputs.version}}-${{env.GOOS}}-${{env.GOARCH}}.zip disaster - - uses: actions/upload-artifact@v1 + - uses: actions/upload-artifact@v4 with: name: disaster-v${{needs.next-version.outputs.version}}-${{env.GOOS}}-${{env.GOARCH}}.zip path: disaster-v${{needs.next-version.outputs.version}}-${{env.GOOS}}-${{env.GOARCH}}.zip @@ -71,18 +72,18 @@ jobs: GOOS: darwin steps: - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: ${{ env.GO_VERSION }} check-latest: true id: go - name: Check out code into the Go module directory - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: create run: go build -ldflags="-X 'github.com/karl-cardenas-coding/disaster-cli/cmd.VersionString=${{needs.next-version.outputs.version}}'" -o=disaster -v && zip disaster-v${{needs.next-version.outputs.version}}-${{env.GOOS}}-${{env.GOARCH}}.zip disaster - - uses: actions/upload-artifact@v1 + - uses: actions/upload-artifact@v4 with: name: disaster-v${{needs.next-version.outputs.version}}-${{env.GOOS}}-${{env.GOARCH}}.zip path: disaster-v${{needs.next-version.outputs.version}}-${{env.GOOS}}-${{env.GOARCH}}.zip @@ -97,19 +98,19 @@ jobs: GOOS: linux steps: - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: ${{ env.GO_VERSION }} check-latest: true id: go - name: Check out code into the Go module directory - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: create run: go build -ldflags="-X 'github.com/karl-cardenas-coding/disaster-cli/cmd.VersionString=${{needs.next-version.outputs.version}}'" -o=disaster -v && zip disaster-v${{needs.next-version.outputs.version}}-${{env.GOOS}}-${{env.GOARCH}}.zip disaster - - uses: actions/upload-artifact@v1 + - uses: actions/checkout@v4 with: name: disaster-v${{needs.next-version.outputs.version}}-${{env.GOOS}}-${{env.GOARCH}}.zip path: disaster-v${{needs.next-version.outputs.version}}-${{env.GOOS}}-${{env.GOARCH}}.zip @@ -124,19 +125,19 @@ jobs: GOOS: linux steps: - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: ${{ env.GO_VERSION }} check-latest: true id: go - name: Check out code into the Go module directory - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: create run: go build -ldflags="-X 'github.com/karl-cardenas-coding/disaster-cli/cmd.VersionString=v${{needs.next-version.outputs.version}}'" -o=disaster -v && zip disaster-v${{needs.next-version.outputs.version}}-${{env.GOOS}}-${{env.GOARCH}}.zip disaster - - uses: actions/upload-artifact@v1 + - uses: actions/checkout@v4 with: name: disaster-v${{needs.next-version.outputs.version}}-${{env.GOOS}}-${{env.GOARCH}}.zip path: disaster-v${{needs.next-version.outputs.version}}-${{env.GOOS}}-${{env.GOARCH}}.zip @@ -152,19 +153,19 @@ jobs: GOOS: windows steps: - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: ${{ env.GO_VERSION }} check-latest: true id: go - name: Check out code into the Go module directory - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: create run: go build -ldflags="-X 'github.com/karl-cardenas-coding/disaster-cli/cmd.VersionString=${{needs.next-version.outputs.version}}'" -o=disaster.exe -v && zip disaster-v${{needs.next-version.outputs.version}}-${{env.GOOS}}-${{env.GOARCH}}.zip disaster.exe - - uses: actions/upload-artifact@v1 + - uses: actions/checkout@v4 with: name: disaster-v${{needs.next-version.outputs.version}}-${{env.GOOS}}-${{env.GOARCH}}.zip path: disaster-v${{needs.next-version.outputs.version}}-${{env.GOOS}}-${{env.GOARCH}}.zip @@ -175,7 +176,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@v3 + uses: actions/checkout@v4 - uses: actions/download-artifact@v1 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e6bdfee..3320719 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,8 @@ on: branches: [ main ] env: GITHUB_TOKEN: ${{ github.token }} - LINT_VERSION: "1.53.3" + LINT_VERSION: "1.62.0" + GO_VERSION: '1.23' jobs: test: @@ -16,19 +17,19 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: ${{ env.GO_VERSION }} check-latest: true id: go - name: Check out code into the Go module directory - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Go Tests run: | go get && go test ./... - name: Run golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v6 with: args: -v @@ -40,12 +41,12 @@ jobs: steps: - name: Check out code into the Go module directory - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: ${{ env.GO_VERSION }} check-latest: true id: go @@ -83,7 +84,7 @@ jobs: chmod +x disaster ./disaster version - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: test-results path: go.txt diff --git a/Makefile b/Makefile index efd5f06..5e41f9d 100644 --- a/Makefile +++ b/Makefile @@ -5,4 +5,9 @@ license: opensource: @echo "Checking for open source licenses" - ~/go/bin/go-licenses report github.com/karl-cardenas-coding/disaster-cli --template=documentation/open-source.tpl > documentation/open-source.md \ No newline at end of file + ~/go/bin/go-licenses report github.com/karl-cardenas-coding/disaster-cli --template=documentation/open-source.tpl > documentation/open-source.md + + +tests: + @echo "Running tests..." + go test -v ./... \ No newline at end of file diff --git a/cmd/categories.go b/cmd/categories.go index f1c2f11..554b3f5 100644 --- a/cmd/categories.go +++ b/cmd/categories.go @@ -9,7 +9,7 @@ import ( "os" "github.com/jedib0t/go-pretty/v6/table" - "github.com/karl-cardenas-coding/disaster-cli/library" + library "github.com/karl-cardenas-coding/disaster-cli/internal" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) diff --git a/cmd/events.go b/cmd/events.go index 1b7f081..e023f92 100644 --- a/cmd/events.go +++ b/cmd/events.go @@ -9,7 +9,7 @@ import ( "os" "github.com/jedib0t/go-pretty/v6/table" - "github.com/karl-cardenas-coding/disaster-cli/library" + library "github.com/karl-cardenas-coding/disaster-cli/internal" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) diff --git a/cmd/update.go b/cmd/update.go index 1a5295d..ffcb611 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -18,7 +18,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/dustin/go-humanize" - "github.com/karl-cardenas-coding/disaster-cli/library" + library "github.com/karl-cardenas-coding/disaster-cli/internal" "github.com/spf13/cobra" ) @@ -230,7 +230,6 @@ func determineOS() string { return output } -// // https://golangcode.com/download-a-file-with-progress/ // WriteCounter counts the number of bytes written to it. It implements to the io.Writer interface // and we can pass this into io.TeeReader() which will report progress on each write cycle. diff --git a/go.mod b/go.mod index c3bd0a8..1738556 100644 --- a/go.mod +++ b/go.mod @@ -1,21 +1,21 @@ module github.com/karl-cardenas-coding/disaster-cli -go 1.20 +go 1.23 require ( github.com/dustin/go-humanize v1.0.1 - github.com/jedib0t/go-pretty/v6 v6.4.6 + github.com/jedib0t/go-pretty/v6 v6.6.1 github.com/sirupsen/logrus v1.9.3 - github.com/spf13/cobra v1.7.0 + github.com/spf13/cobra v1.8.1 ) require ( - github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/mattn/go-runewidth v0.0.14 // indirect - github.com/rivo/uniseg v0.4.4 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect + github.com/rivo/uniseg v0.4.7 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - golang.org/x/sys v0.10.0 // indirect + golang.org/x/sys v0.27.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 0e95180..b9e3d82 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= +github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -9,15 +12,21 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jedib0t/go-pretty/v6 v6.4.6 h1:v6aG9h6Uby3IusSSEjHaZNXpHFhzqMmjXcPq1Rjl9Jw= github.com/jedib0t/go-pretty/v6 v6.4.6/go.mod h1:Ndk3ase2CkQbXLLNf5QDHoYb6J9WtVfmHZu9n8rk2xs= +github.com/jedib0t/go-pretty/v6 v6.6.1 h1:iJ65Xjb680rHcikRj6DSIbzCex2huitmc7bDtxYVWyc= +github.com/jedib0t/go-pretty/v6 v6.6.1/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= @@ -26,6 +35,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -40,6 +51,8 @@ golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/library/client.go b/internal/client.go similarity index 79% rename from library/client.go rename to internal/client.go index 66935d8..9af6d01 100644 --- a/library/client.go +++ b/internal/client.go @@ -6,7 +6,6 @@ package library import ( "encoding/json" "net/http" - "time" log "github.com/sirupsen/logrus" ) @@ -15,17 +14,6 @@ const ( ISSUE_MSG = " Please open up a Github issue to report this error! https://github.com/karl-cardenas-coding/disaster-cli" ) -var disasterClient = &http.Client{ - Timeout: 10 * time.Second, - Transport: &http.Transport{ - MaxIdleConns: 10, - ResponseHeaderTimeout: 10 * time.Second, - IdleConnTimeout: 5 * time.Second, - DisableCompression: true, - ForceAttemptHTTP2: true, - }, -} - func getJson(url string, target interface{}) error { req, err := http.NewRequest("GET", url, nil) if err != nil { @@ -38,6 +26,12 @@ func getJson(url string, target interface{}) error { "Accept": []string{"application/json"}, } + disasterClient := &http.Client{ + Transport: &http.Transport{ + ForceAttemptHTTP2: true, + }, + } + r, err := disasterClient.Do(req) if err != nil { log.WithFields(log.Fields{ diff --git a/library/query.go b/internal/query.go similarity index 87% rename from library/query.go rename to internal/query.go index 8ef91e7..0e9120d 100644 --- a/library/query.go +++ b/internal/query.go @@ -7,7 +7,6 @@ import ( "encoding/json" "fmt" "net/http" - "time" log "github.com/sirupsen/logrus" ) @@ -26,11 +25,7 @@ func QueryEventAPI(apikey string) EventResponse { client := &http.Client{ Transport: &http.Transport{ - MaxIdleConns: 10, - ResponseHeaderTimeout: 10 * time.Second, - IdleConnTimeout: 5 * time.Second, - DisableCompression: true, - ForceAttemptHTTP2: true, + ForceAttemptHTTP2: true, }, } @@ -74,11 +69,7 @@ func QueryCategoriesAPI(apikey string, category string) CategoriesResponse { client := &http.Client{ Transport: &http.Transport{ - MaxIdleConns: 10, - ResponseHeaderTimeout: 10 * time.Second, - IdleConnTimeout: 5 * time.Second, - DisableCompression: true, - ForceAttemptHTTP2: true, + ForceAttemptHTTP2: true, }, } diff --git a/library/query_test.go b/internal/query_test.go similarity index 100% rename from library/query_test.go rename to internal/query_test.go diff --git a/library/structs.go b/internal/structs.go similarity index 100% rename from library/structs.go rename to internal/structs.go diff --git a/library/structs_test.go b/internal/structs_test.go similarity index 100% rename from library/structs_test.go rename to internal/structs_test.go