Skip to content

Commit

Permalink
[DEVOPS-616] Added systemWide flag support to task_definition.
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnykt committed Oct 10, 2024
1 parent c04f7f5 commit 9d4f30b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions api/plugins/action/task_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class ActionModule(LagoonMutationActionBase):
"advancedTaskDefinitionArguments",
"deployTokenInjection",
"projectKeyInjection",
"systemWide",
],
),
# Configuration for deleting a task definition.
Expand Down
17 changes: 12 additions & 5 deletions api/plugins/module_utils/gqlTaskDefinition.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'advancedTaskDefinitionArguments',
'deployTokenInjection',
'projectKeyInjection',
'systemWide',
]

TASK_DEFINITION_FIELDS_COMMAND = [
Expand Down Expand Up @@ -113,7 +114,8 @@ def add_update_variables(self, task_type: str, permission: str,
description: str, service: str, image: str,
command: str, arguments: list,
deploy_token_injection: bool,
project_key_injection: bool):
project_key_injection: bool,
system_wide: bool):
variables = """
$type: AdvancedTaskDefinitionTypes
$permission: TaskPermission
Expand All @@ -123,6 +125,7 @@ def add_update_variables(self, task_type: str, permission: str,
$arguments: [AdvancedTaskDefinitionArgumentInput]
$deployTokenInjection: Boolean
$projectKeyInjection: Boolean
$systemWide: Boolean
"""
variables_input = """
type: $type
Expand All @@ -133,6 +136,7 @@ def add_update_variables(self, task_type: str, permission: str,
advancedTaskDefinitionArguments: $arguments
deployTokenInjection: $deployTokenInjection
projectKeyInjection: $projectKeyInjection
systemWide: $systemWide
"""
variables_dict = {
"type": task_type,
Expand All @@ -143,6 +147,7 @@ def add_update_variables(self, task_type: str, permission: str,
"arguments": arguments,
"deployTokenInjection": deploy_token_injection,
"projectKeyInjection": project_key_injection,
"systemWide": system_wide,
}

if project_id:
Expand All @@ -169,12 +174,13 @@ def add_update_variables(self, task_type: str, permission: str,
def add(self, task_type: str, permission: str, project_id: int,
environment_id: int, name: str, description: str, service: str,
image: str, command: str, arguments: list,
deploy_token_injection: bool, project_key_injection: bool) -> dict:
deploy_token_injection: bool, project_key_injection: bool,
system_wide: bool) -> dict:

variables, variables_input, variables_dict = self.add_update_variables(
task_type, permission, project_id, environment_id, name,
description, service, image, command, arguments,
deploy_token_injection, project_key_injection)
deploy_token_injection, project_key_injection, system_wide)

res = self.client.execute_query(
f"""
Expand All @@ -199,12 +205,13 @@ def add(self, task_type: str, permission: str, project_id: int,
def update(self, id: int, task_type: str, permission: str, project_id: int,
environment_id: int, name: str, description: str, service: str,
image: str, command: str, arguments: list,
deploy_token_injection: bool, project_key_injection: bool) -> dict:
deploy_token_injection: bool, project_key_injection: bool,
system_wide: bool) -> dict:

variables, variables_input, variables_dict = self.add_update_variables(
task_type, permission, project_id, environment_id, name,
description, service, image, command, arguments,
deploy_token_injection, project_key_injection)
deploy_token_injection, project_key_injection, system_wide)

res = self.client.execute_query(
f"""
Expand Down
7 changes: 7 additions & 0 deletions api/plugins/modules/task_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
- The deployment in which the task is run (cli/php/nginx...).
- Required when state is present.
type: str
system_wide:
description:
- The task will appear for all environments, subject to the user's
- permission to invoke it.
type: bool
default: false
command:
description:
- The command to run.
Expand Down Expand Up @@ -98,6 +104,7 @@
permission: MAINTAINER
description: Run the shipshape audit
service: cli
system_wide: false
command: shipshape
- name: Delete task definition.
Expand Down
2 changes: 2 additions & 0 deletions api/tests/playbooks/task_definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
permission: MAINTAINER
description: Run my test task
service: cli
system_wide: false
command: ls -l

- name: Ensure task definitions exist
Expand All @@ -30,6 +31,7 @@
permission: MAINTAINER
description: Run my test task
service: cli
system_wide: false
command: ls -l
advancedTaskDefinitionArguments:
- name: MY_CUSTOM_ARG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def test_get(self):
}
deployTokenInjection
projectKeyInjection
systemWide
image
}
Expand All @@ -66,6 +67,7 @@ def test_get(self):
}
deployTokenInjection
projectKeyInjection
systemWide
command
}
Expand Down

0 comments on commit 9d4f30b

Please sign in to comment.