Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Merge requests
!2501
Support feature worker declaration from gitlab.teklia.com
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Support feature worker declaration from gitlab.teklia.com
teklia-workers
into
release-1.7.1
Overview
5
Commits
12
Pipelines
0
Changes
1
All threads resolved!
Hide all comments
Merged
Valentin Rigal
requested to merge
teklia-workers
into
release-1.7.1
3 months ago
Overview
5
Commits
12
Pipelines
0
Changes
1
All threads resolved!
Hide all comments
Expand
Closes
#1883 (closed)
Requires tests
Edited
2 months ago
by
Valentin Rigal
0
0
Merge request reports
Viewing commit
940ff674
Prev
Next
Show latest version
1 file
+
18
−
3
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
940ff674
Add a bit of validation
· 940ff674
Valentin Rigal
authored
3 months ago
arkindex/process/management/commands/update_system_workers.py
+
18
−
3
Options
from
collections
import
defaultdict
from
django.conf
import
settings
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.db
import
transaction
from
django.db.models
import
Max
from
teklia_toolbox.config
import
ConfigParser
from
teklia_toolbox.config
import
ConfigParser
,
ConfigurationError
from
arkindex.process.models
import
ArkindexFeature
,
FeatureUsage
,
Worker
,
WorkerType
,
WorkerVersion
,
WorkerVersionState
@@ -17,12 +19,25 @@ def parse_config():
feature_parser
=
features_parser
.
add_subparser
(
feature
.
value
,
allow_extra_keys
=
False
,
default
=
{})
feature_parser
.
add_option
(
"
image
"
,
type
=
str
,
default
=
None
)
feature_parser
.
add_option
(
"
command
"
,
type
=
str
,
default
=
None
)
teklia_worker_parser
=
feature_parser
.
add_subparser
(
"
teklia_worker
"
,
allow_extra_keys
=
False
,
default
=
{}
)
teklia_worker_parser
=
feature_parser
.
add_subparser
(
"
teklia_worker
"
,
allow_extra_keys
=
False
,
default
=
None
)
teklia_worker_parser
.
add_option
(
"
name
"
,
type
=
str
,
default
=
None
)
teklia_worker_parser
.
add_option
(
"
version
"
,
type
=
str
,
default
=
None
)
teklia_worker_parser
.
add_option
(
"
slug
"
,
type
=
str
,
default
=
None
)
return
parser
.
parse
(
settings
.
BASE_DIR
/
"
system_workers.yml
"
)
parsed
=
parser
.
parse
(
settings
.
BASE_DIR
/
"
system_workers.yml
"
)
errors
=
defaultdict
(
list
)
for
feature
,
config
in
parsed
[
"
features
"
].
items
():
if
config
[
"
image
"
]
and
config
[
"
teklia_worker
"
]:
errors
[
feature
].
append
(
"
Exactly one of image/command or teklia_parser must be set
"
)
continue
if
(
subparser
:
=
config
[
"
teklia_worker
"
])
and
(
None
in
subparser
.
values
()):
errors
[
feature
].
append
(
"
teklia_parser configuration must define a name, a version and a slug
"
)
if
(
config
[
"
command
"
]
and
config
[
"
image
"
]
is
None
):
errors
[
feature
].
append
(
"
command argument must be set with the image argument
"
)
if
errors
:
raise
ConfigurationError
(
errors
)
return
parsed
class
Command
(
BaseCommand
):
Loading