Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-go
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
e19c968f
Commit
e19c968f
authored
2 years ago
by
ko_oler
Browse files
Options
Downloads
Patches
Plain Diff
правки по ПР
parent
821bb1a9
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/setup/collection.go
+7
-5
7 additions, 5 deletions
pkg/setup/collection.go
pkg/setup/collection_test.go
+3
-3
3 additions, 3 deletions
pkg/setup/collection_test.go
with
10 additions
and
8 deletions
pkg/setup/collection.go
+
7
−
5
View file @
e19c968f
...
@@ -23,7 +23,7 @@ type DeleteCollectionFn func(s *Setup, col *collections.Collection) bool
...
@@ -23,7 +23,7 @@ type DeleteCollectionFn func(s *Setup, col *collections.Collection) bool
type
CollectionConfig
struct
{
type
CollectionConfig
struct
{
collection
*
collections
.
Collection
collection
*
collections
.
Collection
metadata
[
]
string
metadata
map
[
string
]
string
UpdateFn
UpdateCollectionFn
UpdateFn
UpdateCollectionFn
DeleteFn
DeleteCollectionFn
DeleteFn
DeleteCollectionFn
}
}
...
@@ -81,9 +81,9 @@ func UpdateExistingCollection() CollectionsOption {
...
@@ -81,9 +81,9 @@ func UpdateExistingCollection() CollectionsOption {
}
}
}
}
func
SetSchemaMetadata
(
kv
...
string
)
CollectionsOption
{
func
SetSchemaMetadata
(
md
map
[
string
]
string
)
CollectionsOption
{
return
func
(
c
*
CollectionConfig
)
{
return
func
(
c
*
CollectionConfig
)
{
c
.
metadata
=
kv
c
.
metadata
=
md
}
}
}
}
...
@@ -139,7 +139,9 @@ func (s *Setup) InstallCollection(ctx context.Context, c CollectionConfig) (setS
...
@@ -139,7 +139,9 @@ func (s *Setup) InstallCollection(ctx context.Context, c CollectionConfig) (setS
}
}
if
c
.
metadata
!=
nil
{
if
c
.
metadata
!=
nil
{
collection
.
Schema
.
WithMetadata
(
c
.
metadata
...
)
for
k
,
v
:=
range
c
.
metadata
{
collection
.
Schema
.
WithMetadata
(
k
,
v
)
}
}
}
if
exist
==
nil
{
if
exist
==
nil
{
...
@@ -150,7 +152,7 @@ func (s *Setup) InstallCollection(ctx context.Context, c CollectionConfig) (setS
...
@@ -150,7 +152,7 @@ func (s *Setup) InstallCollection(ctx context.Context, c CollectionConfig) (setS
}
}
}
else
{
}
else
{
if
collection
.
Schema
.
Metadata
!=
nil
&&
exist
.
Schema
.
Metadata
[
"extension"
]
!=
collection
.
Schema
.
Metadata
[
"extension"
]
&&
!
s
.
IsForce
()
{
if
collection
.
Schema
.
Metadata
!=
nil
&&
exist
.
Schema
.
Metadata
[
"extension"
]
!=
collection
.
Schema
.
Metadata
[
"extension"
]
&&
!
s
.
IsForce
()
{
return
false
,
errors
.
Wrap
(
errors
.
Errorf
(
"collection %s has the same id(%s) as extension's collection %s"
,
exist
.
Name
,
exist
.
ID
,
collection
.
Name
),
"fail to update collection
"
)
return
false
,
errors
.
New
(
"collection already exists
"
)
}
}
var
upd
bool
var
upd
bool
...
...
This diff is collapsed.
Click to expand it.
pkg/setup/collection_test.go
+
3
−
3
View file @
e19c968f
...
@@ -107,7 +107,7 @@ func TestSetup_InstallCollections(t *testing.T) {
...
@@ -107,7 +107,7 @@ func TestSetup_InstallCollections(t *testing.T) {
wantErr
:
func
(
t
*
testing
.
T
,
err
error
)
{
wantErr
:
func
(
t
*
testing
.
T
,
err
error
)
{
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
},
},
co
:
SetSchemaMetadata
(
"extension"
,
"test-extension"
),
co
:
SetSchemaMetadata
(
map
[
string
]
string
{
"extension"
:
"test-extension"
}
),
},
},
{
{
name
:
"Fail to update collection with the same id"
,
name
:
"Fail to update collection with the same id"
,
...
@@ -118,7 +118,7 @@ func TestSetup_InstallCollections(t *testing.T) {
...
@@ -118,7 +118,7 @@ func TestSetup_InstallCollections(t *testing.T) {
wantErr
:
func
(
t
*
testing
.
T
,
err
error
)
{
wantErr
:
func
(
t
*
testing
.
T
,
err
error
)
{
assert
.
Error
(
t
,
err
)
assert
.
Error
(
t
,
err
)
},
},
co
:
SetSchemaMetadata
(
"extension"
,
"test-extension"
),
co
:
SetSchemaMetadata
(
map
[
string
]
string
{
"extension"
:
"test-extension"
}
),
},
},
{
{
name
:
"Update collection with the same id, with force"
,
name
:
"Update collection with the same id, with force"
,
...
@@ -134,7 +134,7 @@ func TestSetup_InstallCollections(t *testing.T) {
...
@@ -134,7 +134,7 @@ func TestSetup_InstallCollections(t *testing.T) {
wantErr
:
func
(
t
*
testing
.
T
,
err
error
)
{
wantErr
:
func
(
t
*
testing
.
T
,
err
error
)
{
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
},
},
co
:
SetSchemaMetadata
(
"extension"
,
"test-extension"
),
co
:
SetSchemaMetadata
(
map
[
string
]
string
{
"extension"
:
"test-extension"
}
),
force
:
true
,
force
:
true
,
},
},
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment