From 7849428c14e1df97c148cfd0cec9b676b979a782 Mon Sep 17 00:00:00 2001 From: thedebugger Date: Wed, 17 Jul 2024 03:51:17 +0000 Subject: [PATCH 1/2] Add random bits in branch name to run step few times --- pkg/branch/branch.go | 3 ++- release/trigger-branch | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/branch/branch.go b/pkg/branch/branch.go index fe83a04c3..204ca194f 100644 --- a/pkg/branch/branch.go +++ b/pkg/branch/branch.go @@ -19,6 +19,7 @@ import ( "os" "path" "strconv" + "math/rand" "sigs.k8s.io/yaml" @@ -91,7 +92,7 @@ func Branch(manifest model.Manifest, step int, dryrun bool, token string) error if step > 2 { prName = "[release-" + release + "] " + prName } - if err := util.CreatePR(manifest, repo, "automatedBranchStep"+strconv.Itoa(step), prName, "", dryrun, token, "", "", []string{}); err != nil { + if err := util.CreatePR(manifest, repo, "automatedBranchStep"+strconv.Itoa(step)+"-"+strconv.Itoa(rand.Intn(100)), prName, "", dryrun, token, "", "", []string{}); err != nil { return fmt.Errorf("failed PR creation: %v", err) } } diff --git a/release/trigger-branch b/release/trigger-branch index 2195c76ae..bbca8469e 100644 --- a/release/trigger-branch +++ b/release/trigger-branch @@ -1,2 +1,2 @@ -VERSION=1.19 -STEP=1 \ No newline at end of file +VERSION=1.23 +STEP=1 From c9e2bace1afab26998f57ae3c0e48d9efa2096dd Mon Sep 17 00:00:00 2001 From: thedebugger Date: Tue, 23 Jul 2024 04:37:56 +0000 Subject: [PATCH 2/2] Fix linting errors --- pkg/branch/branch.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/branch/branch.go b/pkg/branch/branch.go index 204ca194f..559b428d5 100644 --- a/pkg/branch/branch.go +++ b/pkg/branch/branch.go @@ -16,10 +16,10 @@ package branch import ( "fmt" + "math/rand" "os" "path" "strconv" - "math/rand" "sigs.k8s.io/yaml" @@ -92,7 +92,10 @@ func Branch(manifest model.Manifest, step int, dryrun bool, token string) error if step > 2 { prName = "[release-" + release + "] " + prName } - if err := util.CreatePR(manifest, repo, "automatedBranchStep"+strconv.Itoa(step)+"-"+strconv.Itoa(rand.Intn(100)), prName, "", dryrun, token, "", "", []string{}); err != nil { + + // Disable linter G404: Use of weak random number generator + err := util.CreatePR(manifest, repo, "automatedBranchStep"+strconv.Itoa(step)+"-"+strconv.Itoa(rand.Intn(100)), prName, "", dryrun, token, "", "", []string{}) //nolint:all + if err != nil { return fmt.Errorf("failed PR creation: %v", err) } }