#!/bin/env bash
set -xe # Don't continue if first command fail

docker run \
    --rm \
    --user=$UID \
    --network=host \
    -v ${PWD}:/local \
    swaggerapi/swagger-codegen-cli:2.4.18 \
        generate -i http://localhost:49618/swagger/swagger.json -l go -o /local/api-client/oc-catalog.bak

if [ -d api-client/oc-catalog.bak ]; then
    rm -r api-client/oc-catalog
    mv api-client/oc-catalog.bak api-client/oc-catalog
fi
