Skip to content

Commit 218c077

Browse files
author
Mauricio Siu
committed
refactor: simplify StopGracePeriod handling in container specifications
- Updated the handling of StopGracePeriod in various database builders to streamline the condition check, improving code readability and maintainability.
1 parent 1c65247 commit 218c077

File tree

6 files changed

+6
-12
lines changed

6 files changed

+6
-12
lines changed

packages/server/src/utils/builders/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ export const mechanizeDockerContainer = async (
125125
Image: image,
126126
Env: envVariables,
127127
Mounts: [...volumesMount, ...bindsMount, ...filesMount],
128-
...(StopGracePeriod !== undefined &&
129-
StopGracePeriod !== null && { StopGracePeriod }),
128+
...(StopGracePeriod && { StopGracePeriod }),
130129
...(command
131130
? {
132131
Command: ["/bin/sh"],

packages/server/src/utils/databases/mariadb.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ export const buildMariadb = async (mariadb: MariadbNested) => {
7373
Image: dockerImage,
7474
Env: envVariables,
7575
Mounts: [...volumesMount, ...bindsMount, ...filesMount],
76-
...(StopGracePeriod !== undefined &&
77-
StopGracePeriod !== null && { StopGracePeriod }),
76+
...(StopGracePeriod && { StopGracePeriod }),
7877
...(command
7978
? {
8079
Command: ["/bin/sh"],

packages/server/src/utils/databases/mongo.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ ${command ?? "wait $MONGOD_PID"}`;
121121
Image: dockerImage,
122122
Env: envVariables,
123123
Mounts: [...volumesMount, ...bindsMount, ...filesMount],
124-
...(StopGracePeriod !== undefined &&
125-
StopGracePeriod !== null && { StopGracePeriod }),
124+
...(StopGracePeriod && { StopGracePeriod }),
126125
...(replicaSets
127126
? {
128127
Command: ["/bin/bash"],

packages/server/src/utils/databases/mysql.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ export const buildMysql = async (mysql: MysqlNested) => {
7979
Image: dockerImage,
8080
Env: envVariables,
8181
Mounts: [...volumesMount, ...bindsMount, ...filesMount],
82-
...(StopGracePeriod !== undefined &&
83-
StopGracePeriod !== null && { StopGracePeriod }),
82+
...(StopGracePeriod && { StopGracePeriod }),
8483
...(command
8584
? {
8685
Command: ["/bin/sh"],

packages/server/src/utils/databases/postgres.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ export const buildPostgres = async (postgres: PostgresNested) => {
7272
Image: dockerImage,
7373
Env: envVariables,
7474
Mounts: [...volumesMount, ...bindsMount, ...filesMount],
75-
...(StopGracePeriod !== undefined &&
76-
StopGracePeriod !== null && { StopGracePeriod }),
75+
...(StopGracePeriod && { StopGracePeriod }),
7776
...(command
7877
? {
7978
Command: ["/bin/sh"],

packages/server/src/utils/databases/redis.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ export const buildRedis = async (redis: RedisNested) => {
7070
Image: dockerImage,
7171
Env: envVariables,
7272
Mounts: [...volumesMount, ...bindsMount, ...filesMount],
73-
...(StopGracePeriod !== undefined &&
74-
StopGracePeriod !== null && { StopGracePeriod }),
73+
...(StopGracePeriod && { StopGracePeriod }),
7574
Command: ["/bin/sh"],
7675
Args: [
7776
"-c",

0 commit comments

Comments
 (0)