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
3d2d5439
Commit
3d2d5439
authored
2 years ago
by
ko_oler
Browse files
Options
Downloads
Patches
Plain Diff
правки по ПР
parent
e19c968f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/setup/collection.go
+12
-6
12 additions, 6 deletions
pkg/setup/collection.go
pkg/setup/collection_test.go
+3
-3
3 additions, 3 deletions
pkg/setup/collection_test.go
with
15 additions
and
9 deletions
pkg/setup/collection.go
+
12
−
6
View file @
3d2d5439
...
@@ -15,6 +15,7 @@ var (
...
@@ -15,6 +15,7 @@ var (
ErrCheckCollections
=
errors
.
New
(
"collections check error"
)
ErrCheckCollections
=
errors
.
New
(
"collections check error"
)
ErrInstallCollections
=
errors
.
New
(
"failed to install collections"
)
ErrInstallCollections
=
errors
.
New
(
"failed to install collections"
)
ErrUninstallCollections
=
errors
.
New
(
"failed to uninstall collections"
)
ErrUninstallCollections
=
errors
.
New
(
"failed to uninstall collections"
)
ErrCollectionAlreadyExists
=
errors
.
New
(
"failed to uninstall collections"
)
)
)
type
CollectionsOption
func
(
c
*
CollectionConfig
)
type
CollectionsOption
func
(
c
*
CollectionConfig
)
...
@@ -81,9 +82,14 @@ func UpdateExistingCollection() CollectionsOption {
...
@@ -81,9 +82,14 @@ func UpdateExistingCollection() CollectionsOption {
}
}
}
}
func
SetSchemaMetadata
(
md
map
[
string
]
string
)
CollectionsOption
{
func
SetSchemaMetadata
(
kv
...
string
)
CollectionsOption
{
return
func
(
c
*
CollectionConfig
)
{
return
func
(
c
*
CollectionConfig
)
{
c
.
metadata
=
md
if
c
.
metadata
==
nil
{
c
.
metadata
=
make
(
map
[
string
]
string
)
}
for
i
:=
0
;
i
<
len
(
kv
);
i
+=
2
{
c
.
metadata
[
kv
[
i
]]
=
kv
[
i
+
1
]
}
}
}
}
}
...
@@ -152,7 +158,7 @@ func (s *Setup) InstallCollection(ctx context.Context, c CollectionConfig) (setS
...
@@ -152,7 +158,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
,
e
rr
ors
.
New
(
"c
ollection
a
lready
e
xists
"
)
return
false
,
E
rr
C
ollection
A
lready
E
xists
}
}
var
upd
bool
var
upd
bool
...
...
This diff is collapsed.
Click to expand it.
pkg/setup/collection_test.go
+
3
−
3
View file @
3d2d5439
...
@@ -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
(
map
[
string
]
string
{
"extension"
:
"test-extension"
}
),
co
:
SetSchemaMetadata
(
"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
(
map
[
string
]
string
{
"extension"
:
"test-extension"
}
),
co
:
SetSchemaMetadata
(
"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
(
map
[
string
]
string
{
"extension"
:
"test-extension"
}
),
co
:
SetSchemaMetadata
(
"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