summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDan Duvall <dduvall@wikimedia.org>2018-09-19 11:06:46 -0700
committerDan Duvall <dduvall@wikimedia.org>2018-12-12 15:02:22 -0800
commit4df63a83c93ba0f591eb78110e184bfef0f76535 (patch)
tree9a0c97f54432cf7ecb30ff910d5f514b51f02ed9 /scripts
parent3da9f201cad3b09b4e7d70dcaf023c70b4bcc026 (diff)
downloadblubber-4df63a83c93ba0f591eb78110e184bfef0f76535.tar.gz
Provide OpenAPI spec for Blubberoid
Wrote an OpenAPI 3.0 spec for Blubberoid that provides `x-amples` entries compatible with service-checker. The written spec includes basic schema for Blubber config objects that may be later factored out for use in validation. Note that OpenAPI 3.0 supports only the v4 draft of the JSON Schema standard, so some parts of the configuration could not be fully described. Specifically, v4 does not include the `patternProperties` definition introduced in the JSON Schema v6 draft that would allow us to describe `variants` and `runs.environment` and everything beneath. Blubberoid was refactored slightly to incorporate the new spec as well as assume JSON as the canonical and default configuration format. It was also refactored to include a versioned namespace ("v1") after the server endpoint. Bug: T205920 Change-Id: I28a341aa503b8920d802715660d4c4d62be45475
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generate-const.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/scripts/generate-const.sh b/scripts/generate-const.sh
new file mode 100755
index 0000000..f049389
--- /dev/null
+++ b/scripts/generate-const.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+#
+# Generates a Go const from the contents of a static file, and appends it at
+# the line following the go:generate directive that calls this script.
+#
+set -euo pipefail
+
+sed -i.sed.bak -e "$((GOLINE+1)),\$d" "$GOFILE"
+rm "$GOFILE.sed.bak"
+
+(echo -n "const $1 = \`"; cat "$2"; echo "\`") >> "$GOFILE"