From a548246c1bd46d68a3f636a103d9aaca584f1b51 Mon Sep 17 00:00:00 2001 From: Gergely Brautigam Date: Fri, 24 Apr 2020 10:02:28 +0200 Subject: [PATCH] Retire satori UUID and use a community driven fork (#241) * Retire satori UUID and use a community driven fork * Addressed the bot's concerns --- go.mod | 4 +- go.sum | 4 +- handlers/pipeline.go | 19 +++++---- handlers/workers.go | 14 ++++--- security/secret_generator.go | 4 +- store/store_test.go | 39 +++++++++++++------ workers/pipeline/build_cpp.go | 10 +++-- workers/pipeline/build_golang.go | 10 +++-- workers/pipeline/build_java.go | 10 +++-- workers/pipeline/build_nodejs.go | 11 ++++-- workers/pipeline/build_nodejs_test.go | 13 ++++--- workers/pipeline/build_python.go | 11 ++++-- workers/pipeline/build_ruby.go | 17 ++++++-- .../pipeline/testacc/build_pipeline_test.go | 20 ++++++---- workers/scheduler/scheduler.go | 8 +++- workers/scheduler/scheduler_test.go | 7 ++-- 16 files changed, 135 insertions(+), 66 deletions(-) diff --git a/go.mod b/go.mod index e83611f3..dbabc77d 100644 --- a/go.mod +++ b/go.mod @@ -20,6 +20,7 @@ require ( github.com/gaia-pipeline/flag v1.7.4-pre github.com/gaia-pipeline/protobuf v0.0.0-20180812091451-7be8a901b55a github.com/gliderlabs/ssh v0.1.1 // indirect + github.com/gofrs/uuid v3.2.0+incompatible github.com/gogo/protobuf v1.2.1 // indirect github.com/golang/protobuf v1.3.1 github.com/google/go-cmp v0.2.0 // indirect @@ -45,7 +46,6 @@ require ( github.com/pelletier/go-buffruneio v0.2.0 // indirect github.com/pkg/errors v0.8.1 github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967 - github.com/satori/go.uuid v1.2.0 github.com/sergi/go-diff v1.0.0 // indirect github.com/sirupsen/logrus v1.4.2 // indirect github.com/src-d/gcfg v1.3.0 // indirect @@ -62,3 +62,5 @@ require ( gopkg.in/yaml.v2 v2.2.2 gotest.tools v2.2.0+incompatible // indirect ) + +go 1.13 diff --git a/go.sum b/go.sum index 9493d915..20e7589d 100644 --- a/go.sum +++ b/go.sum @@ -48,6 +48,8 @@ github.com/gaia-pipeline/protobuf v0.0.0-20180812091451-7be8a901b55a h1:/5XAmdAy github.com/gaia-pipeline/protobuf v0.0.0-20180812091451-7be8a901b55a/go.mod h1:H0w7MofSuW53Nz7kesnBdVkvr437flf5B7D9Lcsb+lQ= github.com/gliderlabs/ssh v0.1.1 h1:j3L6gSLQalDETeEg/Jg0mGY0/y/N6zI2xX1978P0Uqw= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= +github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE= +github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= @@ -124,8 +126,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967 h1:x7xEyJDP7Hv3LVgvWhzioQqbC/KtuUhTigKlH/8ehhE= github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k= -github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= -github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= diff --git a/handlers/pipeline.go b/handlers/pipeline.go index 4b451685..7e09a1e8 100644 --- a/handlers/pipeline.go +++ b/handlers/pipeline.go @@ -5,16 +5,15 @@ import ( "strconv" "time" - "github.com/gaia-pipeline/gaia/helper/stringhelper" - - "github.com/gaia-pipeline/gaia/security" + "github.com/gofrs/uuid" + "github.com/labstack/echo" + "github.com/robfig/cron" "github.com/gaia-pipeline/gaia" + "github.com/gaia-pipeline/gaia/helper/stringhelper" + "github.com/gaia-pipeline/gaia/security" "github.com/gaia-pipeline/gaia/services" "github.com/gaia-pipeline/gaia/workers/pipeline" - "github.com/labstack/echo" - "github.com/robfig/cron" - uuid "github.com/satori/go.uuid" ) // PipelineGitLSRemote checks for available git remote branches. @@ -52,7 +51,11 @@ func CreatePipeline(c echo.Context) error { // Set initial value p.Created = time.Now() p.StatusType = gaia.CreatePipelineRunning - p.ID = uuid.Must(uuid.NewV4(), nil).String() + v4, err := uuid.NewV4() + if err != nil { + return c.String(http.StatusBadRequest, err.Error()) + } + p.ID = uuid.Must(v4, nil).String() // Add pipeline type tag if not already existent if !stringhelper.IsContainedInSlice(p.Pipeline.Tags, p.Pipeline.Type.String(), true) { @@ -60,7 +63,7 @@ func CreatePipeline(c echo.Context) error { } // Save this pipeline to our store - err := storeService.CreatePipelinePut(p) + err = storeService.CreatePipelinePut(p) if err != nil { gaia.Cfg.Logger.Debug("cannot put pipeline into store", "error", err.Error()) return c.String(http.StatusInternalServerError, err.Error()) diff --git a/handlers/workers.go b/handlers/workers.go index e51a9847..708249b1 100644 --- a/handlers/workers.go +++ b/handlers/workers.go @@ -6,13 +6,13 @@ import ( "net/http" "time" - "github.com/gaia-pipeline/gaia/security" - "github.com/Pallinder/go-randomdata" + "github.com/gofrs/uuid" + "github.com/labstack/echo" + "github.com/gaia-pipeline/gaia" + "github.com/gaia-pipeline/gaia/security" "github.com/gaia-pipeline/gaia/services" - "github.com/labstack/echo" - uuid "github.com/satori/go.uuid" ) const ( @@ -57,8 +57,12 @@ func RegisterWorker(c echo.Context) error { worker.Name = randomdata.SillyName() + "_" + randomdata.SillyName() } + v4, err := uuid.NewV4() + if err != nil { + return c.String(http.StatusInternalServerError, "error generating uuid") + } w := gaia.Worker{ - UniqueID: uuid.Must(uuid.NewV4(), nil).String(), + UniqueID: uuid.Must(v4, nil).String(), Name: worker.Name, Tags: worker.Tags, RegisterDate: time.Now(), diff --git a/security/secret_generator.go b/security/secret_generator.go index 259102d9..7a912489 100644 --- a/security/secret_generator.go +++ b/security/secret_generator.go @@ -3,13 +3,13 @@ package security import ( "crypto/rand" - uuid "github.com/satori/go.uuid" + "github.com/gofrs/uuid" ) // GenerateRandomUUIDV5 will return a 32bit random seeded UUID based on // a randomly generated UUID v4. func GenerateRandomUUIDV5() string { - nsUUID := uuid.NewV4() + nsUUID, _ := uuid.NewV4() token := make([]byte, 32) _, _ = rand.Read(token) namespace := string(token) diff --git a/store/store_test.go b/store/store_test.go index a801144b..6d2bd7e8 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -8,8 +8,9 @@ import ( "testing" "time" + "github.com/gofrs/uuid" + "github.com/gaia-pipeline/gaia" - uuid "github.com/satori/go.uuid" ) func TestInit(t *testing.T) { @@ -172,8 +173,12 @@ func TestCreatePipelinePut(t *testing.T) { } defer store.Close() + v4, err := uuid.NewV4() + if err != nil { + t.Fatal(err) + } p := &gaia.CreatePipeline{ - ID: uuid.Must(uuid.NewV4(), nil).String(), + ID: uuid.Must(v4, nil).String(), Created: time.Now(), StatusType: gaia.CreatePipelineRunning, Pipeline: gaia.Pipeline{ @@ -206,8 +211,9 @@ func TestCreatePipelineGet(t *testing.T) { var getIDs []string for i := 0; i < 3; i++ { + v4, _ := uuid.NewV4() p := gaia.CreatePipeline{ - ID: uuid.Must(uuid.NewV4(), nil).String(), + ID: uuid.Must(v4, nil).String(), Pipeline: gaia.Pipeline{ Repo: &gaia.GitRepo{}, }, @@ -388,11 +394,12 @@ func TestPipelineGetRunHighestID(t *testing.T) { t.Fatal(err) } + v4, _ := uuid.NewV4() pipelineRun1 := &gaia.PipelineRun{ ID: 1, PipelineID: 1, Status: gaia.RunRunning, - UniqueID: uuid.Must(uuid.NewV4(), nil).String(), + UniqueID: uuid.Must(v4, nil).String(), StartDate: time.Now(), } err = store.PipelinePutRun(pipelineRun1) @@ -400,11 +407,12 @@ func TestPipelineGetRunHighestID(t *testing.T) { t.Fatal(err) } + newV4, _ := uuid.NewV4() pipelineRun2 := &gaia.PipelineRun{ ID: 2, PipelineID: 1, Status: gaia.RunRunning, - UniqueID: uuid.Must(uuid.NewV4(), nil).String(), + UniqueID: uuid.Must(newV4, nil).String(), StartDate: time.Now(), } err = store.PipelinePutRun(pipelineRun2) @@ -439,8 +447,9 @@ func TestPipelinePutRun(t *testing.T) { } defer store.Close() + v4, _ := uuid.NewV4() run := gaia.PipelineRun{ - UniqueID: uuid.Must(uuid.NewV4(), nil).String(), + UniqueID: uuid.Must(v4, nil).String(), ID: 1, PipelineID: 1, ScheduleDate: time.Now(), @@ -470,22 +479,24 @@ func TestPipelineGetScheduled(t *testing.T) { } defer store.Close() + v4, _ := uuid.NewV4() pipelineRun1 := &gaia.PipelineRun{ ID: 1, PipelineID: 1, Status: gaia.RunNotScheduled, - UniqueID: uuid.Must(uuid.NewV4(), nil).String(), + UniqueID: uuid.Must(v4, nil).String(), } err = store.PipelinePutRun(pipelineRun1) if err != nil { t.Fatal(err) } + v4, _ = uuid.NewV4() pipelineRun2 := &gaia.PipelineRun{ ID: 2, PipelineID: 1, Status: gaia.RunNotScheduled, - UniqueID: uuid.Must(uuid.NewV4(), nil).String(), + UniqueID: uuid.Must(v4, nil).String(), } err = store.PipelinePutRun(pipelineRun2) if err != nil { @@ -528,8 +539,9 @@ func TestPipelineGetRunByPipelineIDAndID(t *testing.T) { } defer store.Close() + v4, _ := uuid.NewV4() run := gaia.PipelineRun{ - UniqueID: uuid.Must(uuid.NewV4(), nil).String(), + UniqueID: uuid.Must(v4, nil).String(), ID: 1, PipelineID: 1, ScheduleDate: time.Now(), @@ -582,11 +594,12 @@ func TestPipelineGetAllRuns(t *testing.T) { } for i := 0; i < 2; i++ { + v4, _ := uuid.NewV4() p := &gaia.PipelineRun{ ID: i, PipelineID: 1, Status: gaia.RunNotScheduled, - UniqueID: uuid.Must(uuid.NewV4(), nil).String(), + UniqueID: uuid.Must(v4, nil).String(), } err = store.PipelinePutRun(p) if err != nil { @@ -646,11 +659,12 @@ func TestPipelineGetLatestRun(t *testing.T) { t.Fatal(err) } + v4, _ := uuid.NewV4() pipelineRun1 := &gaia.PipelineRun{ ID: 1, PipelineID: 1, Status: gaia.RunRunning, - UniqueID: uuid.Must(uuid.NewV4(), nil).String(), + UniqueID: uuid.Must(v4, nil).String(), StartDate: time.Now(), } err = store.PipelinePutRun(pipelineRun1) @@ -658,11 +672,12 @@ func TestPipelineGetLatestRun(t *testing.T) { t.Fatal(err) } + v4, _ = uuid.NewV4() pipelineRun2 := &gaia.PipelineRun{ ID: 2, PipelineID: 1, Status: gaia.RunRunning, - UniqueID: uuid.Must(uuid.NewV4(), nil).String(), + UniqueID: uuid.Must(v4, nil).String(), StartDate: time.Now(), } err = store.PipelinePutRun(pipelineRun2) diff --git a/workers/pipeline/build_cpp.go b/workers/pipeline/build_cpp.go index 2eb1c501..81555608 100644 --- a/workers/pipeline/build_cpp.go +++ b/workers/pipeline/build_cpp.go @@ -12,7 +12,7 @@ import ( "github.com/gaia-pipeline/gaia" "github.com/gaia-pipeline/gaia/services" - uuid "github.com/satori/go.uuid" + "github.com/gofrs/uuid" ) const ( @@ -28,11 +28,15 @@ type BuildPipelineCpp struct { // PrepareEnvironment prepares the environment before we start the build process. func (b *BuildPipelineCpp) PrepareEnvironment(p *gaia.CreatePipeline) error { // create uniqueName for destination folder - uniqueName := uuid.Must(uuid.NewV4(), nil) + v4, err := uuid.NewV4() + if err != nil { + return err + } + uniqueName := uuid.Must(v4, nil) // Create local temp folder for clone cloneFolder := filepath.Join(gaia.Cfg.HomePath, gaia.TmpFolder, gaia.TmpCppFolder, srcFolder, uniqueName.String()) - err := os.MkdirAll(cloneFolder, 0700) + err = os.MkdirAll(cloneFolder, 0700) if err != nil { return err } diff --git a/workers/pipeline/build_golang.go b/workers/pipeline/build_golang.go index 1ca9b944..a0d7fed4 100644 --- a/workers/pipeline/build_golang.go +++ b/workers/pipeline/build_golang.go @@ -12,7 +12,7 @@ import ( "github.com/gaia-pipeline/gaia" "github.com/gaia-pipeline/gaia/services" - uuid "github.com/satori/go.uuid" + "github.com/gofrs/uuid" ) const ( @@ -27,12 +27,16 @@ type BuildPipelineGolang struct { // PrepareEnvironment prepares the environment before we start the build process. func (b *BuildPipelineGolang) PrepareEnvironment(p *gaia.CreatePipeline) error { // create uniqueName for destination folder - uniqueName := uuid.Must(uuid.NewV4(), nil) + v4, err := uuid.NewV4() + if err != nil { + return err + } + uniqueName := uuid.Must(v4, nil) // Create local temp folder for clone goPath := filepath.Join(gaia.Cfg.HomePath, gaia.TmpFolder, gaia.TmpGoFolder) cloneFolder := filepath.Join(goPath, srcFolder, uniqueName.String()) - err := os.MkdirAll(cloneFolder, 0700) + err = os.MkdirAll(cloneFolder, 0700) if err != nil { return err } diff --git a/workers/pipeline/build_java.go b/workers/pipeline/build_java.go index 9b802128..b801bc3d 100644 --- a/workers/pipeline/build_java.go +++ b/workers/pipeline/build_java.go @@ -12,7 +12,7 @@ import ( "github.com/gaia-pipeline/gaia" "github.com/gaia-pipeline/gaia/services" - uuid "github.com/satori/go.uuid" + "github.com/gofrs/uuid" ) var ( @@ -33,12 +33,16 @@ type BuildPipelineJava struct { // PrepareEnvironment prepares the environment before we start the build process. func (b *BuildPipelineJava) PrepareEnvironment(p *gaia.CreatePipeline) error { // create uniqueName for destination folder - uniqueName := uuid.Must(uuid.NewV4(), nil) + v4, err := uuid.NewV4() + if err != nil { + return err + } + uniqueName := uuid.Must(v4, nil) // Create local temp folder for clone rootPath := filepath.Join(gaia.Cfg.HomePath, gaia.TmpFolder, javaFolder) cloneFolder := filepath.Join(rootPath, srcFolder, uniqueName.String()) - err := os.MkdirAll(cloneFolder, 0700) + err = os.MkdirAll(cloneFolder, 0700) if err != nil { return err } diff --git a/workers/pipeline/build_nodejs.go b/workers/pipeline/build_nodejs.go index 90f7651a..0efcfebb 100644 --- a/workers/pipeline/build_nodejs.go +++ b/workers/pipeline/build_nodejs.go @@ -12,7 +12,7 @@ import ( "github.com/gaia-pipeline/gaia" "github.com/gaia-pipeline/gaia/services" - uuid "github.com/satori/go.uuid" + "github.com/gofrs/uuid" ) const nodeJSInternalCloneFolder = "jsclone" @@ -25,11 +25,16 @@ type BuildPipelineNodeJS struct { // PrepareEnvironment prepares the environment before we start the build process. func (b *BuildPipelineNodeJS) PrepareEnvironment(p *gaia.CreatePipeline) error { // create uniqueName for destination folder - uniqueName := uuid.Must(uuid.NewV4(), nil) + v4, err := uuid.NewV4() + if err != nil { + gaia.Cfg.Logger.Debug("unable to generate uuid", "error", err.Error()) + return err + } + uniqueName := uuid.Must(v4, nil) // Create local temp folder for clone cloneFolder := filepath.Join(gaia.Cfg.HomePath, gaia.TmpFolder, gaia.TmpNodeJSFolder, srcFolder, uniqueName.String(), nodeJSInternalCloneFolder) - err := os.MkdirAll(cloneFolder, 0700) + err = os.MkdirAll(cloneFolder, 0700) if err != nil { return err } diff --git a/workers/pipeline/build_nodejs_test.go b/workers/pipeline/build_nodejs_test.go index e1db4734..656569f2 100644 --- a/workers/pipeline/build_nodejs_test.go +++ b/workers/pipeline/build_nodejs_test.go @@ -11,12 +11,11 @@ import ( "strings" "testing" - "github.com/gaia-pipeline/gaia/helper/pipelinehelper" - hclog "github.com/hashicorp/go-hclog" - - uuid "github.com/satori/go.uuid" + "github.com/gofrs/uuid" + "github.com/hashicorp/go-hclog" "github.com/gaia-pipeline/gaia" + "github.com/gaia-pipeline/gaia/helper/pipelinehelper" "github.com/gaia-pipeline/gaia/services" "github.com/gaia-pipeline/gaia/store" ) @@ -64,7 +63,11 @@ func TestExecuteBuildNodeJS(t *testing.T) { defer os.RemoveAll(tmp) gaia.Cfg = new(gaia.Config) gaia.Cfg.HomePath = tmp - pipelineID := uuid.Must(uuid.NewV4(), nil) + v4, err := uuid.NewV4() + if err != nil { + t.Fatal(err) + } + pipelineID := uuid.Must(v4, nil) buildDir := filepath.Join(gaia.Cfg.HomePath, gaia.TmpFolder, gaia.TmpNodeJSFolder, srcFolder, pipelineID.String()) if err := os.MkdirAll(buildDir, 0700); err != nil { t.Fatal(err) diff --git a/workers/pipeline/build_python.go b/workers/pipeline/build_python.go index b3f50270..86c153cc 100644 --- a/workers/pipeline/build_python.go +++ b/workers/pipeline/build_python.go @@ -14,7 +14,7 @@ import ( "github.com/gaia-pipeline/gaia" "github.com/gaia-pipeline/gaia/services" - uuid "github.com/satori/go.uuid" + "github.com/gofrs/uuid" ) var ( @@ -29,12 +29,17 @@ type BuildPipelinePython struct { // PrepareEnvironment prepares the environment before we start the build process. func (b *BuildPipelinePython) PrepareEnvironment(p *gaia.CreatePipeline) error { // create uniqueName for destination folder - uniqueName := uuid.Must(uuid.NewV4(), nil) + v4, err := uuid.NewV4() + if err != nil { + gaia.Cfg.Logger.Debug("unable to generate uuid", "error", err.Error()) + return err + } + uniqueName := uuid.Must(v4, nil) // Create local temp folder for clone rootPath := filepath.Join(gaia.Cfg.HomePath, gaia.TmpFolder, gaia.TmpPythonFolder) cloneFolder := filepath.Join(rootPath, srcFolder, uniqueName.String()) - err := os.MkdirAll(cloneFolder, 0700) + err = os.MkdirAll(cloneFolder, 0700) if err != nil { return err } diff --git a/workers/pipeline/build_ruby.go b/workers/pipeline/build_ruby.go index 794c3153..bd4d4bb6 100644 --- a/workers/pipeline/build_ruby.go +++ b/workers/pipeline/build_ruby.go @@ -14,7 +14,7 @@ import ( "github.com/gaia-pipeline/gaia" "github.com/gaia-pipeline/gaia/services" - uuid "github.com/satori/go.uuid" + "github.com/gofrs/uuid" ) var ( @@ -35,11 +35,16 @@ type BuildPipelineRuby struct { // PrepareEnvironment prepares the environment before we start the build process. func (b *BuildPipelineRuby) PrepareEnvironment(p *gaia.CreatePipeline) error { // create uniqueName for destination folder - uniqueName := uuid.Must(uuid.NewV4(), nil) + v4, err := uuid.NewV4() + if err != nil { + gaia.Cfg.Logger.Debug("unable to generate uuid", "error", err.Error()) + return err + } + uniqueName := uuid.Must(v4, nil) // Create local temp folder for clone cloneFolder := filepath.Join(gaia.Cfg.HomePath, gaia.TmpFolder, gaia.TmpRubyFolder, srcFolder, uniqueName.String()) - err := os.MkdirAll(cloneFolder, 0700) + err = os.MkdirAll(cloneFolder, 0700) if err != nil { return err } @@ -82,7 +87,11 @@ func (b *BuildPipelineRuby) ExecuteBuild(p *gaia.CreatePipeline) error { } // Generate a new UUID for the gem name to prevent conflicts with other gems. - uuid := uuid.Must(uuid.NewV4(), nil).String() + v4, err := uuid.NewV4() + if err != nil { + return err + } + uuid := uuid.Must(v4, nil).String() // Read gemspec file. gemspecContent, err := ioutil.ReadFile(gemspec[0]) diff --git a/workers/pipeline/testacc/build_pipeline_test.go b/workers/pipeline/testacc/build_pipeline_test.go index 6d758f65..7cceb0d6 100644 --- a/workers/pipeline/testacc/build_pipeline_test.go +++ b/workers/pipeline/testacc/build_pipeline_test.go @@ -9,7 +9,7 @@ import ( "github.com/gaia-pipeline/gaia" "github.com/gaia-pipeline/gaia/server" "github.com/gaia-pipeline/gaia/workers/pipeline" - uuid "github.com/satori/go.uuid" + "github.com/gofrs/uuid" ) func TestBuildPipelineAcceptanceTestTearUp(t *testing.T) { @@ -46,8 +46,9 @@ func TestBuildPipelineAcceptanceTestTearUp(t *testing.T) { func buildGoPluginTest(t *testing.T) { // Create test pipeline. + v4, _ := uuid.NewV4() testPipeline := &gaia.CreatePipeline{ - ID: uuid.Must(uuid.NewV4(), nil).String(), + ID: uuid.Must(v4, nil).String(), Pipeline: gaia.Pipeline{ Name: "GoTestPipeline", Type: gaia.PTypeGolang, @@ -66,8 +67,9 @@ func buildGoPluginTest(t *testing.T) { func buildJavaPluginTest(t *testing.T) { // Create test pipeline. + v4, _ := uuid.NewV4() testPipeline := &gaia.CreatePipeline{ - ID: uuid.Must(uuid.NewV4(), nil).String(), + ID: uuid.Must(v4, nil).String(), Pipeline: gaia.Pipeline{ Name: "JavaTestPipeline", Type: gaia.PTypeJava, @@ -86,8 +88,9 @@ func buildJavaPluginTest(t *testing.T) { func buildPythonPluginTest(t *testing.T) { // Create test pipeline. + v4, _ := uuid.NewV4() testPipeline := &gaia.CreatePipeline{ - ID: uuid.Must(uuid.NewV4(), nil).String(), + ID: uuid.Must(v4, nil).String(), Pipeline: gaia.Pipeline{ Name: "PythonTestPipeline", Type: gaia.PTypePython, @@ -106,8 +109,9 @@ func buildPythonPluginTest(t *testing.T) { func buildCppPluginTest(t *testing.T) { // Create test pipeline. + v4, _ := uuid.NewV4() testPipeline := &gaia.CreatePipeline{ - ID: uuid.Must(uuid.NewV4(), nil).String(), + ID: uuid.Must(v4, nil).String(), Pipeline: gaia.Pipeline{ Name: "CppTestPipeline", Type: gaia.PTypeCpp, @@ -126,8 +130,9 @@ func buildCppPluginTest(t *testing.T) { func buildRubyPluginTest(t *testing.T) { // Create test pipeline. + v4, _ := uuid.NewV4() testPipeline := &gaia.CreatePipeline{ - ID: uuid.Must(uuid.NewV4(), nil).String(), + ID: uuid.Must(v4, nil).String(), Pipeline: gaia.Pipeline{ Name: "RubyTestPipeline", Type: gaia.PTypeRuby, @@ -146,8 +151,9 @@ func buildRubyPluginTest(t *testing.T) { func buildNodeJSPluginTest(t *testing.T) { // Create test pipeline. + v4, _ := uuid.NewV4() testPipeline := &gaia.CreatePipeline{ - ID: uuid.Must(uuid.NewV4(), nil).String(), + ID: uuid.Must(v4, nil).String(), Pipeline: gaia.Pipeline{ Name: "NodeJSTestPipeline", Type: gaia.PTypeNodeJS, diff --git a/workers/scheduler/scheduler.go b/workers/scheduler/scheduler.go index 089605e6..28f56327 100644 --- a/workers/scheduler/scheduler.go +++ b/workers/scheduler/scheduler.go @@ -17,7 +17,7 @@ import ( "github.com/gaia-pipeline/gaia/store" "github.com/gaia-pipeline/gaia/store/memdb" "github.com/gaia-pipeline/gaia/workers/docker" - uuid "github.com/satori/go.uuid" + "github.com/gofrs/uuid" ) const ( @@ -429,8 +429,12 @@ func (s *Scheduler) SchedulePipeline(p *gaia.Pipeline, args []*gaia.Argument) (* } // Create new not scheduled pipeline run + v4, err := uuid.NewV4() + if err != nil { + return nil, err + } run := gaia.PipelineRun{ - UniqueID: uuid.Must(uuid.NewV4(), nil).String(), + UniqueID: uuid.Must(v4, nil).String(), ID: highestID, PipelineID: p.ID, ScheduleDate: time.Now(), diff --git a/workers/scheduler/scheduler_test.go b/workers/scheduler/scheduler_test.go index 50a668b1..9351e1ea 100644 --- a/workers/scheduler/scheduler_test.go +++ b/workers/scheduler/scheduler_test.go @@ -17,8 +17,8 @@ import ( "github.com/gaia-pipeline/gaia/plugin" "github.com/gaia-pipeline/gaia/security" "github.com/gaia-pipeline/gaia/store" - hclog "github.com/hashicorp/go-hclog" - uuid "github.com/satori/go.uuid" + "github.com/gofrs/uuid" + "github.com/hashicorp/go-hclog" ) type PluginFake struct{} @@ -630,11 +630,12 @@ func prepareTestData() (pipeline gaia.Pipeline, pipelineRun gaia.PipelineRun) { Type: gaia.PTypeGolang, Jobs: prepareJobs(), } + v4, _ := uuid.NewV4() pipelineRun = gaia.PipelineRun{ ID: 1, PipelineID: 1, Status: gaia.RunNotScheduled, - UniqueID: uuid.Must(uuid.NewV4(), nil).String(), + UniqueID: uuid.Must(v4, nil).String(), Jobs: pipeline.Jobs, } return