local submodules
local deps
- submodules=("foundry/msg/artifact"
- "foundry/msg/buildrequest"
- "foundry/msg/build"
- "foundry/msg/commit"
- "foundry/msg/distrequest"
- "foundry/msg/dist"
- "foundry/msg/mergerequest"
- "foundry/msg/merge"
- "foundry/msg/signrequest"
- "foundry/msg/sign"
- "foundry/msg/testrequest"
- "foundry/msg/test")
-
- deps=("ipc"
- "json")
+ submodules=(
+ "foundry/msg/artifact"
+ "foundry/msg/build"
+ "foundry/msg/commit"
+ "foundry/msg/dist"
+ "foundry/msg/merge"
+ "foundry/msg/sign"
+ "foundry/msg/test"
+ )
+
+ deps=(
+ "ipc"
+ "json"
+ )
if ! include "${submodules[@]}" "${deps[@]}"; then
return 1
declare -gxir __foundry_msg_version=1
declare -gxir __foundry_msg_type_build=1
- declare -gxir __foundry_msg_type_buildrequest=2
- declare -gxir __foundry_msg_type_commit=3
- declare -gxir __foundry_msg_type_dist=4
- declare -gxir __foundry_msg_type_distrequest=5
- declare -gxir __foundry_msg_type_merge=6
- declare -gxir __foundry_msg_type_mergerequest=7
- declare -gxir __foundry_msg_type_sign=8
- declare -gxir __foundry_msg_type_signrequest=9
- declare -gxir __foundry_msg_type_test=10
- declare -gxir __foundry_msg_type_testrequest=11
+ declare -gxir __foundry_msg_type_commit=2
+ declare -gxir __foundry_msg_type_dist=3
+ declare -gxir __foundry_msg_type_merge=4
+ declare -gxir __foundry_msg_type_sign=5
+ declare -gxir __foundry_msg_type_test=6
declare -gxA __foundry_msg_typemap
__foundry_msg_typemap["build"]="$__foundry_msg_type_build"
- __foundry_msg_typemap["buildrequest"]="$__foundry_msg_type_buildrequest"
__foundry_msg_typemap["commit"]="$__foundry_msg_type_commit"
__foundry_msg_typemap["dist"]="$__foundry_msg_type_dist"
- __foundry_msg_typemap["distrequest"]="$__foundry_msg_type_distrequest"
__foundry_msg_typemap["merge"]="$__foundry_msg_type_merge"
- __foundry_msg_typemap["mergerequest"]="$__foundry_msg_type_mergerequest"
__foundry_msg_typemap["sign"]="$__foundry_msg_type_sign"
- __foundry_msg_typemap["signrequest"]="$__foundry_msg_type_signrequest"
__foundry_msg_typemap["test"]="$__foundry_msg_type_test"
- __foundry_msg_typemap["testrequest"]="$__foundry_msg_type_testrequest"
return 0
}
+++ /dev/null
-#!/bin/bash
-
-__init() {
- if ! include "json"; then
- return 1
- fi
-
- declare -gxr __foundry_msg_buildrequest_msgtype="buildrequest"
-
- return 0
-}
-
-foundry_msg_buildrequest_new() {
- local context="$1"
- local repository="$2"
- local branch="$3"
-
- local json
- local msg
-
- if ! json=$(json_object "context" "$context" \
- "repository" "$repository" \
- "branch" "$branch"); then
- return 1
- fi
-
- if ! msg=$(foundry_msg_new "$__foundry_msg_buildrequest_msgtype" "$json"); then
- return 1
- fi
-
- echo "$msg"
- return 0
-}
-
-foundry_msg_buildrequest_get_context() {
- local msg="$1"
-
- local context
-
- if ! context=$(foundry_msg_get_data_field "$msg" "context"); then
- return 1
- fi
-
- echo "$context"
- return 0
-}
-
-foundry_msg_buildrequest_get_repository() {
- local msg="$1"
-
- local repository
-
- if ! repository=$(foundry_msg_get_data_field "$msg" "repository"); then
- return 1
- fi
-
- echo "$repository"
- return 0
-}
-
-foundry_msg_buildrequest_get_branch() {
- local msg="$1"
-
- local branch
-
- if ! branch=$(foundry_msg_get_data_field "$msg" "branch"); then
- return 1
- fi
-
- echo "$branch"
- return 0
-}
+++ /dev/null
-#!/bin/bash
-
-__init() {
- if ! include "json"; then
- return 1
- fi
-
- declare -gxr __foundry_msg_distrequest_msgtype="distrequest"
-
- return 0
-}
-
-foundry_msg_distrequest_new() {
- local context="$1"
- local artifacts=("${@:2}")
-
- local artifacts_json
- local json
- local msg
-
- if ! artifacts_json=$(json_array "${artifacts[@]}"); then
- return 1
- fi
-
- if ! json=$(json_object "context" "$context" \
- "artifacts" "$artifacts_json"); then
- return 1
- fi
-
- if ! msg=$(foundry_msg_new "$__foundry_msg_distrequest_msgtype" "$json"); then
- return 1
- fi
-
- echo "$msg"
- return 0
-}
-
-foundry_msg_distrequest_get_context() {
- local distrequest="$1"
-
- local context
-
- if ! context=$(foundry_msg_get_data_field "$distrequest" "context"); then
- return 1
- fi
-
- echo "$context"
- return 0
-}
-
-foundry_msg_distrequest_get_artifacts() {
- local distrequest="$1"
-
- local raw_artifacts
- local artifacts
- local artifact
- local checksum
- local uri
- local query
-
- query='artifacts[] | "\(.checksum) \(.uri)"'
-
- if ! raw_artifacts=$(foundry_msg_get_data_field "$distrequest" \
- "$query"); then
- return 1
- fi
-
- while read -r checksum uri; do
- if ! artifact=$(foundry_msg_artifact_new "$uri" "$checksum"); then
- return 1
- fi
-
- artifacts+=("$artifact")
- done <<< "$raw_artifacts"
-
- for artifact in "${artifacts[@]}"; do
- echo "$artifact"
- done
-
- return 0
-}
+++ /dev/null
-#!/bin/bash
-
-__init() {
- if ! include "json"; then
- return 1
- fi
-
- declare -gxr __foundry_msg_mergerequest_msgtype="mergerequest"
-
- return 0
-}
-
-foundry_msg_mergerequest_new() {
- local context="$1"
- local repository="$2"
- local srcbranch="$3"
- local dstbranch="$4"
-
- local json
- local msg
-
- if ! json=$(json_object "context" "$context" \
- "repository" "$repository" \
- "source_branch" "$srcbranch" \
- "destination_branch" "$dstbranch"); then
- return 1
- fi
-
- if ! msg=$(foundry_msg_new "$__foundry_msg_mergerequest_msgtype" \
- "$json"); then
- return 1
- fi
-
- echo "$msg"
- return 0
-}
-
-foundry_msg_mergerequest_get_context() {
- local msg="$1"
-
- local context
-
- if ! context=$(foundry_msg_get_data_field "$msg" "context"); then
- return 1
- fi
-
- echo "$context"
- return 0
-}
-
-foundry_msg_mergerequest_get_repository() {
- local msg="$1"
-
- local repository
-
- if ! repository=$(foundry_msg_get_data_field "$msg" "repository"); then
- return 1
- fi
-
- echo "$repository"
- return 0
-}
-
-foundry_msg_mergerequest_get_source_branch() {
- local msg="$1"
-
- local srcbranch
-
- if ! srcbranch=$(foundry_msg_get_data_field "$msg" "source_branch"); then
- return 1
- fi
-
- echo "$srcbranch"
- return 0
-}
-
-foundry_msg_mergerequest_get_destination_branch() {
- local msg="$1"
-
- local dstbranch
-
- if ! dstbranch=$(foundry_msg_get_data_field "$msg" "destination_branch"); then
- return 1
- fi
-
- echo "$dstbranch"
- return 0
-}
+++ /dev/null
-#!/bin/bash
-
-__init() {
- if ! include "json" "foundry/msg/artifact"; then
- return 1
- fi
-
- declare -gxr __foundry_msg_signrequest_msgtype="signrequest"
-
- return 0
-}
-
-foundry_msg_signrequest_new() {
- local context="$1"
- local artifacts=("${@:2}")
-
- local artifacts_json
- local json
- local msg
-
- if ! artifacts_json=$(json_array "${artifacts[@]}"); then
- return 1
- fi
-
- if ! json=$(json_object "context" "$context" \
- "artifacts" "$artifacts_json"); then
- return 1
- fi
-
- if ! msg=$(foundry_msg_new "$__foundry_msg_signrequest_msgtype" "$json"); then
- return 1
- fi
-
- echo "$msg"
- return 0
-}
-
-foundry_msg_signrequest_get_context() {
- local signrequest="$1"
-
- local context
-
- if ! context=$(foundry_msg_get_data_field "$signrequest" "context"); then
- return 1
- fi
-
- echo "$context"
- return 0
-}
-
-foundry_msg_signrequest_get_artifacts() {
- local signrequest="$1"
-
- local query
- local raw_artifacts
- local artifacts
- local checksum
- local uri
-
- query='artifacts[] | "\(.checksum) \(.uri)"'
- artifacts=()
-
- if ! raw_artifacts=$(foundry_msg_get_data_field "$signrequest" "$query"); then
- return 1
- fi
-
- while read -r checksum uri; do
- local artifact
-
- if ! artifact=$(foundry_msg_artifact_new "$uri" "$checksum"); then
- return 1
- fi
-
- artifacts+=("$artifact")
- done <<< "$raw_artifacts"
-
- array_to_lines "${artifacts[@]}"
- return 0
-}
+++ /dev/null
-#!/bin/bash
-
-__init() {
- if ! include "json"; then
- return 1
- fi
-
- declare -gxr __foundry_msg_testrequest_msgtype="testrequest"
-
- return 0
-}
-
-foundry_msg_testrequest_new() {
- local context="$1"
- local repository="$2"
- local branch="$3"
-
- local json
- local msg
-
- if ! json=$(json_object "context" "$context" \
- "repository" "$repository" \
- "branch" "$branch"); then
- return 1
- fi
-
- if ! msg=$(foundry_msg_new "$__foundry_msg_testrequest_msgtype" "$json"); then
- return 1
- fi
-
- echo "$msg"
- return 0
-}
-
-foundry_msg_testrequest_get_context() {
- local msg="$1"
-
- local context
-
- if ! context=$(foundry_msg_get_data_field "$msg" "context"); then
- return 1
- fi
-
- echo "$context"
- return 0
-}
-
-
-foundry_msg_testrequest_get_repository() {
- local msg="$1"
-
- local repository
-
- if ! repository=$(foundry_msg_get_data_field "$msg" "repository"); then
- return 1
- fi
-
- echo "$repository"
- return 0
-}
-
-foundry_msg_testrequest_get_branch() {
- local msg="$1"
-
- local branch
-
- if ! branch=$(foundry_msg_get_data_field "$msg" "branch"); then
- return 1
- fi
-
- echo "$branch"
- return 0
-}
+++ /dev/null
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "$id": "https://m10k.eu/foundry/msg.buildrequest.json",
- "title": "Foundry BuildRequest Message",
- "type": "object",
-
- "properties": {
- "context": {
- "description": "Context identifier of this transaction",
- "type": "string"
- },
-
- "repository": {
- "description": "URL of the repository where the code to be built is located",
- "type": "string"
- },
-
- "branch": {
- "description": "Name of the branch that contains the commit to be built",
- "type": "string"
- }
- },
-
- "required": [
- "context",
- "repository",
- "branch"
- ]
-}
+++ /dev/null
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "$id": "https://m10k.eu/foundry/msg.distrequest.json",
- "title": "Foundry DistRequest Message",
- "type": "object",
-
- "properties": {
- "context": {
- "description": "Context identifier of this transaction",
- "type": "string"
- },
-
- "repository": {
- "description": "URL of the source tree the artifacts were built from",
- "type": "string"
- },
-
- "branch": {
- "description": "Name of the branch the artifacts were built from",
- "type": "string"
- },
-
- "artifacts": {
- "description": "List of artifacts built from the source tree",
- "type": "array",
- "items": {
- "type": "string"
- },
- "minItems": 1
- }
- },
-
- "required": [
- "context",
- "repository",
- "branch",
- "artifacts"
- ]
-}
+++ /dev/null
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "$id": "https://m10k.eu/foundry/msg.mergerequest.json",
- "title": "Foundry MergeRequst Message",
- "type": "object",
-
- "properties": {
- "context": {
- "description": "Context identifier of this transaction",
- "type": "string"
- },
-
- "repository": {
- "description": "URL of the repository containing the code to be tested",
- "type": "string"
- },
-
- "source-branch": {
- "description": "Name of the source for the merge operation",
- "type": "string"
- },
-
- "destination-branch": {
- "description": "Name of the destination for the merge operation",
- "type": "string"
- }
- },
-
- "required": [
- "context",
- "repository",
- "source-branch",
- "destination-branch"
- ]
-}
+++ /dev/null
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "$id": "https://m10k.eu/foundry/msg.signrequest.json",
- "title": "Foundry SignRequest Message",
- "type": "object",
-
- "properties": {
- "context": {
- "description": "Context identifier of this transaction",
- "type": "string"
- },
-
- "artifacts": {
- "description": "The artifacts to be signed",
- "type": "array",
- "items": {
- "type": "#/$defs/artifact"
- },
- "minItems": 1
- }
- },
-
- "required": [
- "context",
- "artifacts"
- ],
-
- "$defs": {
- "artifact": {
- "type": "object",
-
- "properties": {
- "uri": {
- "description": "URI of the artifact",
- "type": "string"
- },
- "checksum": {
- "description": "hex-encoded sha512 checksum of the artifact",
- "type": "string",
- "pattern": "^[0-9a-fA-F]{128}$"
- }
- },
-
- "required": [
- "uri",
- "checksum"
- }
- }
- }
-}
+++ /dev/null
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "$id": "https://m10k.eu/foundry/msg.testrequest.json",
- "title": "Foundry TestRequest Message",
- "type": "object",
-
- "properties": {
- "context": {
- "description": "Context identifier of this transaction",
- "type": "string"
- },
-
- "repository": {
- "description": "URL of the repository containing the code to be tested",
- "type": "string"
- },
-
- "branch": {
- "description": "Name of the branch containing the commit to be tested",
- "type": "string"
- }
- },
-
- "required": [
- "context",
- "repository",
- "branch"
- ]
-}