Skip to content

Commit

Permalink
chore: Refacto
Browse files Browse the repository at this point in the history
  • Loading branch information
mzottola committed Nov 20, 2023
1 parent 7a38eda commit 2f642ac
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 324 deletions.
4 changes: 3 additions & 1 deletion src/schemas/_index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -755,4 +755,6 @@ ServiceTypeForVariableEnum:
LifecycleJobResponse:
$ref: ./job/LifecycleJobResponse.yaml
CronJobResponse:
$ref: ./job/CronJobResponse.yaml
$ref: ./job/CronJobResponse.yaml
BaseJobResponse:
$ref: ./job/BaseJobResponse.yaml
88 changes: 88 additions & 0 deletions src/schemas/job/BaseJobResponse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
allOf:
- $ref: '../BaseResponse.yaml'
- type: object
required:
- environment
- name
- tag
- auto_preview
- cpu
- memory
- min_running_instances
- max_running_instances
- maximum_cpu
- maximum_memory
- healthchecks
- source
properties:
environment:
$ref: '../ReferenceObject.yaml'
maximum_cpu:
type: integer
description: Maximum cpu that can be allocated to the job based on organization cluster configuration. unit is millicores (m). 1000m = 1 cpu
example: 16000
maximum_memory:
type: integer
description: Maximum memory that can be allocated to the job based on organization cluster configuration. unit is MB. 1024 MB = 1GB
example: 16384
name:
type: string
description: name is case insensitive
description:
type: string
cpu:
type: integer
description: unit is millicores (m). 1000m = 1 cpu
example: 1250
memory:
type: integer
description: unit is MB. 1024 MB = 1GB
example: 1024
max_nb_restart:
type: integer
minimum: 0
description: |
Maximum number of restart allowed before the job is considered as failed
0 means that no restart/crash of the job is allowed
max_duration_seconds:
type: integer
minimum: 0
description: |
Maximum number of seconds allowed for the job to run before killing it and mark it as failed
auto_preview:
type: boolean
description: |
Indicates if the 'environment preview option' is enabled for this container.
If enabled, a preview environment will be automatically cloned when `/preview` endpoint is called.
If not specified, it takes the value of the `auto_preview` property from the associated environment.
port:
type: integer
nullable: true
minimum: 1
description: Port where to run readiness and liveliness probes checks. The port will not be exposed externally
default: null
source:
nullable: false
oneOf:
- type: object
properties:
image:
$ref: '../ContainerSource.yaml'
- type: object
properties:
docker:
type: object
properties:
dockerfile_path:
type: string
description: The path of the associated Dockerfile. Only if you are using build_mode = DOCKER
nullable: true
git_repository:
$ref: '../ApplicationGitRepositoryResponse.yaml'
healthchecks:
$ref: '../Healthcheck.yaml'
auto_deploy:
type: boolean
description: |
Specify if the job will be automatically updated after receiving a new image tag or a new commit according to the source type.
The new image tag shall be communicated via the "Auto Deploy job" endpoint https://api-doc.qovery.com/#tag/Jobs/operation/autoDeployJobEnvironments
88 changes: 2 additions & 86 deletions src/schemas/job/CronJobResponse.yaml
Original file line number Diff line number Diff line change
@@ -1,95 +1,16 @@
allOf:
- $ref: '../BaseResponse.yaml'
- $ref: './BaseJobResponse.yaml'
- type: object
required:
- environment
- name
- tag
- auto_preview
- cpu
- memory
- min_running_instances
- max_running_instances
- maximum_cpu
- maximum_memory
- healthchecks
- source
- schedule
- job_type
properties:
environment:
$ref: '../ReferenceObject.yaml'
maximum_cpu:
type: integer
description: Maximum cpu that can be allocated to the job based on organization cluster configuration. unit is millicores (m). 1000m = 1 cpu
example: 16000
maximum_memory:
type: integer
description: Maximum memory that can be allocated to the job based on organization cluster configuration. unit is MB. 1024 MB = 1GB
example: 16384
name:
type: string
description: name is case insensitive
description:
type: string
cpu:
type: integer
description: unit is millicores (m). 1000m = 1 cpu
example: 1250
memory:
type: integer
description: unit is MB. 1024 MB = 1GB
example: 1024
max_nb_restart:
type: integer
minimum: 0
description: |
Maximum number of restart allowed before the job is considered as failed
0 means that no restart/crash of the job is allowed
max_duration_seconds:
type: integer
minimum: 0
description: |
Maximum number of seconds allowed for the job to run before killing it and mark it as failed
auto_preview:
type: boolean
description: |
Indicates if the 'environment preview option' is enabled for this container.
If enabled, a preview environment will be automatically cloned when `/preview` endpoint is called.
If not specified, it takes the value of the `auto_preview` property from the associated environment.
port:
type: integer
nullable: true
minimum: 1
description: Port where to run readiness and liveliness probes checks. The port will not be exposed externally
default: null
source:
nullable: false
oneOf:
- type: object
properties:
image:
$ref: '../ContainerSource.yaml'
- type: object
properties:
docker:
type: object
properties:
dockerfile_path:
type: string
description: The path of the associated Dockerfile. Only if you are using build_mode = DOCKER
nullable: true
git_repository:
$ref: '../ApplicationGitRepositoryResponse.yaml'
healthchecks:
$ref: '../Healthcheck.yaml'
job_type:
type: string
enum:
- CRON
schedule:
type: object
description: |
A Lifecycle job should contain at least one property `on_XXX` among the 3 properties: `on_start`, `on_stop`, `on_delete`
properties:
cronjob:
type: object
Expand All @@ -112,8 +33,3 @@ allOf:
For example: `* * * * *` represent the cron to launch the job every minute.
See https://crontab.guru/ to WISIWIG interface.
Timezone is UT
auto_deploy:
type: boolean
description: |
Specify if the job will be automatically updated after receiving a new image tag or a new commit according to the source type.
The new image tag shall be communicated via the "Auto Deploy job" endpoint https://api-doc.qovery.com/#tag/Jobs/operation/autoDeployJobEnvironments
153 changes: 8 additions & 145 deletions src/schemas/job/JobResponse.yaml
Original file line number Diff line number Diff line change
@@ -1,145 +1,8 @@
allOf:
- $ref: '../BaseResponse.yaml'
- type: object
required:
- environment
- name
- tag
- auto_preview
- cpu
- memory
- min_running_instances
- max_running_instances
- maximum_cpu
- maximum_memory
- healthchecks
- source
properties:
environment:
$ref: '../ReferenceObject.yaml'
maximum_cpu:
type: integer
description: Maximum cpu that can be allocated to the job based on organization cluster configuration. unit is millicores (m). 1000m = 1 cpu
example: 16000
maximum_memory:
type: integer
description: Maximum memory that can be allocated to the job based on organization cluster configuration. unit is MB. 1024 MB = 1GB
example: 16384
name:
type: string
description: name is case insensitive
description:
type: string
cpu:
type: integer
description: unit is millicores (m). 1000m = 1 cpu
example: 1250
memory:
type: integer
description: unit is MB. 1024 MB = 1GB
example: 1024
max_nb_restart:
type: integer
minimum: 0
description: |
Maximum number of restart allowed before the job is considered as failed
0 means that no restart/crash of the job is allowed
max_duration_seconds:
type: integer
minimum: 0
description: |
Maximum number of seconds allowed for the job to run before killing it and mark it as failed
auto_preview:
type: boolean
description: |
Indicates if the 'environment preview option' is enabled for this container.
If enabled, a preview environment will be automatically cloned when `/preview` endpoint is called.
If not specified, it takes the value of the `auto_preview` property from the associated environment.
port:
type: integer
nullable: true
minimum: 1
description: Port where to run readiness and liveliness probes checks. The port will not be exposed externally
default: null
source:
nullable: false
oneOf:
- type: object
properties:
image:
$ref: '../ContainerSource.yaml'
- type: object
properties:
docker:
type: object
properties:
dockerfile_path:
type: string
description: The path of the associated Dockerfile. Only if you are using build_mode = DOCKER
nullable: true
git_repository:
$ref: '../ApplicationGitRepositoryResponse.yaml'
healthchecks:
$ref: '../Healthcheck.yaml'
schedule:
type: object
description: |
If you want to define a Cron job, only the `cronjob` property must be filled
A Lifecycle job should contain at least one property `on_XXX` among the 3 properties: `on_start`, `on_stop`, `on_delete`
properties:
on_start:
type: object
properties:
arguments:
type: array
items:
type: string
entrypoint:
type: string
description: optional entrypoint when launching container
on_stop:
type: object
properties:
arguments:
type: array
items:
type: string
entrypoint:
type: string
description: optional entrypoint when launching container
on_delete:
type: object
properties:
arguments:
type: array
items:
type: string
entrypoint:
type: string
description: optional entrypoint when launching container
cronjob:
type: object
required:
- scheduled_at
properties:
arguments:
type: array
items:
type: string
entrypoint:
type: string
description: optional entrypoint when launching container
scheduled_at:
type: string
format: cron
description: |
Can only be set if the event is CRON.
Represent the cron format for the job schedule without seconds.
For example: `* * * * *` represent the cron to launch the job every minute.
See https://crontab.guru/ to WISIWIG interface.
Timezone is UT
auto_deploy:
type: boolean
description: |
Specify if the job will be automatically updated after receiving a new image tag or a new commit according to the source type.
The new image tag shall be communicated via the "Auto Deploy job" endpoint https://api-doc.qovery.com/#tag/Jobs/operation/autoDeployJobEnvironments
oneOf:
- $ref: './LifecycleJobResponse.yaml'
- $ref: './CronJobResponse.yaml'
discriminator:
propertyName: job_type
mapping:
LIFECYCLE: '#/components/schemas/LifecycleJobResponse'
CRON: '#/components/schemas/CronJobResponse'
9 changes: 1 addition & 8 deletions src/schemas/job/JobResponseList.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,4 @@ properties:
results:
type: array
items:
oneOf:
- $ref: './LifecycleJobResponse.yaml'
- $ref: './CronJobResponse.yaml'
discriminator:
propertyName: job_type
mapping:
LIFECYCLE: '#/components/schemas/LifecycleJobResponse'
CRON: '#/components/schemas/CronJobResponse'
$ref: './JobResponse.yaml'
Loading

0 comments on commit 2f642ac

Please sign in to comment.