Skip to content

Commit f4dc68a

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

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
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

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ require (
3030
github.com/pivotal-cf/replicator v0.0.0-20181127185712-7c58987ce14b
3131
github.com/pivotal-cf/winfs-injector v0.0.0-20200827170301-91411420d92f
3232
github.com/vmware/govmomi v0.44.1
33+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
3334
golang.org/x/oauth2 v0.23.0
3435
google.golang.org/api v0.200.0
3536
gopkg.in/go-playground/validator.v9 v9.31.0

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq
465465
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
466466
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
467467
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
468+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
469+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
468470
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
469471
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
470472
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=

0 commit comments

Comments
 (0)