Skip to content

Commit 06b78b8

Browse files
mikelolasagastirhafer
authored andcommitted
chore: drop gofrs/uuid module usage and use google/uuid
Signed-off-by: Mikel Olasagasti Uranga <[email protected]>
1 parent c76ba6f commit 06b78b8

File tree

10 files changed

+26
-26
lines changed

10 files changed

+26
-26
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ require (
3434
github.com/go-micro/plugins/v4/wrapper/monitoring/prometheus v1.2.0
3535
github.com/go-micro/plugins/v4/wrapper/trace/opentelemetry v1.2.0
3636
github.com/go-playground/validator/v10 v10.28.0
37-
github.com/gofrs/uuid v4.4.0+incompatible
3837
github.com/golang-jwt/jwt/v5 v5.3.0
3938
github.com/golang/protobuf v1.5.4
4039
github.com/google/go-cmp v0.7.0
@@ -230,6 +229,7 @@ require (
230229
github.com/goccy/go-json v0.10.5 // indirect
231230
github.com/goccy/go-yaml v1.18.0 // indirect
232231
github.com/gofrs/flock v0.13.0 // indirect
232+
github.com/gofrs/uuid v4.4.0+incompatible // indirect
233233
github.com/gogo/protobuf v1.3.2 // indirect
234234
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
235235
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect

opencloud/pkg/init/init.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os"
66
"path"
77

8-
"github.com/gofrs/uuid"
8+
"github.com/google/uuid"
99
"gopkg.in/yaml.v2"
1010

1111
"github.com/opencloud-eu/opencloud/pkg/generators"
@@ -103,11 +103,11 @@ func CreateConfig(insecure, forceOverwrite, diff bool, configPath, adminPassword
103103
}
104104
}
105105
} else {
106-
systemUserID = uuid.Must(uuid.NewV4()).String()
107-
adminUserID = uuid.Must(uuid.NewV4()).String()
108-
graphApplicationID = uuid.Must(uuid.NewV4()).String()
109-
storageUsersMountID = uuid.Must(uuid.NewV4()).String()
110-
serviceAccountID = uuid.Must(uuid.NewV4()).String()
106+
systemUserID = uuid.NewString()
107+
adminUserID = uuid.NewString()
108+
graphApplicationID = uuid.NewString()
109+
storageUsersMountID = uuid.NewString()
110+
serviceAccountID = uuid.NewString()
111111

112112
idmServicePassword, err = generators.GenerateRandomPassword(passwordLength)
113113
if err != nil {

services/graph/pkg/identity/ldap_education_school.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"time"
88

99
"github.com/go-ldap/ldap/v3"
10-
"github.com/gofrs/uuid"
10+
"github.com/google/uuid"
1111
libregraph "github.com/opencloud-eu/libre-graph-api-go"
1212
"github.com/opencloud-eu/opencloud/pkg/log"
1313
"github.com/opencloud-eu/opencloud/services/graph/pkg/config"
@@ -148,7 +148,7 @@ func (i *LDAP) CreateEducationSchool(ctx context.Context, school libregraph.Educ
148148
ar.Attribute(i.educationConfig.schoolAttributeMap.schoolNumber, []string{school.GetSchoolNumber()})
149149
}
150150
if !i.useServerUUID {
151-
ar.Attribute(i.educationConfig.schoolAttributeMap.id, []string{uuid.Must(uuid.NewV4()).String()})
151+
ar.Attribute(i.educationConfig.schoolAttributeMap.id, []string{uuid.NewString()})
152152
}
153153
objectClasses := []string{"organizationalUnit", i.educationConfig.schoolObjectClass, "top"}
154154
ar.Attribute("objectClass", objectClasses)

services/graph/pkg/identity/ldap_group.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
"github.com/CiscoM31/godata"
1212
"github.com/go-ldap/ldap/v3"
13-
"github.com/gofrs/uuid"
13+
"github.com/google/uuid"
1414
"github.com/libregraph/idm/pkg/ldapdn"
1515
libregraph "github.com/opencloud-eu/libre-graph-api-go"
1616

@@ -448,7 +448,7 @@ func (i *LDAP) groupToLDAPAttrValues(group libregraph.Group) (map[string][]strin
448448
}
449449

450450
if !i.useServerUUID {
451-
attrs["openCloudUUID"] = []string{uuid.Must(uuid.NewV4()).String()}
451+
attrs["openCloudUUID"] = []string{uuid.NewString()}
452452
attrs["objectClass"] = append(attrs["objectClass"], "openCloudObject")
453453
}
454454
return attrs, nil

services/settings/pkg/store/metadata/assignments.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"encoding/json"
77
"fmt"
88

9-
"github.com/gofrs/uuid"
9+
"github.com/google/uuid"
1010
settingsmsg "github.com/opencloud-eu/opencloud/protogen/gen/opencloud/messages/settings/v0"
1111
"github.com/opencloud-eu/opencloud/services/settings/pkg/settings"
1212
"github.com/opencloud-eu/opencloud/services/settings/pkg/store/defaults"
@@ -20,7 +20,7 @@ func (s *Store) ListRoleAssignments(accountUUID string) ([]*settingsmsg.UserRole
2020
if accountUUID == serviceAccountID {
2121
return []*settingsmsg.UserRoleAssignment{
2222
{
23-
Id: uuid.Must(uuid.NewV4()).String(), // should we hardcode this id too?
23+
Id: uuid.NewString(), // should we hardcode this id too?
2424
AccountUuid: accountUUID,
2525
RoleId: defaults.BundleUUIDServiceAccount,
2626
},
@@ -136,7 +136,7 @@ func (s *Store) WriteRoleAssignment(accountUUID, roleID string) (*settingsmsg.Us
136136
}
137137

138138
ass := &settingsmsg.UserRoleAssignment{
139-
Id: uuid.Must(uuid.NewV4()).String(),
139+
Id: uuid.NewString(),
140140
AccountUuid: accountUUID,
141141
RoleId: roleID,
142142
}

services/settings/pkg/store/metadata/assignments_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"sync"
66
"testing"
77

8-
"github.com/gofrs/uuid"
8+
"github.com/google/uuid"
99
olog "github.com/opencloud-eu/opencloud/pkg/log"
1010
"github.com/opencloud-eu/opencloud/pkg/shared"
1111
settingsmsg "github.com/opencloud-eu/opencloud/protogen/gen/opencloud/messages/settings/v0"
@@ -95,7 +95,7 @@ func initStore() *Store {
9595
cfg: defaults.DefaultConfig(),
9696
}
9797
s.cfg.Commons = &shared.Commons{
98-
AdminUserID: uuid.Must(uuid.NewV4()).String(),
98+
AdminUserID: uuid.NewString(),
9999
}
100100

101101
_ = NewMDC(s)

services/settings/pkg/store/metadata/bundles.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"errors"
88
"fmt"
99

10-
"github.com/gofrs/uuid"
10+
"github.com/google/uuid"
1111
settingsmsg "github.com/opencloud-eu/opencloud/protogen/gen/opencloud/messages/settings/v0"
1212
"github.com/opencloud-eu/opencloud/services/settings/pkg/settings"
1313
"github.com/opencloud-eu/opencloud/services/settings/pkg/store/defaults"
@@ -146,7 +146,7 @@ func (s *Store) AddSettingToBundle(bundleID string, setting *settingsmsg.Setting
146146
}
147147

148148
if setting.Id == "" {
149-
setting.Id = uuid.Must(uuid.NewV4()).String()
149+
setting.Id = uuid.NewString()
150150
}
151151

152152
b.Settings = append(b.Settings, setting)

services/settings/pkg/store/metadata/bundles_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package store
33
import (
44
"testing"
55

6-
"github.com/gofrs/uuid"
6+
"github.com/google/uuid"
77
settingsmsg "github.com/opencloud-eu/opencloud/protogen/gen/opencloud/messages/settings/v0"
88
"github.com/stretchr/testify/require"
99
)
@@ -102,7 +102,7 @@ var bundleScenarios = []struct {
102102
}
103103

104104
var (
105-
appendTestBundleID = uuid.Must(uuid.NewV4()).String()
105+
appendTestBundleID = uuid.NewString()
106106

107107
appendTestSetting1 = &settingsmsg.Setting{
108108
Id: "append-test-setting-1",

services/settings/pkg/store/metadata/store.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"log"
88
"sync"
99

10-
"github.com/gofrs/uuid"
10+
"github.com/google/uuid"
1111
olog "github.com/opencloud-eu/opencloud/pkg/log"
1212
settingsmsg "github.com/opencloud-eu/opencloud/protogen/gen/opencloud/messages/settings/v0"
1313
"github.com/opencloud-eu/opencloud/services/settings/pkg/config"
@@ -21,7 +21,7 @@ var (
2121
// Name is the default name for the settings store
2222
Name = "opencloud-settings"
2323
managerName = "metadata"
24-
settingsSpaceID = "f1bdd61a-da7c-49fc-8203-0558109d1b4f" // uuid.Must(uuid.NewV4()).String()
24+
settingsSpaceID = "f1bdd61a-da7c-49fc-8203-0558109d1b4f" // uuid.NewString()
2525
rootFolderLocation = "settings"
2626
bundleFolderLocation = "settings/bundles"
2727
accountsFolderLocation = "settings/accounts"
@@ -156,7 +156,7 @@ func (s *Store) initMetadataClient(mdc MetadataClient) error {
156156
}
157157

158158
ass := &settingsmsg.UserRoleAssignment{
159-
Id: uuid.Must(uuid.NewV4()).String(),
159+
Id: uuid.NewString(),
160160
AccountUuid: accountUUID,
161161
RoleId: roleID,
162162
}
@@ -220,7 +220,7 @@ func (s *Store) userMustHaveAdminRole(accountUUID string, assIDs []string, mdc M
220220
}
221221

222222
ass := &settingsmsg.UserRoleAssignment{
223-
Id: uuid.Must(uuid.NewV4()).String(),
223+
Id: uuid.NewString(),
224224
AccountUuid: accountUUID,
225225
RoleId: defaults.BundleUUIDRoleAdmin,
226226
}

services/settings/pkg/store/metadata/values.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"encoding/json"
77
"fmt"
88

9-
"github.com/gofrs/uuid"
9+
"github.com/google/uuid"
1010
settingsmsg "github.com/opencloud-eu/opencloud/protogen/gen/opencloud/messages/settings/v0"
1111
"github.com/opencloud-eu/opencloud/services/settings/pkg/settings"
1212
"github.com/opencloud-eu/reva/v2/pkg/errtypes"
@@ -127,7 +127,7 @@ func (s *Store) WriteValue(value *settingsmsg.Value) (*settingsmsg.Value, error)
127127
ctx := context.TODO()
128128

129129
if value.Id == "" {
130-
value.Id = uuid.Must(uuid.NewV4()).String()
130+
value.Id = uuid.NewString()
131131
}
132132
b, err := json.Marshal(value)
133133
if err != nil {

0 commit comments

Comments
 (0)