From a65d00c7f8c057e598f4c69c7ff2da3e418949f3 Mon Sep 17 00:00:00 2001 From: Samuel Rowe Date: Sun, 31 Jul 2022 20:03:43 +0530 Subject: [PATCH] feat(frontend): add `deploy` attribute to `IEditServiceForm` interface * Updatd `IService` to make all the attributes in `deploy` optional. This change ensures that `IService.deploy` adheres to the specification. --- services/frontend/src/types/index.ts | 121 +++++++++++++++++++-------- 1 file changed, 85 insertions(+), 36 deletions(-) diff --git a/services/frontend/src/types/index.ts b/services/frontend/src/types/index.ts index b1b9071..8dfa319 100644 --- a/services/frontend/src/types/index.ts +++ b/services/frontend/src/types/index.ts @@ -153,48 +153,48 @@ export interface IService { condition: string; }; }; - deploy: { - endpoint_mode: string; - labels: string[] | { [key: string]: string }; - mode: string; - placement: { - constraints: KeyValPair[] | KeyValPair; - preferences: KeyValPair[] | KeyValPair; + deploy?: { + endpoint_mode?: "vip" | "dnsrr"; + labels?: string[] | Record; + mode?: "replicated" | "global"; + placement?: { + constraints?: KeyValPair[] | KeyValPair; + preferences?: KeyValPair[] | KeyValPair; }; - replicas: number; - resources: { - limits: { - cpus: string; - memory: string; - pids: number; + replicas?: number; + resources?: { + limits?: { + cpus?: string; + memory?: string; + pids?: number; }; - reservations: { - cpus: string; - memory: string; - devices: { [key: string]: string | number | string[] }[]; + reservations?: { + cpus?: string; + memory?: string; + devices?: { [key: string]: string | number | string[] }[]; }; }; - restart_policy: { - condition: string; - delay: string; - max_attempts: number; - window: string; + restart_policy?: { + condition?: "none" | "on-failure" | "any"; + delay?: string; + max_attempts?: number; + window?: string; }; - rollback_config: { - parallelism: number; - delay: string; - failure_action: string; - monitor: string; - max_failure_ratio: string; - order: string; + rollback_config?: { + parallelism?: number; + delay?: string; + failure_action?: string; + monitor?: string; + max_failure_ratio?: string; + order?: string; }; - update_config: { - parallelism: number; - delay: string; - failure_action: string; - monitor: string; - max_failure_ratio: string; - order: string; + update_config?: { + parallelism?: number; + delay?: string; + failure_action?: string; + monitor?: string; + max_failure_ratio?: string; + order?: string; }; }; device_cgroup_rules: string[]; @@ -385,6 +385,55 @@ export interface IEditServiceForm { sharedMemorySize: string; target: string; }; + deploy: { + /** + * The default value for `mode` is `replicated`. However, we allow + * it to be empty. Thus, `mode` attribute can be pruned away + * if the user never assigned `mode` explicitly. + */ + mode: "" | "global" | "replicated"; + /** + * The default value for `endpointMode` is platform dependent. + */ + endpointMode: "" | "vip" | "dnsrr"; + replicas: string; + placement: { + constraints: { + key: string; + value: string; + }[]; + preferences: { + key: string; + value: string; + }[]; + }; + resources: { + limits: { + cpus: string; + memory: string; + pids: string; + }; + reservations: { + cpus: string; + memory: string; + }; + }; + restartPolicy: { + /** + * The default value for `condition` is `any`. However, we allow + * it to be empty. Thus, `deploy` attribute can be pruned away + * if the user never assigned `condition` explicitly. + */ + condition: "" | "none" | "on-failure" | "any"; + delay: string; + maxAttempts: string; + window: string; + }; + labels: { + key: string; + value: string; + }[]; + }; serviceName: string; imageName: string; imageTag: string;