Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 642f8bc

Browse files
committed
Add a seed for better randomness
Without the seed the rand.Intn will always start from the same place and return the same application name Signed-off-by: Djordje Lukic <[email protected]>
1 parent 80c0233 commit 642f8bc

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

cmd/cnab-run/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package main
33
import (
44
"errors"
55
"fmt"
6+
"math/rand"
67
"os"
8+
"time"
79

810
"github.com/docker/app/internal"
911
)
@@ -38,6 +40,7 @@ func getCnabAction() (cnabAction, string, error) {
3840
}
3941

4042
func main() {
43+
rand.Seed(time.Now().UnixNano())
4144
action, actionName, err := getCnabAction()
4245
if err != nil {
4346
fmt.Fprintf(os.Stderr, "Error while parsing CNAB operation: %s", err)

cmd/docker-app/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package main
22

33
import (
4+
"math/rand"
5+
"time"
6+
47
"github.com/docker/app/internal"
58
app "github.com/docker/app/internal/commands"
69
"github.com/docker/cli/cli-plugins/manager"
@@ -10,6 +13,7 @@ import (
1013
)
1114

1215
func main() {
16+
rand.Seed(time.Now().UnixNano())
1317
plugin.Run(func(dockerCli command.Cli) *cobra.Command {
1418
cmd := app.NewRootCmd("app", dockerCli)
1519
originalPreRun := cmd.PersistentPreRunE

0 commit comments

Comments
 (0)