Skip to content

Commit

Permalink
fix: fix creating a release (error messages and sh) (#1454)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguel-crespo-fdc authored Mar 20, 2024
1 parent 980066e commit 0f33ef5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
19 changes: 12 additions & 7 deletions infrastructure/scripts/create-testdata/create-release.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash
set -eu
set -o pipefail
#set -x

# usage
# ./create-release.sh my-service-name [my-team-name]
Expand Down Expand Up @@ -98,18 +97,24 @@ else
AUTHOR=$(echo -n "script-user" | base64 -w 0)
fi

inputs=()
inputs+=(--form-string "application=$name")
inputs+=(--form-string "source_commit_id=$commit_id")
inputs+=(--form-string "source_author=$author")

if [ "$prev" != "" ];
then
inputs+=(--form-string "previous_commit_id=${prev}")
fi

curl http://localhost:${FRONTEND_PORT}/release \
-H "author-email:${EMAIL}" \
-H "author-name:${AUTHOR}=" \
--form-string "application=$name" \
--form-string "source_commit_id=${commit_id}" \
--form-string "source_author=${author}" \
--form-string "previous_commit_id=${prev}" \
"${inputs[@]}" \
${release_version} \
--form-string "display_version=${displayVersion}" \
--form "source_message=<${commit_message_file}" \
"${configuration[@]}" \
"${manifests[@]}" -v

echo # curl sometimes does not print a trailing \n

echo # curl sometimes does not print a trailing \n
12 changes: 7 additions & 5 deletions services/frontend-service/pkg/handler/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,15 @@ func (s Server) HandleRelease(w http.ResponseWriter, r *http.Request, tail strin
}

if previousCommitId, ok := form.Value["previous_commit_id"]; ok {
if len(previousCommitId) == 1 && isCommitId(previousCommitId[0]) {
tf.PreviousCommitId = previousCommitId[0]
} else {
if len(previousCommitId) != 1 {
w.WriteHeader(400)
fmt.Fprintf(w, "Too many previous commits provided.")
return
fmt.Fprintf(w, "Invalid number of previous commit IDs provided. Expecting 1, got %d", len(previousCommitId))
}
if !isCommitId(previousCommitId[0]) {
w.WriteHeader(400)
fmt.Fprintf(w, "Provided commit id (%s) is not valid.", previousCommitId[0])
}
tf.PreviousCommitId = previousCommitId[0]
}

if sourceAuthor, ok := form.Value["source_author"]; ok {
Expand Down

0 comments on commit 0f33ef5

Please sign in to comment.