From e41324eb7bc680991ebc2bb0e02e8dea7b07e6ea Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Wed, 2 Feb 2022 20:47:39 +0900 Subject: [PATCH] Remove unused message types The buildrequest, distrequest, mergerequest, signrequest, and testrequest messages are not used in the new message architecture and can be removed. This commit removes the specs and implementations of the unused message types. --- include/msg.sh | 49 ++++++++------------- include/msg/buildrequest.sh | 72 ------------------------------ include/msg/distrequest.sh | 81 ---------------------------------- include/msg/mergerequest.sh | 88 ------------------------------------- include/msg/signrequest.sh | 79 --------------------------------- include/msg/testrequest.sh | 73 ------------------------------ spec/buildrequest.json | 29 ------------ spec/distrequest.json | 39 ---------------- spec/mergerequest.json | 35 --------------- spec/signrequest.json | 50 --------------------- spec/testrequest.json | 29 ------------ 11 files changed, 19 insertions(+), 605 deletions(-) delete mode 100644 include/msg/buildrequest.sh delete mode 100644 include/msg/distrequest.sh delete mode 100644 include/msg/mergerequest.sh delete mode 100644 include/msg/signrequest.sh delete mode 100644 include/msg/testrequest.sh delete mode 100644 spec/buildrequest.json delete mode 100644 spec/distrequest.json delete mode 100644 spec/mergerequest.json delete mode 100644 spec/signrequest.json delete mode 100644 spec/testrequest.json diff --git a/include/msg.sh b/include/msg.sh index 664a225..d0f9b24 100644 --- a/include/msg.sh +++ b/include/msg.sh @@ -4,21 +4,20 @@ __init() { 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 @@ -27,30 +26,20 @@ __init() { 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 } diff --git a/include/msg/buildrequest.sh b/include/msg/buildrequest.sh deleted file mode 100644 index d3e8e44..0000000 --- a/include/msg/buildrequest.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/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 -} diff --git a/include/msg/distrequest.sh b/include/msg/distrequest.sh deleted file mode 100644 index 9a5cbfa..0000000 --- a/include/msg/distrequest.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/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 -} diff --git a/include/msg/mergerequest.sh b/include/msg/mergerequest.sh deleted file mode 100644 index 697f32c..0000000 --- a/include/msg/mergerequest.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/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 -} diff --git a/include/msg/signrequest.sh b/include/msg/signrequest.sh deleted file mode 100644 index 93c5260..0000000 --- a/include/msg/signrequest.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/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 -} diff --git a/include/msg/testrequest.sh b/include/msg/testrequest.sh deleted file mode 100644 index fb84c7c..0000000 --- a/include/msg/testrequest.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/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 -} diff --git a/spec/buildrequest.json b/spec/buildrequest.json deleted file mode 100644 index 1bab4e4..0000000 --- a/spec/buildrequest.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "$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" - ] -} diff --git a/spec/distrequest.json b/spec/distrequest.json deleted file mode 100644 index b86724f..0000000 --- a/spec/distrequest.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "$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" - ] -} diff --git a/spec/mergerequest.json b/spec/mergerequest.json deleted file mode 100644 index d7c489b..0000000 --- a/spec/mergerequest.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "$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" - ] -} diff --git a/spec/signrequest.json b/spec/signrequest.json deleted file mode 100644 index f5034d0..0000000 --- a/spec/signrequest.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "$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" - } - } - } -} diff --git a/spec/testrequest.json b/spec/testrequest.json deleted file mode 100644 index ceb533f..0000000 --- a/spec/testrequest.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "$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" - ] -} -- 2.47.3