Skip to content

Commit 35ac8ee

Browse files
committed
Refactor to use new go slices library
Authored-by: Wayne Adams <[email protected]>
1 parent bfeb3fb commit 35ac8ee

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

download_clients/pivnet_client.go

+3-10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"strconv"
1010
"strings"
1111

12+
"golang.org/x/exp/slices"
13+
1214
"github.com/pivotal-cf/go-pivnet/v6/logshim"
1315
"github.com/pivotal-cf/pivnet-cli/v2/filter"
1416

@@ -185,7 +187,7 @@ func (p *pivnetClient) getLatestStemcell(dependencies []pivnet.ReleaseDependency
185187

186188
for _, dependency := range dependencies {
187189
if strings.Contains(dependency.Release.Product.Slug, "stemcells") {
188-
if !contains(stemcellSlugs, dependency.Release.Product.Slug) {
190+
if !slices.Contains(stemcellSlugs, dependency.Release.Product.Slug) {
189191
stemcellSlugs = append(stemcellSlugs, dependency.Release.Product.Slug)
190192
}
191193
versions = append(versions, dependency.Release.Version)
@@ -204,15 +206,6 @@ func (p *pivnetClient) getLatestStemcell(dependencies []pivnet.ReleaseDependency
204206
return stemcellSlugs[0], stemcellVersion, nil
205207
}
206208

207-
func contains(slice []string, str string) bool {
208-
for _, s := range slice {
209-
if s == str {
210-
return true
211-
}
212-
}
213-
return false
214-
}
215-
216209
const (
217210
errorForVersion = "versioning of stemcell dependency in unexpected format: \"major.minor\" or \"major\". the following version could not be parsed: %s"
218211
userAgent = "om-download-product"

go.mod

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ require (
2929
github.com/pivotal-cf/pivnet-cli/v2 v2.0.2
3030
github.com/pivotal-cf/replicator v0.0.0-20181127185712-7c58987ce14b
3131
github.com/pivotal-cf/winfs-injector v0.0.0-20200827170301-91411420d92f
32-
github.com/vmware/govmomi v0.46.0
33-
golang.org/x/oauth2 v0.24.0
34-
google.golang.org/api v0.205.0
32+
github.com/vmware/govmomi v0.44.1
33+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
34+
golang.org/x/oauth2 v0.23.0
35+
google.golang.org/api v0.200.0
3536
gopkg.in/go-playground/validator.v9 v9.31.0
3637
gopkg.in/yaml.v2 v2.4.0
3738
gopkg.in/yaml.v3 v3.0.1

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@ golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq
466466
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
467467
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
468468
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
469+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
470+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
469471
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
470472
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
471473
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=

0 commit comments

Comments
 (0)