@magda/scripts 2.3.3 → 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/acs-cmd/acs-cmd-admin-set.js +5 -4
- package/acs-cmd/acs-cmd-admin-unset.js +5 -4
- package/acs-cmd/acs-cmd-admin.js +3 -2
- package/acs-cmd/acs-cmd-assign-permission.js +5 -4
- package/acs-cmd/acs-cmd-assign-role.js +5 -4
- package/acs-cmd/acs-cmd-assign.js +3 -2
- package/acs-cmd/acs-cmd-create-operation.js +4 -3
- package/acs-cmd/acs-cmd-create-permission.js +4 -4
- package/acs-cmd/acs-cmd-create.js +3 -2
- package/acs-cmd/acs-cmd-jwt.js +4 -4
- package/acs-cmd/acs-cmd-list-permissions.js +5 -4
- package/acs-cmd/acs-cmd-list-resources.js +5 -4
- package/acs-cmd/acs-cmd-list-roles.js +5 -4
- package/acs-cmd/acs-cmd-list-users.js +5 -4
- package/acs-cmd/acs-cmd-list.js +3 -2
- package/acs-cmd/acs-cmd-remove-permission.js +5 -4
- package/acs-cmd/acs-cmd-remove-role.js +5 -4
- package/acs-cmd/acs-cmd-remove.js +3 -2
- package/acs-cmd/index.js +3 -2
- package/acs-cmd/utils.js +2 -5
- package/build-changed.js +8 -7
- package/check-release-version.js +6 -4
- package/create-api-key.js +7 -6
- package/create-docker-context-for-node-component.js +20 -15
- package/create-jwt-token.js +5 -5
- package/create-region-synonym-file.js +5 -5
- package/create-secrets/askQuestions.js +14 -20
- package/create-secrets/index.js +7 -6
- package/create-secrets/k8sExecution.js +9 -9
- package/create-secrets/preloadConfig.js +4 -4
- package/create-secrets/prompts/inquirer-fuzzy-path.js +9 -9
- package/create-secrets/prompts/list-with-transformer.js +5 -5
- package/create-secrets/pwgen.js +2 -2
- package/db/getDBConfig.js +1 -3
- package/db/getDBPool.js +3 -3
- package/docker-util.js +11 -11
- package/findLastModifiedFile.js +2 -2
- package/generate-api-documentation.js +7 -6
- package/generate-registry-typescript.js +5 -4
- package/getAllPackages.js +6 -2
- package/isScalaPackage.js +3 -3
- package/isTypeScriptPackage.js +4 -3
- package/loaders/remove-hashbag-loader.js +2 -2
- package/org-tree/getNodeIdFromNameOrId.js +2 -2
- package/org-tree/getUserIdFromNameOrId.js +2 -2
- package/org-tree/index.js +3 -2
- package/org-tree/org-tree-assign.js +7 -7
- package/org-tree/org-tree-create.js +5 -5
- package/org-tree/org-tree-delete.js +6 -6
- package/org-tree/org-tree-insert.js +6 -6
- package/org-tree/org-tree-move.js +6 -6
- package/org-tree/org-tree-unassign.js +5 -7
- package/org-tree/org-tree-view.js +5 -5
- package/package.json +15 -8
- package/retag-and-push.js +3 -8
- package/run-in-submodules.js +11 -9
- package/run-typescript-in-nodemon.js +6 -9
- package/set-scss-vars.js +1 -0
- package/tools/swagger-codegen-cli.jar +0 -0
- package/tools/swagger-codegen-cli.md +1 -1
- package/update-helm-chart-version.js +1 -0
- package/create-all-tsconfigs.js +0 -51
- package/create-pod-and-forward.js +0 -108
- package/generate-connector-jobs.js +0 -192
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const childProcess = require("child_process");
|
|
3
|
-
const process = require("process");
|
|
4
|
-
const yargs = require("yargs");
|
|
5
|
-
|
|
6
|
-
const argv = yargs
|
|
7
|
-
.options({
|
|
8
|
-
configuration: {
|
|
9
|
-
description: "The Kubernetes configuration to apply.",
|
|
10
|
-
type: "string",
|
|
11
|
-
demand: true
|
|
12
|
-
},
|
|
13
|
-
selector: {
|
|
14
|
-
description:
|
|
15
|
-
"The selector to use to find the pod to forward into, such as `service=combined-db`.",
|
|
16
|
-
type: "string",
|
|
17
|
-
demand: true
|
|
18
|
-
},
|
|
19
|
-
port: {
|
|
20
|
-
description: "The pod port to which to forward.",
|
|
21
|
-
type: "number",
|
|
22
|
-
demand: true
|
|
23
|
-
},
|
|
24
|
-
localPort: {
|
|
25
|
-
description:
|
|
26
|
-
"The local port to forward into the pod. If not specified, the local port is the same as the pod port.",
|
|
27
|
-
type: "number"
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
.help().argv;
|
|
31
|
-
|
|
32
|
-
const dockerEnvProcess = childProcess.execSync(
|
|
33
|
-
"minikube docker-env --shell bash",
|
|
34
|
-
{ encoding: "utf8" }
|
|
35
|
-
);
|
|
36
|
-
const dockerEnv = dockerEnvProcess
|
|
37
|
-
.split("\n")
|
|
38
|
-
.filter((line) => line.indexOf("export ") === 0)
|
|
39
|
-
.reduce(function (env, line) {
|
|
40
|
-
const match = /^export (\w+)="(.*)"$/.exec(line);
|
|
41
|
-
if (match) {
|
|
42
|
-
env[match[1]] = match[2];
|
|
43
|
-
}
|
|
44
|
-
return env;
|
|
45
|
-
}, {});
|
|
46
|
-
|
|
47
|
-
const env = Object.assign({}, process.env, dockerEnv);
|
|
48
|
-
|
|
49
|
-
childProcess.execSync("kubectl config use-context minikube", {
|
|
50
|
-
stdio: "inherit",
|
|
51
|
-
env: env
|
|
52
|
-
});
|
|
53
|
-
childProcess.execSync("yarn run docker-build-local", {
|
|
54
|
-
stdio: "inherit",
|
|
55
|
-
env: env
|
|
56
|
-
});
|
|
57
|
-
childProcess.execSync(`kubectl apply -f ${argv.configuration}`, {
|
|
58
|
-
stdio: "inherit",
|
|
59
|
-
env: env
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
console.log("Waiting for the pod to start...");
|
|
63
|
-
|
|
64
|
-
let status;
|
|
65
|
-
const endTime = Date.now() + 90 * 1000;
|
|
66
|
-
do {
|
|
67
|
-
status = childProcess
|
|
68
|
-
.execSync(
|
|
69
|
-
`kubectl get pods -l ${argv.selector} -o=custom-columns=NAME:.status.phase --no-headers`,
|
|
70
|
-
{ encoding: "utf8", env: env }
|
|
71
|
-
)
|
|
72
|
-
.trim();
|
|
73
|
-
} while (status !== "Running" && Date.now() < endTime);
|
|
74
|
-
|
|
75
|
-
if (status !== "Running") {
|
|
76
|
-
console.log(
|
|
77
|
-
`Pod failed to start within 90 seconds. The last status was: ${status}.`
|
|
78
|
-
);
|
|
79
|
-
process.exit(1);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
console.log("Pod is running!");
|
|
83
|
-
|
|
84
|
-
const podName = childProcess
|
|
85
|
-
.execSync(
|
|
86
|
-
`kubectl get pods -l ${argv.selector} -o=custom-columns=NAME:.metadata.name --no-headers`,
|
|
87
|
-
{ encoding: "utf8", env: env }
|
|
88
|
-
)
|
|
89
|
-
.trim();
|
|
90
|
-
const portSpec =
|
|
91
|
-
argv.localPort !== undefined
|
|
92
|
-
? `${argv.localPort}:${argv.port}`
|
|
93
|
-
: argv.port.toString();
|
|
94
|
-
const portForwardProcess = childProcess.spawn(
|
|
95
|
-
"kubectl",
|
|
96
|
-
["port-forward", podName, portSpec],
|
|
97
|
-
{
|
|
98
|
-
stdio: "inherit",
|
|
99
|
-
env: env,
|
|
100
|
-
shell: true
|
|
101
|
-
}
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
const logsProcess = childProcess.spawn("kubectl", ["logs", "-f", podName], {
|
|
105
|
-
stdio: "inherit",
|
|
106
|
-
env: env,
|
|
107
|
-
shell: true
|
|
108
|
-
});
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const fs = require("fs-extra");
|
|
3
|
-
const klawSync = require("klaw-sync");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const yargs = require("yargs");
|
|
6
|
-
|
|
7
|
-
const argv = yargs
|
|
8
|
-
.config()
|
|
9
|
-
.help()
|
|
10
|
-
.option("in", {
|
|
11
|
-
describe:
|
|
12
|
-
"The directory containing the connector configuration JSON files.",
|
|
13
|
-
type: "string",
|
|
14
|
-
demandOption: true
|
|
15
|
-
})
|
|
16
|
-
.option("out", {
|
|
17
|
-
describe:
|
|
18
|
-
"The directory in which to write the generated Kubernetes config files.",
|
|
19
|
-
type: "string",
|
|
20
|
-
demandOption: true
|
|
21
|
-
})
|
|
22
|
-
.option("local", {
|
|
23
|
-
describe:
|
|
24
|
-
"true to generate config files for a Minikube deployment with the registry on localhost:5000 and the version at latest. Otherwise, the default registry and the version in the connector's package.json are used.",
|
|
25
|
-
type: "boolean",
|
|
26
|
-
default: false
|
|
27
|
-
})
|
|
28
|
-
.option("prod", {
|
|
29
|
-
describe:
|
|
30
|
-
"Whether to use values appropriate for a dev cluster or a prod cluster",
|
|
31
|
-
type: "boolean",
|
|
32
|
-
default: false
|
|
33
|
-
})
|
|
34
|
-
.option("imageVersion", {
|
|
35
|
-
describe:
|
|
36
|
-
"Overrides the version of the image that will be given to the jobs. Defaults to 'latest' if 'local' is specified, otherwise it will match the version of this package.",
|
|
37
|
-
type: "string"
|
|
38
|
-
})
|
|
39
|
-
.option("imagePrefix", {
|
|
40
|
-
describe:
|
|
41
|
-
"Overrides the prefix for the image that will be given to the jobs. Defaults to 'localhost:5000/data61' if 'local' is specified, otherwise data61/",
|
|
42
|
-
type: "string"
|
|
43
|
-
}).argv;
|
|
44
|
-
|
|
45
|
-
fs.ensureDirSync(argv.out);
|
|
46
|
-
|
|
47
|
-
const files = klawSync(argv.in, { nodir: true });
|
|
48
|
-
files.forEach(function (connectorConfigFile) {
|
|
49
|
-
const configFile = JSON.parse(
|
|
50
|
-
fs.readFileSync(connectorConfigFile.path, "utf8")
|
|
51
|
-
);
|
|
52
|
-
const connectorPackageName = configFile.type;
|
|
53
|
-
const connectorPackagePath = path.join("..", connectorPackageName);
|
|
54
|
-
const connectorPackageJson = JSON.parse(
|
|
55
|
-
fs.readFileSync(path.join(connectorPackagePath, "package.json"), "utf8")
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
function getImageVersion() {
|
|
59
|
-
if (argv.imageVersion) {
|
|
60
|
-
return argv.imageVersion;
|
|
61
|
-
} else if (argv.local) {
|
|
62
|
-
return "latest";
|
|
63
|
-
} else {
|
|
64
|
-
return connectorPackageJson.version;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function getImagePrefix() {
|
|
69
|
-
if (argv.imagePrefix) {
|
|
70
|
-
return argv.imagePrefix;
|
|
71
|
-
} else if (argv.local) {
|
|
72
|
-
return "localhost:5000/data61/";
|
|
73
|
-
} else {
|
|
74
|
-
return "data61/";
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const image = getImagePrefix() + configFile.type + ":" + getImageVersion();
|
|
79
|
-
const prod = argv.prod;
|
|
80
|
-
|
|
81
|
-
const basename = path.basename(connectorConfigFile.path, ".json");
|
|
82
|
-
|
|
83
|
-
const jobSpec = {
|
|
84
|
-
template: {
|
|
85
|
-
metadata: {
|
|
86
|
-
name: "connector-" + basename
|
|
87
|
-
},
|
|
88
|
-
spec: {
|
|
89
|
-
containers: [
|
|
90
|
-
{
|
|
91
|
-
name: "connector-" + basename,
|
|
92
|
-
image: image,
|
|
93
|
-
command: [
|
|
94
|
-
"node",
|
|
95
|
-
"/usr/src/app/component/dist/index.js",
|
|
96
|
-
"--config",
|
|
97
|
-
"/etc/config/connector.json",
|
|
98
|
-
"--registryUrl",
|
|
99
|
-
"http://registry-api/v0"
|
|
100
|
-
],
|
|
101
|
-
imagePullPolicy: prod ? "IfNotPresent" : "Always",
|
|
102
|
-
resources: {
|
|
103
|
-
requests: {
|
|
104
|
-
cpu: prod ? "500m" : "500m",
|
|
105
|
-
memory: prod ? "500Mi" : "500Mi"
|
|
106
|
-
},
|
|
107
|
-
limits: {
|
|
108
|
-
cpu: prod ? "1000m" : "500m"
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
volumeMounts: [
|
|
112
|
-
{
|
|
113
|
-
mountPath: "/etc/config",
|
|
114
|
-
name: "config"
|
|
115
|
-
}
|
|
116
|
-
],
|
|
117
|
-
env: [
|
|
118
|
-
{
|
|
119
|
-
name: "USER_ID",
|
|
120
|
-
value: "00000000-0000-4000-8000-000000000000"
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
name: "JWT_SECRET",
|
|
124
|
-
valueFrom: {
|
|
125
|
-
secretKeyRef: {
|
|
126
|
-
name: "auth-secrets",
|
|
127
|
-
key: "jwt-secret"
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
]
|
|
132
|
-
}
|
|
133
|
-
],
|
|
134
|
-
restartPolicy: "OnFailure",
|
|
135
|
-
volumes: [
|
|
136
|
-
{
|
|
137
|
-
name: "config",
|
|
138
|
-
configMap: {
|
|
139
|
-
name: "connector-config",
|
|
140
|
-
items: [
|
|
141
|
-
{
|
|
142
|
-
key: path.basename(
|
|
143
|
-
connectorConfigFile.path
|
|
144
|
-
),
|
|
145
|
-
path: "connector.json"
|
|
146
|
-
}
|
|
147
|
-
]
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
]
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
const job = {
|
|
156
|
-
apiVersion: "batch/v1",
|
|
157
|
-
kind: "Job",
|
|
158
|
-
metadata: {
|
|
159
|
-
name: "connector-" + basename
|
|
160
|
-
},
|
|
161
|
-
spec: jobSpec
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
fs.writeFileSync(
|
|
165
|
-
path.join(argv.out, "connector-" + basename + ".json"),
|
|
166
|
-
JSON.stringify(job, undefined, " "),
|
|
167
|
-
"utf8"
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
const cron = {
|
|
171
|
-
apiVersion: "batch/v1",
|
|
172
|
-
kind: "CronJob",
|
|
173
|
-
metadata: {
|
|
174
|
-
name: "connector-" + basename
|
|
175
|
-
},
|
|
176
|
-
spec: {
|
|
177
|
-
schedule:
|
|
178
|
-
configFile.schedule && prod
|
|
179
|
-
? configFile.schedule
|
|
180
|
-
: "0 14 * * 6", // 12am Sydney time on Sunday
|
|
181
|
-
jobTemplate: {
|
|
182
|
-
spec: jobSpec
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
fs.writeFileSync(
|
|
188
|
-
path.join(argv.out, "connector-" + basename + "-cron.json"),
|
|
189
|
-
JSON.stringify(cron, undefined, " "),
|
|
190
|
-
"utf8"
|
|
191
|
-
);
|
|
192
|
-
});
|