Skip to content

Commit

Permalink
Simplify defer closer funcs (#2489)
Browse files Browse the repository at this point in the history
  • Loading branch information
sverdlov93 authored Mar 19, 2024
1 parent c88f2ee commit bf797d1
Show file tree
Hide file tree
Showing 23 changed files with 162 additions and 112 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/accessTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ jobs:
os: [ ubuntu, windows, macos ]
runs-on: ${{ matrix.os }}-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Go Cache
uses: actions/cache@v4
with:
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ jobs:
os: [ ubuntu, windows, macos ]
runs-on: ${{ matrix.os }}-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Checkout code
uses: actions/checkout@v4
with:
Expand All @@ -41,10 +42,11 @@ jobs:
steps:
- name: Checkout Source
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Static Code Analysis
uses: golangci/golangci-lint-action@v3
with:
Expand All @@ -57,10 +59,11 @@ jobs:
steps:
- name: Checkout Source
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/artifactoryTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ jobs:
os: [ ubuntu, windows, macos ]
runs-on: ${{ matrix.os }}-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Checkout code
uses: actions/checkout@v4
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/distributionTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ jobs:
os: [ ubuntu, windows, macos ]
runs-on: ${{ matrix.os }}-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Go Cache
uses: actions/cache@v4
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/dockerTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ jobs:
name: ubuntu-latest
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Checkout code
uses: actions/checkout@v4
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/goTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ jobs:
os: [ ubuntu, windows, macos ]
runs-on: ${{ matrix.os }}-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Checkout code
uses: actions/checkout@v4
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/gradleTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ jobs:
env:
GRADLE_OPTS: -Dorg.gradle.daemon=false
steps:
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/lifecycleTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ jobs:
os: [ ubuntu, windows, macos ]
runs-on: ${{ matrix.os }}-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Checkout code
uses: actions/checkout@v4
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/mavenTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ jobs:
os: [ ubuntu, windows, macos ]
runs-on: ${{ matrix.os }}-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Checkout code
uses: actions/checkout@v4
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/npmTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ jobs:
os: [ ubuntu, windows, macos ]
runs-on: ${{ matrix.os }}-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Install npm
uses: actions/setup-node@v3
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/nugetTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ jobs:
os: [ ubuntu, windows, macos ]
runs-on: ${{ matrix.os }}-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Install NuGet
uses: nuget/setup-nuget@v1
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/pluginsTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ jobs:
os: [ ubuntu, windows, macos ]
runs-on: ${{ matrix.os }}-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Checkout code
uses: actions/checkout@v4
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/podmanTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ jobs:
name: ubuntu-latest
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Checkout code
uses: actions/checkout@v4
with:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/pythonTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ jobs:
os: [ ubuntu, windows, macos ]
runs-on: ${{ matrix.os }}-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
# Due to a bug in Python 3.12.0 we temporary use version 3.11.5
cache: false
# Due to a bug in Python 3.12.0 we temporarily use version 3.11.5
- name: Setup Python3
uses: actions/setup-python@v5
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/scriptTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ jobs:
osSuffix: ".exe"
runs-on: ${{ matrix.suite.os }}
steps:
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false

- name: Checkout code
uses: actions/checkout@v4
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/transferTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Go Cache
uses: actions/cache@v4
with:
Expand All @@ -56,10 +57,11 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install Go
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
- name: Go Cache
uses: actions/cache@v4
with:
Expand Down
11 changes: 3 additions & 8 deletions artifactory/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package artifactory
import (
"errors"
"fmt"
ioutils "github.com/jfrog/gofrog/io"
"github.com/jfrog/jfrog-cli/utils/accesstoken"
"os"
"strconv"
"strings"

"github.com/jfrog/jfrog-cli/utils/accesstoken"

"github.com/jfrog/gofrog/version"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/transferinstall"
"github.com/jfrog/jfrog-cli/docs/artifactory/transferplugininstall"
Expand Down Expand Up @@ -1527,12 +1527,7 @@ func searchCmd(c *cli.Context) (err error) {
return
}
reader := searchCmd.Result().Reader()
defer func() {
e := reader.Close()
if err == nil {
err = e
}
}()
defer ioutils.Close(reader, &err)
length, err := reader.Length()
if err != nil {
return err
Expand Down
35 changes: 21 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ require (
github.com/jfrog/jfrog-cli-security v1.0.4
github.com/jfrog/jfrog-client-go v1.38.0
github.com/jszwec/csvutil v1.10.0
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
github.com/testcontainers/testcontainers-go v0.23.0
github.com/urfave/cli v1.22.14
github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a
golang.org/x/term v0.17.0
golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81
golang.org/x/term v0.18.0
gopkg.in/yaml.v2 v2.4.0
)

Expand All @@ -38,22 +38,25 @@ require (
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/containerd/containerd v1.7.11 // indirect
github.com/containerd/containerd v1.7.12 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v24.0.7+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/docker v25.0.3+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/forPelevin/gomoji v1.1.8 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand All @@ -79,12 +82,12 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/user v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/nwaples/rardecode v1.1.3 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
github.com/opencontainers/runc v1.1.12 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/owenrumney/go-sarif/v2 v2.3.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
Expand Down Expand Up @@ -113,15 +116,19 @@ require (
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.18.0 // indirect
golang.org/x/tools v0.19.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
Expand Down
Loading

0 comments on commit bf797d1

Please sign in to comment.