{% if not embedded -%}
{% include "bash.sh.j2" %}
{% endif %}

{% macro yq(cache_only=False) -%}
version=$(curl -s https://api.github.com/repos/mikefarah/yq/releases/latest | grep tag_name | cut -d: -f2 | tr -d 'v," ')
echo $version
wget --quiet --timestamping https://github.com/mikefarah/yq/releases/download/v${version}/yq_linux_amd64
tar -f archive.tar -r yq_linux_amd64
{% if not cache_only -%}
sudo install --mode 0755 --owner root --group root yq_linux_amd64 /usr/local/bin/yq
sudo chmod +x /usr/local/bin/yq
yq --version
{% endif %}
{% endmacro %}

{% block content %}{{ yq(cache_only) }} {% endblock %}
