How to curl to plantuml-server

0 votes
asked Nov 25, 2020 in Question / help by bryanhuntesl (120 points)
edited Nov 27, 2020 by bryanhuntesl
Pretty basic question - and forgive my ignorance, I've hunted around and can't see clearly how people are doing this.

I want to run a curl command like so

INPUT -> curl -> plantuml local server -> PNG (stdout) -> filesystem

So, ideally it would be something like :

cat ./my-beautiful-diagram.puml |  curl -v -H "Content-Type: text/plain" --data-binary @- http://localhost:8080/ihaventacluewhaturlorparamstouse/ > my-beautiful-diagram.png

Can anyone suggest a good place to get this information?

Thanks,

Bryan

--->

Update - I've figured it out - and it's very simple but might as well leave this post up in case someone else goes looking

cat ../my-beautiful-diagram.puml |  curl -v -H "Content-Type: text/plain" --data-binary @- http://localhost:8080/png/ --output - > /tmp/out.png
commented Nov 27, 2020 by bryanhuntesl (120 points)

In case anyone is interested I used it in a CI setup like so :

#!/bin/bash

set -e

target=${1:?needs target dir argument}
mkdir -p $target
base_commit=$(git log -n 1 --pretty=format:%h)
find uml -type f -name '*.puml' | while read f
do
    hash="$( git log -n 1 --pretty=format:%h -- ${f})"
    d=$(dirname $f)
    if [ "$base_commit" == "$hash" ] ; then
        echo "$f changed in this commit - regenerating"
        mkdir -p $target/$d
        destfile=${f%%.puml}.png
        cat ${f} |  curl --silent --show-error --fail   -H "Content-Type: text/plain" --data-binary @- http://localhost:8080/png/ --output - > "${target}/${destfile}"
    else
        echo "$f not changed in this commit - no need to generate"
    fi
done

manifest=$target/all-images.md
test -f $manifest && rm $manifest
find $target -name '*.png' | while read f
do
    echo "* [${f##${target}}](${f##${target}/})" >> $manifest
done

commented Jan 30, 2023 by Topper Harley
Thanks so much, this saved me a lot of time.

1 Answer

0 votes
answered Jan 15, 2022 by MaLo
Should this only work for local plantuml-server or also with plantuml.com service? Can't get it running...
...