Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): replace nu7hatch/gouuid with google/uuid #3078

Merged
merged 33 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
342703e
replace nu7hatch/gouuid with google/uuid
geigerj0 Jul 17, 2024
b05eab8
tidy up go.mod fie
geigerj0 Jul 17, 2024
0dd7967
debug
geigerj0 Jul 17, 2024
8536895
debug
geigerj0 Jul 17, 2024
2054d6c
foo
geigerj0 Jul 17, 2024
9643d28
foo
geigerj0 Jul 17, 2024
96ab97b
foo
geigerj0 Jul 17, 2024
229dd80
foo
geigerj0 Jul 17, 2024
a380a69
use stuff printed in this run https://github.com/cloudfoundry/app-aut…
geigerj0 Jul 17, 2024
aecb059
use stuff printed in this run https://github.com/cloudfoundry/app-aut…
geigerj0 Jul 17, 2024
9d7bdf8
Merge branch 'main' into appautosacler-753/uuid
geigerj0 Jul 17, 2024
0e86c24
remove error handling leftover
geigerj0 Jul 17, 2024
c514187
try output from https://github.com/cloudfoundry/app-autoscaler-releas…
geigerj0 Jul 17, 2024
1d29fc7
try local make package-spec run
geigerj0 Jul 17, 2024
d5f6385
revert to state from main
geigerj0 Jul 17, 2024
c45393c
debug
geigerj0 Jul 18, 2024
b5d3601
debug
geigerj0 Jul 18, 2024
946e4f3
debug
geigerj0 Jul 18, 2024
3fa5c41
debug
geigerj0 Jul 18, 2024
b824139
foo
geigerj0 Jul 19, 2024
39d42a7
debug
geigerj0 Jul 19, 2024
4fe3377
appautosacler-753/uuid:
bonzofenix Jul 19, 2024
7fe72ab
fishing
geigerj0 Jul 19, 2024
351e0de
👹
geigerj0 Jul 19, 2024
01dc78a
👹
geigerj0 Jul 19, 2024
ea3c5ed
allow to trigger the dependency update post-processing workflow manually
geigerj0 Jul 19, 2024
b072dd9
only approve PRs automatically if the trigger came from renovate
geigerj0 Jul 19, 2024
d2669e2
fix branch name retrieval so that it also works for github workflows
geigerj0 Jul 19, 2024
da634f9
remove approval because it's no longer required
geigerj0 Jul 23, 2024
f4c640f
remove condition because the action is just triggered whenever a go.m…
geigerj0 Jul 23, 2024
969d36a
revert branch name retrieval to keep diff short.
geigerj0 Jul 23, 2024
6106c67
test post-processing by deleting some lines from a spec
geigerj0 Jul 23, 2024
af50a31
🤖🦾🛠️ go mod tidy & make package-specs
geigerj0 Jul 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/bosh-release-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ jobs:
make package-specs
- name: Check if there is any change
run: |
[ $(git status --porcelain | wc -l) -eq 0 ] || \
{ \
git status;\
echo "::error::Specs are out of date, run \"make package-specs\" to update";\
exit 1;\
}
if [ "$(git status --porcelain | wc -l)" -ne 0 ]; then
git status
git diff
echo "::error::Specs are out of date, run \"make package-specs\" to update"
exit 1
fi
bosh-release:
needs: generate-gosub
name: Create Bosh Release
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/dependency-updates-post-processing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
workflow_dispatch: {}
jobs:
dependency-updates-post-processing:
if: github.actor == 'renovate[bot]'
if: github.actor == 'renovate[bot]' || github.event_name == 'workflow_dispatch'
name: "Dependency Updates Post-Processing"
runs-on: ubuntu-latest
container:
Expand Down Expand Up @@ -65,18 +65,16 @@ jobs:
declare -r commit_author_name="${{steps.configure_git.outputs.commit_author_name}}"
declare -r commit_message="${{steps.configure_git.outputs.commit_subject}}"

if [[ ! "${commit_author_name}" == 'renovate[bot]' ]] \
|| [[ "${commit_message}" == "${tidy_message}" ]]
then
echo 'This commit was not by a known bot or already an automatic `go mod tidy`! Exiting …'
if [[ "${commit_message}" == "${tidy_message}" ]]; then
echo 'This commit is already an automatic `go-mod-tidy and make package-specs`! Exiting ...'
exit 0
fi

# Generated files are needed for `go mod tidy` which is a dependency of the
# target `package-specs`. However the generation of them itself already
# requires go-modules to be tidied up. So we need to generate the files
# before changing `go.mod` and `go.sum`.
declare -r current_branch="${{ github.head_ref }}"
declare -r current_branch="${GITHUB_REF#refs/heads/}"
git checkout 'HEAD~1'
make generate-fakes
make generate-openapi-generated-clients-and-servers
Expand All @@ -94,7 +92,9 @@ jobs:
git commit --message="${tidy_message}"
git pull --rebase=true
git push
gh pr review --approve
if [ "${{ github.actor }}" == "renovate[bot]" ]; then
gh pr review --approve
fi
else
echo 'No files changed!'
fi
Expand Down
1 change: 0 additions & 1 deletion packages/eventgenerator/spec
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ files:
- autoscaler/vendor/github.com/jmoiron/sqlx/* # gosub
- autoscaler/vendor/github.com/jmoiron/sqlx/reflectx/* # gosub
- autoscaler/vendor/github.com/munnerz/goautoneg/* # gosub
- autoscaler/vendor/github.com/nu7hatch/gouuid/* # gosub
- autoscaler/vendor/github.com/openzipkin/zipkin-go/idgenerator/* # gosub
- autoscaler/vendor/github.com/openzipkin/zipkin-go/model/* # gosub
- autoscaler/vendor/github.com/prometheus/client_golang/prometheus/* # gosub
Expand Down
1 change: 0 additions & 1 deletion packages/golangapiserver/spec
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ files:
- autoscaler/vendor/github.com/mattn/go-colorable/* # gosub
- autoscaler/vendor/github.com/mattn/go-isatty/* # gosub
- autoscaler/vendor/github.com/munnerz/goautoneg/* # gosub
- autoscaler/vendor/github.com/nu7hatch/gouuid/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/conv/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/http/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/internal/httpcookie/* # gosub
Expand Down
2 changes: 1 addition & 1 deletion packages/metricsforwarder/spec
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ files:
- autoscaler/vendor/github.com/go-logr/logr/funcr/* # gosub
- autoscaler/vendor/github.com/go-logr/stdr/* # gosub
- autoscaler/vendor/github.com/go-sql-driver/mysql/* # gosub
- autoscaler/vendor/github.com/google/uuid/* # gosub
- autoscaler/vendor/github.com/gorilla/mux/* # gosub
- autoscaler/vendor/github.com/hashicorp/go-cleanhttp/* # gosub
- autoscaler/vendor/github.com/hashicorp/go-retryablehttp/* # gosub
Expand Down Expand Up @@ -81,7 +82,6 @@ files:
- autoscaler/vendor/github.com/klauspost/compress/zstd/* # gosub
- autoscaler/vendor/github.com/klauspost/compress/zstd/internal/xxhash/* # gosub
- autoscaler/vendor/github.com/munnerz/goautoneg/* # gosub
- autoscaler/vendor/github.com/nu7hatch/gouuid/* # gosub
- autoscaler/vendor/github.com/openzipkin/zipkin-go/idgenerator/* # gosub
- autoscaler/vendor/github.com/openzipkin/zipkin-go/model/* # gosub
- autoscaler/vendor/github.com/patrickmn/go-cache/* # gosub
Expand Down
2 changes: 1 addition & 1 deletion packages/operator/spec
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ files:
- autoscaler/vendor/github.com/go-logr/logr/funcr/* # gosub
- autoscaler/vendor/github.com/go-logr/stdr/* # gosub
- autoscaler/vendor/github.com/go-sql-driver/mysql/* # gosub
- autoscaler/vendor/github.com/google/uuid/* # gosub
- autoscaler/vendor/github.com/gorilla/mux/* # gosub
- autoscaler/vendor/github.com/hashicorp/go-cleanhttp/* # gosub
- autoscaler/vendor/github.com/hashicorp/go-retryablehttp/* # gosub
Expand All @@ -55,7 +56,6 @@ files:
- autoscaler/vendor/github.com/jmoiron/sqlx/* # gosub
- autoscaler/vendor/github.com/jmoiron/sqlx/reflectx/* # gosub
- autoscaler/vendor/github.com/munnerz/goautoneg/* # gosub
- autoscaler/vendor/github.com/nu7hatch/gouuid/* # gosub
- autoscaler/vendor/github.com/openzipkin/zipkin-go/idgenerator/* # gosub
- autoscaler/vendor/github.com/openzipkin/zipkin-go/model/* # gosub
- autoscaler/vendor/github.com/prometheus/client_golang/prometheus/* # gosub
Expand Down
1 change: 0 additions & 1 deletion packages/scalingengine/spec
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ files:
- autoscaler/vendor/github.com/mattn/go-colorable/* # gosub
- autoscaler/vendor/github.com/mattn/go-isatty/* # gosub
- autoscaler/vendor/github.com/munnerz/goautoneg/* # gosub
- autoscaler/vendor/github.com/nu7hatch/gouuid/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/conv/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/http/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/internal/httpcookie/* # gosub
Expand Down
25 changes: 6 additions & 19 deletions src/autoscaler/api/broker/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/db"
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/models"
"code.cloudfoundry.org/lager/v3"
uuid "github.com/nu7hatch/gouuid"
"github.com/google/uuid"
"github.com/pivotal-cf/brokerapi/v11/domain"
"github.com/pivotal-cf/brokerapi/v11/domain/apiresponses"
"golang.org/x/exp/slices"
Expand Down Expand Up @@ -125,12 +125,7 @@ func (b *Broker) Provision(ctx context.Context, instanceID string, details domai
}

if policy != nil {
policyGuid, err := uuid.NewV4()
if err != nil {
b.logger.Error("get-default-policy-create-guid", err, lager.Data{"instanceID": instanceID})
return result, apiresponses.NewFailureResponse(errors.New("error generating policy guid"), http.StatusInternalServerError, "get-default-policy-create-guid")
}
policyGuidStr = policyGuid.String()
policyGuidStr = uuid.NewString()
policyBytes, err := json.Marshal(policy)
if err != nil {
b.logger.Error("marshal policy failed", err, lager.Data{"instanceID": instanceID})
Expand Down Expand Up @@ -460,13 +455,9 @@ func (b *Broker) determineDefaultPolicy(parameters *models.InstanceParameters, s
if err != nil {
return nil, "", false, err
}
policyGuid, err := uuid.NewV4()
if err != nil {
b.logger.Error("determine-default-policy-create-guid", err, lager.Data{"instanceID": serviceInstance.ServiceInstanceId})
return newPolicy, "", false, apiresponses.NewFailureResponse(errors.New("failed to create policy guid"), http.StatusInternalServerError, "determine-default-policy-create-guidz")
}
policyGuid := uuid.NewString()
defaultPolicy = newPolicy
defaultPolicyGuid = policyGuid.String()
defaultPolicyGuid = policyGuid
defaultPolicyIsNew = true
}

Expand Down Expand Up @@ -516,12 +507,8 @@ func (b *Broker) Bind(ctx context.Context, instanceID string, bindingID string,
if err != nil {
return result, err
}
policyGuid, err := uuid.NewV4()
if err != nil {
b.logger.Error("get-default-policy-create-guid", err, lager.Data{"instanceID": instanceID})
return result, apiresponses.NewFailureResponse(errors.New("error generating policy guid"), http.StatusInternalServerError, "get-default-policy-create-guid")
}
policyGuidStr := policyGuid.String()

policyGuidStr := uuid.NewString()

// fallback to default policy if no policy was provided
if policy == nil {
Expand Down
14 changes: 4 additions & 10 deletions src/autoscaler/api/publicapiserver/public_api_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/helpers"
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/models"
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/routes"
"github.com/google/uuid"

"code.cloudfoundry.org/app-autoscaler/src/autoscaler/helpers/handlers"
"code.cloudfoundry.org/lager/v3"
uuid "github.com/nu7hatch/gouuid"
)

type PublicApiHandler struct {
Expand Down Expand Up @@ -135,21 +135,15 @@ func (h *PublicApiHandler) AttachScalingPolicy(w http.ResponseWriter, r *http.Re
return
}

policyGuid, err := uuid.NewV4()
if err != nil {
logger.Error("Failed to generate policy guid", err)
writeErrorResponse(w, http.StatusInternalServerError, "Error generating policy guid")
return
}

err = h.policydb.SaveAppPolicy(r.Context(), appId, policy, policyGuid.String())
policyGuid := uuid.NewString()
err = h.policydb.SaveAppPolicy(r.Context(), appId, policy, policyGuid)
if err != nil {
logger.Error("Failed to save policy", err)
writeErrorResponse(w, http.StatusInternalServerError, "Error saving policy")
return
}
h.logger.Info("creating/updating schedules", lager.Data{"policy": policy})
err = h.schedulerUtil.CreateOrUpdateSchedule(r.Context(), appId, policy, policyGuid.String())
err = h.schedulerUtil.CreateOrUpdateSchedule(r.Context(), appId, policy, policyGuid)
if err != nil {
logger.Error("Failed to create/update schedule", err)
writeErrorResponse(w, http.StatusInternalServerError, err.Error())
Expand Down
14 changes: 3 additions & 11 deletions src/autoscaler/cred_helper/custom_metrics_cred_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"time"

"code.cloudfoundry.org/app-autoscaler/src/autoscaler/db/sqldb"
"github.com/google/uuid"

"code.cloudfoundry.org/app-autoscaler/src/autoscaler/db"
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/models"
"code.cloudfoundry.org/lager/v3"
uuid "github.com/nu7hatch/gouuid"
"github.com/patrickmn/go-cache"
"golang.org/x/crypto/bcrypt"
)
Expand Down Expand Up @@ -120,16 +120,8 @@ var _ Credentials = &customMetricsCredentials{}
func _createCredential(ctx context.Context, appId string, userProvidedCredential *models.Credential, policyDB db.PolicyDB) (*models.Credential, error) {
var credUsername, credPassword string
if userProvidedCredential == nil {
credUsernameUUID, err := uuid.NewV4()
if err != nil {
return nil, err
}
credPasswordUUID, err := uuid.NewV4()
if err != nil {
return nil, err
}
credUsername = credUsernameUUID.String()
credPassword = credPasswordUUID.String()
credUsername = uuid.NewString()
credPassword = uuid.NewString()
} else {
credUsername = userProvidedCredential.Username
credPassword = userProvidedCredential.Password
Expand Down
3 changes: 1 addition & 2 deletions src/autoscaler/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ require (
github.com/go-faster/jx v1.1.0
github.com/go-logr/logr v1.4.2
github.com/go-sql-driver/mysql v1.8.1
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.1
github.com/hashicorp/go-retryablehttp v0.7.7
github.com/jackc/pgx/v5 v5.6.0
github.com/jmoiron/sqlx v1.4.0
github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d
github.com/ogen-go/ogen v1.2.2
github.com/onsi/ginkgo/v2 v2.19.0
github.com/onsi/gomega v1.33.1
Expand Down Expand Up @@ -71,7 +71,6 @@ require (
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20240711041743-f6c9dda6c6da // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
Expand Down
1 change: 0 additions & 1 deletion src/autoscaler/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,6 @@ github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcs
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
Expand Down
14 changes: 0 additions & 14 deletions src/autoscaler/helpers/uuid.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"code.cloudfoundry.org/app-autoscaler/src/autoscaler/models"
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/testhelpers"
"github.com/google/uuid"

. "github.com/onsi/ginkgo/v2"
)
Expand Down Expand Up @@ -36,7 +37,7 @@ var _ = Describe("Integration_GolangApi_ScalingEngine", func() {
"https://127.0.0.1:8888",
tmpDir)
startGolangApiServer()
appId = getUUID()
appId = uuid.NewString()
pathVariables = []string{appId}

})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"

"code.cloudfoundry.org/app-autoscaler/src/autoscaler/testhelpers"
"github.com/google/uuid"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
Expand Down Expand Up @@ -40,9 +41,9 @@ var _ = Describe("Integration_GolangApi_Scheduler", func() {
bindingId = getRandomIdRef("bindingId")
binding2Id = getRandomIdRef("binding2Id")
binding3Id = getRandomIdRef("binding3Id")
appId = getUUID()
app2Id = getUUID()
app3Id = getUUID()
appId = uuid.NewString()
app2Id = uuid.NewString()
app3Id = uuid.NewString()
brokerAuth = base64.StdEncoding.EncodeToString([]byte("broker_username:broker_password"))
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"code.cloudfoundry.org/app-autoscaler/src/autoscaler/testhelpers"
"github.com/google/uuid"

"code.cloudfoundry.org/app-autoscaler/src/autoscaler/models"

Expand All @@ -29,8 +30,8 @@ var _ = Describe("Integration_Operator_Others", func() {
BeforeEach(func() {
httpClient = testhelpers.NewApiClient()

testAppId = getUUID()
testGuid = getUUID()
testAppId = uuid.NewString()
testGuid = uuid.NewString()
serviceInstanceId = getRandomIdRef("serviceInstId")
orgId = getRandomIdRef("orgId")
spaceId = getRandomIdRef("spaceId")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"code.cloudfoundry.org/app-autoscaler/src/autoscaler/testhelpers"
"github.com/google/uuid"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand All @@ -22,8 +23,8 @@ var _ = Describe("Integration_Scheduler_ScalingEngine", func() {
BeforeEach(func() {
httpClient = testhelpers.NewSchedulerClient()

testAppId = getUUID()
testGuid = getUUID()
testAppId = uuid.NewString()
testGuid = uuid.NewString()
startFakeCCNOAAUAA(initInstanceCount)

scalingEngineConfPath = components.PrepareScalingEngineConfig(dbUrl, components.Ports[ScalingEngine], fakeCCNOAAUAA.URL(), defaultHttpClientTimeout, tmpDir)
Expand Down
10 changes: 2 additions & 8 deletions src/autoscaler/integration/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import (
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/db"
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/models"
. "code.cloudfoundry.org/app-autoscaler/src/autoscaler/testhelpers"
"github.com/google/uuid"

"code.cloudfoundry.org/lager/v3"
_ "github.com/go-sql-driver/mysql"
_ "github.com/jackc/pgx/v5/stdlib"
"github.com/jmoiron/sqlx"
uuid "github.com/nu7hatch/gouuid"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/tedsuo/ifrit"
Expand Down Expand Up @@ -242,14 +242,8 @@ func getRandomIdRef(ref string) string {
return id
}

func getUUID() string {
v4, _ := uuid.NewV4()
return v4.String()
}

func randomBits() string {
randomBits := getUUID()
return strings.ReplaceAll(randomBits, "-", "")
return strings.ReplaceAll(uuid.NewString(), "-", "")
}

func testFileFragment(filename string) string {
Expand Down
Loading
Loading