Skip to content

Commit

Permalink
Merge pull request agola-io#311 from sgotti/use_maintained_go_uuid_pa…
Browse files Browse the repository at this point in the history
  • Loading branch information
sgotti authored Feb 22, 2022
2 parents 45194ef + 47a31d7 commit 908eae4
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 93 deletions.
6 changes: 3 additions & 3 deletions cmd/agola/cmd/directrunstart.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
gwclient "agola.io/agola/services/gateway/client"

"github.com/ghodss/yaml"
uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
"github.com/spf13/cobra"
errors "golang.org/x/xerrors"
)
Expand Down Expand Up @@ -163,7 +163,7 @@ func directRunStart(cmd *cobra.Command, args []string) error {
git := &util.Git{}
repoUUID, _ := git.ConfigGet(context.Background(), "agola.repouuid")
if repoUUID == "" {
repoUUID = uuid.NewV4().String()
repoUUID = uuid.Must(uuid.NewV4()).String()
if _, err := git.ConfigSet(context.Background(), "agola.repouuid", repoUUID); err != nil {
return fmt.Errorf("failed to set agola repo uid in git config: %v", err)
}
Expand All @@ -174,7 +174,7 @@ func directRunStart(cmd *cobra.Command, args []string) error {
AddIgnored: directRunStartOpts.ignored,
})

localBranch := "gitsavebranch-" + uuid.NewV4().String()
localBranch := "gitsavebranch-" + uuid.Must(uuid.NewV4()).String()
message := "agola direct run"

commitSHA, err := gs.Save(message, localBranch)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/elazarl/go-bindata-assetfs v1.0.0
github.com/ghodss/yaml v1.0.0
github.com/go-bindata/go-bindata v1.0.0
github.com/gofrs/uuid v4.2.0+incompatible
github.com/golang-jwt/jwt/v4 v4.0.0
github.com/google/go-cmp v0.4.0
github.com/google/go-containerregistry v0.0.0-20200212224832-c629a66d7231
Expand All @@ -26,7 +27,6 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/opencontainers/runc v0.1.1 // indirect
github.com/sanity-io/litter v1.2.0
github.com/satori/go.uuid v1.2.0
github.com/sgotti/gexpect v0.0.0-20210315095146-1ec64e69809b
github.com/spf13/cobra v0.0.5
github.com/xanzy/go-gitlab v0.26.0
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4=
github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0=
github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d h1:3PaI8p3seN09VjbTYC/QWlUZdZ1qS1zGjy7LH2Wt07I=
Expand Down Expand Up @@ -366,7 +368,6 @@ github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sanity-io/litter v1.2.0 h1:DGJO0bxH/+C2EukzOSBmAlxmkhVMGqzvcx/rvySYw9M=
github.com/sanity-io/litter v1.2.0/go.mod h1:JF6pZUFgu2Q0sBZ+HSV35P8TVPI1TTzEwyu9FXAw2W4=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
Expand Down
8 changes: 4 additions & 4 deletions internal/datamanager/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"agola.io/agola/internal/sequence"
"agola.io/agola/internal/util"

uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
errors "golang.org/x/xerrors"
)

Expand Down Expand Up @@ -469,7 +469,7 @@ func (d *DataManager) writeDataType(ctx context.Context, wi walIndex, dataType s
}
dataFileIndexes = append(dataFileIndexes, dataFileIndex)
for i, sp := range splitPoints {
curDataFileID := d.dataFileID(dataSequence, uuid.NewV4().String())
curDataFileID := d.dataFileID(dataSequence, uuid.Must(uuid.NewV4()).String())
if err := d.writeDataFile(ctx, &buf, sp.pos-curPos, dataFileIndexes[i], curDataFileID, dataType); err != nil {
return nil, err
}
Expand Down Expand Up @@ -744,7 +744,7 @@ func (d *DataManager) Import(ctx context.Context, r io.Reader) error {

err := dec.Decode(&de)
if err == io.EOF {
dataFileID := d.dataFileID(dataSequence, uuid.NewV4().String())
dataFileID := d.dataFileID(dataSequence, uuid.Must(uuid.NewV4()).String())
if err := d.writeDataFile(ctx, &buf, int64(buf.Len()), dataFileIndex, dataFileID, curDataType); err != nil {
return err
}
Expand Down Expand Up @@ -778,7 +778,7 @@ func (d *DataManager) Import(ctx context.Context, r io.Reader) error {
}

if mustWrite {
dataFileID := d.dataFileID(dataSequence, uuid.NewV4().String())
dataFileID := d.dataFileID(dataSequence, uuid.Must(uuid.NewV4()).String())
if err := d.writeDataFile(ctx, &buf, int64(buf.Len()), dataFileIndex, dataFileID, curDataType); err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions internal/datamanager/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"agola.io/agola/internal/sequence"
"agola.io/agola/internal/util"

uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
etcdclientv3 "go.etcd.io/etcd/clientv3"
"go.etcd.io/etcd/clientv3/concurrency"
etcdclientv3rpc "go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
Expand Down Expand Up @@ -439,7 +439,7 @@ func (d *DataManager) WriteWalAdditionalOps(ctx context.Context, actions []*Acti
}
walsData.Revision = resp.Kvs[0].ModRevision

walDataFileID := uuid.NewV4().String()
walDataFileID := uuid.Must(uuid.NewV4()).String()
walDataFilePath := d.storageWalDataFile(walDataFileID)
walKey := etcdWalKey(walSequence.String())

Expand Down Expand Up @@ -1196,7 +1196,7 @@ func (d *DataManager) InitEtcd(ctx context.Context, dataStatus *DataStatus) erro
return err
}

walDataFileID := uuid.NewV4().String()
walDataFileID := uuid.Must(uuid.NewV4()).String()
walDataFilePath := d.storageWalDataFile(walDataFileID)
walKey := etcdWalKey(walSequence.String())

Expand Down
4 changes: 2 additions & 2 deletions internal/git-save/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"path/filepath"

"agola.io/agola/internal/util"
uuid "github.com/satori/go.uuid"

"github.com/gofrs/uuid"
"go.uber.org/zap"
errors "golang.org/x/xerrors"
)
Expand Down Expand Up @@ -181,7 +181,7 @@ func (s *GitSave) Save(message, branchName string) (string, error) {
return "", err
}

tmpIndexPath := filepath.Join(gitdir, "gitsave-index-"+uuid.NewV4().String())
tmpIndexPath := filepath.Join(gitdir, "gitsave-index-"+uuid.Must(uuid.NewV4()).String())
defer os.Remove(tmpIndexPath)

indexPath := filepath.Join(gitdir, gitIndexFile)
Expand Down
10 changes: 5 additions & 5 deletions internal/services/configstore/action/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"agola.io/agola/internal/util"
"agola.io/agola/services/configstore/types"

uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
errors "golang.org/x/xerrors"
)

Expand Down Expand Up @@ -119,7 +119,7 @@ func (h *ActionHandler) CreateOrg(ctx context.Context, org *types.Organization)

actions := []*datamanager.Action{}

org.ID = uuid.NewV4().String()
org.ID = uuid.Must(uuid.NewV4()).String()
org.CreatedAt = time.Now()
orgj, err := json.Marshal(org)
if err != nil {
Expand All @@ -135,7 +135,7 @@ func (h *ActionHandler) CreateOrg(ctx context.Context, org *types.Organization)
if org.CreatorUserID != "" {
// add the creator as org member with role owner
orgmember := &types.OrganizationMember{
ID: uuid.NewV4().String(),
ID: uuid.Must(uuid.NewV4()).String(),
OrganizationID: org.ID,
UserID: org.CreatorUserID,
MemberRole: types.MemberRoleOwner,
Expand All @@ -154,7 +154,7 @@ func (h *ActionHandler) CreateOrg(ctx context.Context, org *types.Organization)

// create root org project group
pg := &types.ProjectGroup{
ID: uuid.NewV4().String(),
ID: uuid.Must(uuid.NewV4()).String(),
// use same org visibility
Visibility: org.Visibility,
Parent: types.Parent{
Expand Down Expand Up @@ -277,7 +277,7 @@ func (h *ActionHandler) AddOrgMember(ctx context.Context, orgRef, userRef string
orgmember.MemberRole = role
} else {
orgmember = &types.OrganizationMember{
ID: uuid.NewV4().String(),
ID: uuid.Must(uuid.NewV4()).String(),
OrganizationID: org.ID,
UserID: user.ID,
MemberRole: role,
Expand Down
8 changes: 4 additions & 4 deletions internal/services/configstore/action/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"agola.io/agola/internal/util"
"agola.io/agola/services/configstore/types"

uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
errors "golang.org/x/xerrors"
)

Expand Down Expand Up @@ -148,11 +148,11 @@ func (h *ActionHandler) CreateProject(ctx context.Context, project *types.Projec
return nil, err
}

project.ID = uuid.NewV4().String()
project.ID = uuid.Must(uuid.NewV4()).String()
project.Parent.Type = types.ConfigTypeProjectGroup
// generate the Secret and the WebhookSecret
project.Secret = util.EncodeSha1Hex(uuid.NewV4().String())
project.WebhookSecret = util.EncodeSha1Hex(uuid.NewV4().String())
project.Secret = util.EncodeSha1Hex(uuid.Must(uuid.NewV4()).String())
project.WebhookSecret = util.EncodeSha1Hex(uuid.Must(uuid.NewV4()).String())

pcj, err := json.Marshal(project)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/services/configstore/action/projectgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"agola.io/agola/internal/util"
"agola.io/agola/services/configstore/types"

uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
errors "golang.org/x/xerrors"
)

Expand Down Expand Up @@ -176,7 +176,7 @@ func (h *ActionHandler) CreateProjectGroup(ctx context.Context, projectGroup *ty
return nil, err
}

projectGroup.ID = uuid.NewV4().String()
projectGroup.ID = uuid.Must(uuid.NewV4()).String()
projectGroup.Parent.Type = types.ConfigTypeProjectGroup

pgj, err := json.Marshal(projectGroup)
Expand Down
4 changes: 2 additions & 2 deletions internal/services/configstore/action/remotesource.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"agola.io/agola/internal/util"
"agola.io/agola/services/configstore/types"

uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
errors "golang.org/x/xerrors"
)

Expand Down Expand Up @@ -95,7 +95,7 @@ func (h *ActionHandler) CreateRemoteSource(ctx context.Context, remoteSource *ty
return nil, err
}

remoteSource.ID = uuid.NewV4().String()
remoteSource.ID = uuid.Must(uuid.NewV4()).String()

rsj, err := json.Marshal(remoteSource)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/services/configstore/action/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"agola.io/agola/internal/util"
"agola.io/agola/services/configstore/types"

uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
errors "golang.org/x/xerrors"
)

Expand Down Expand Up @@ -133,7 +133,7 @@ func (h *ActionHandler) CreateSecret(ctx context.Context, secret *types.Secret)
return nil, err
}

secret.ID = uuid.NewV4().String()
secret.ID = uuid.Must(uuid.NewV4()).String()

secretj, err := json.Marshal(secret)
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions internal/services/configstore/action/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"agola.io/agola/internal/util"
"agola.io/agola/services/configstore/types"

uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
errors "golang.org/x/xerrors"
)

Expand Down Expand Up @@ -89,17 +89,17 @@ func (h *ActionHandler) CreateUser(ctx context.Context, req *CreateUserRequest)
}

user := &types.User{
ID: uuid.NewV4().String(),
ID: uuid.Must(uuid.NewV4()).String(),
Name: req.UserName,
Secret: util.EncodeSha1Hex(uuid.NewV4().String()),
Secret: util.EncodeSha1Hex(uuid.Must(uuid.NewV4()).String()),
}
if req.CreateUserLARequest != nil {
if user.LinkedAccounts == nil {
user.LinkedAccounts = make(map[string]*types.LinkedAccount)
}

la := &types.LinkedAccount{
ID: uuid.NewV4().String(),
ID: uuid.Must(uuid.NewV4()).String(),
RemoteSourceID: rs.ID,
RemoteUserID: req.CreateUserLARequest.RemoteUserID,
RemoteUserName: req.CreateUserLARequest.RemoteUserName,
Expand All @@ -119,7 +119,7 @@ func (h *ActionHandler) CreateUser(ctx context.Context, req *CreateUserRequest)

// create root user project group
pg := &types.ProjectGroup{
ID: uuid.NewV4().String(),
ID: uuid.Must(uuid.NewV4()).String(),
// use public visibility
Visibility: types.VisibilityPublic,
Parent: types.Parent{
Expand Down Expand Up @@ -332,7 +332,7 @@ func (h *ActionHandler) CreateUserLA(ctx context.Context, req *CreateUserLAReque
}

la := &types.LinkedAccount{
ID: uuid.NewV4().String(),
ID: uuid.Must(uuid.NewV4()).String(),
RemoteSourceID: rs.ID,
RemoteUserID: req.RemoteUserID,
RemoteUserName: req.RemoteUserName,
Expand Down Expand Up @@ -550,7 +550,7 @@ func (h *ActionHandler) CreateUserToken(ctx context.Context, userRef, tokenName
user.Tokens = make(map[string]string)
}

token := util.EncodeSha1Hex(uuid.NewV4().String())
token := util.EncodeSha1Hex(uuid.Must(uuid.NewV4()).String())
user.Tokens[tokenName] = token

userj, err := json.Marshal(user)
Expand Down
4 changes: 2 additions & 2 deletions internal/services/configstore/action/variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"agola.io/agola/internal/util"
"agola.io/agola/services/configstore/types"

uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
errors "golang.org/x/xerrors"
)

Expand Down Expand Up @@ -109,7 +109,7 @@ func (h *ActionHandler) CreateVariable(ctx context.Context, variable *types.Vari
return nil, err
}

variable.ID = uuid.NewV4().String()
variable.ID = uuid.Must(uuid.NewV4()).String()

variablej, err := json.Marshal(variable)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/services/configstore/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"net/url"
"strings"

uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
)

const (
Expand Down
Loading

0 comments on commit 908eae4

Please sign in to comment.