summaryrefslogtreecommitdiff
path: root/model/job.ts
blob: 52386ebdcc5efc90d582c60389e912b980d758b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { isObject } from "@emprespresso/pengueno";

export type JobArgT = Record<string, string>;
export interface Job {
  readonly type: string;
  readonly arguments: JobArgT;
}
export const isJob = (j: unknown): j is Job =>
  !!(
    isObject(j) &&
    "arguments" in j &&
    isObject(j.arguments) &&
    "type" in j &&
    typeof j.type === "string" &&
    j
  );

export interface FetchCodeJobProps extends JobArgT {
  readonly remoteUrl: string;
  readonly checkout: string;
  readonly path: string;
}

export interface FetchCodeJob {
  readonly type: "fetch_code";
  readonly arguments: FetchCodeJobProps;
}

export interface BuildDockerImageJobProps extends JobArgT {
  readonly registry: string;
  readonly namespace: string;
  readonly repository: string;
  readonly imageTag: string;

  readonly context: string;
  readonly dockerfile: string;
  readonly buildTarget: string;
}

export interface BuildDockerImageJob extends Job {
  readonly type: "build_docker_image";
  readonly arguments: BuildDockerImageJobProps;
}

export interface AnsiblePlaybookJobProps extends JobArgT {
  readonly path: string;
  readonly playbooks: string;
}

export interface AnsiblePlaybookJob extends Job {
  readonly type: "ansible_playbook";
  readonly arguments: AnsiblePlaybookJobProps;
}

export interface CheckoutCiJobProps extends JobArgT {
  readonly remote: string;
  readonly refname: string;
  readonly rev: string;

  readonly run: string;
  readonly returnPath: string;
}

export interface CheckoutCiJob extends Job {
  readonly type: "checkout_ci";
  readonly arguments: CheckoutCiJobProps;
}