-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
546 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import yargs from "yargs"; | ||
import { hideBin } from "yargs/helpers"; | ||
|
||
const argv = yargs(hideBin(process.argv)) | ||
.option("deploy-api", { | ||
description: "Deploy API base path", | ||
}) | ||
.option("subscription-id", { | ||
type: "string", | ||
required: true, | ||
}) | ||
.option("resource-group", { | ||
type: "string", | ||
required: true, | ||
}) | ||
.option("server-name", { | ||
type: "string", | ||
required: true, | ||
}) | ||
.option("key-vault-name", { | ||
type: "string", | ||
required: true, | ||
}) | ||
.option("user", { | ||
type: "string", | ||
required: true, | ||
}) | ||
.option("database", { | ||
type: "string", | ||
required: true, | ||
}) | ||
.option("role-prefix", { | ||
type: "string", | ||
required: true, | ||
}) | ||
.option("schema", { | ||
type: "array", | ||
required: true, | ||
}) | ||
.parse(); | ||
|
||
const request = { | ||
resources: { | ||
subscriptionId: argv.subscriptionId, | ||
resourceGroup: argv.resourceGroup, | ||
serverName: argv.serverName, | ||
keyVaultName: argv.keyVaultName, | ||
user: argv.user, | ||
}, | ||
databaseName: argv.database, | ||
userPrefix: argv.rolePrefix, | ||
schemas: Object.fromEntries(argv.schema.map((n) => [n, {}])), | ||
}; | ||
|
||
// console.log(request); | ||
// process.exit(1); | ||
|
||
const baseUrl = new URL(argv.deployApi); | ||
if (baseUrl.protocol === "http:") { | ||
baseUrl.protocol = "ws:"; | ||
} else if (baseUrl.protocol === "https:") { | ||
baseUrl.protocol = "wss:"; | ||
} else { | ||
throw new Error(`Unsupported protocol: ${baseUrl.protocol}`); | ||
} | ||
|
||
const ws = new WebSocket( | ||
new URL("api/v1/database/bootstrap", baseUrl), | ||
"altinn.task-pipeline" | ||
); | ||
|
||
let pending = Promise.resolve(); | ||
|
||
const write = (data: Blob) => { | ||
const buffer = data.arrayBuffer(); | ||
pending = pending | ||
.then(() => buffer) | ||
.then((buffer) => { | ||
var arr = new Uint8Array(buffer); | ||
process.stderr.write(arr); | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); | ||
}; | ||
|
||
ws.addEventListener("open", (e) => { | ||
ws.send(JSON.stringify(request)); | ||
}); | ||
|
||
ws.addEventListener("message", (ev) => { | ||
write(ev.data); | ||
}); | ||
|
||
ws.addEventListener("close", (ev) => { | ||
console.log("closed", ev.code, ev.reason); | ||
ws.close(); | ||
|
||
if (ev.code !== 4000) { | ||
process.exit(1); | ||
} | ||
}); | ||
|
||
ws.addEventListener("error", (ev) => { | ||
if (ev && "message" in ev) { | ||
console.error("error", ev.message); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { verticals } from "./_meta.mts"; | ||
import * as actions from "@actions/core"; | ||
import yargs from "yargs"; | ||
import { hideBin } from "yargs/helpers"; | ||
|
||
const argv = yargs(hideBin(process.argv)) | ||
.option("type", { | ||
type: "array", | ||
required: true, | ||
}) | ||
.parse(); | ||
|
||
let output = verticals; | ||
if (argv.type) { | ||
output = verticals.filter((v) => argv.type.includes(v.type)); | ||
} | ||
|
||
const paths = output.map((v) => v.relPath); | ||
var matrix = { | ||
shortName: output.map((v) => v.shortName), | ||
include: output.map((v) => { | ||
const ret: Record<string, string> = { | ||
path: v.relPath, | ||
name: v.name, | ||
shortName: v.shortName, | ||
type: v.type, | ||
}; | ||
|
||
if (v.image && v.image.name) { | ||
ret.imageName = v.image.name; | ||
} | ||
|
||
return ret; | ||
}), | ||
}; | ||
|
||
actions.setOutput("matrix", JSON.stringify(matrix)); | ||
actions.setOutput("verticals", JSON.stringify(paths)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.