Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
# Copied from https://get.qovery.com/
# Adapted with https://github.com/Qovery/qovery-cli/issues/159 to support ARM
# Stored in the repo because we don't like to "curl | bash"
set -e
set +x
echo "##################################"
class Poetry < Formula
include Language::Python::Virtualenv
desc "Python package management tool"
homepage "https://python-poetry.org/"
url "https://files.pythonhosted.org/packages/e0/c8/09e126761651e291ab54db1b1d6983c64a1cf67b8b25ce9c806db23e16ab/poetry-1.1.15.tar.gz"
sha256 "a373848fd205f31b2f6bee6b87a201ea1e09ca573a2f40d0991539f564cedffd"
license "MIT"
head "https://github.com/python-poetry/poetry.git", branch: "master"
gp() {
current_branch=$(git rev-parse --abbrev-ref HEAD)
if echo "$current_branch" | grep -qE '^(master|main|devel)$'; then
read "answer?You're about to push to a MAIN branch, are you sure? [y/N] "
if ! echo "$answer" | grep -qE '^y'; then
echo "aborting..."
return
fi
fi
git push origin HEAD
def pod_status_from_spec(spec)
# translated from: https://github.com/kubernetes/kubernetes/blob/a9f6b93b62a98598913180c640ab044c85a6718b/pkg/printers/internalversion/printers.go#L695-L781
# related issue: https://github.com/kubernetes/kubernetes/issues/22839
metadata = spec.fetch("metadata")
pod_status = spec.fetch("status")
reason = pod_status.fetch("phase")
restarts = 0
if pod_status["reason"]
# unsure about this, the go code is opaque
class PirateForm(ModelForm):
class Meta:
model = Pirate
fields = ("name", "is_captain")
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.cleanup_missing_keys(kwargs.get("data"))
def cleanup_missing_keys(self, data):
{% if user.name == "Alice" %}
<input type=hidden name=is_captain value=false>
<input type=checkbox name=is_captain id=id_is_captain {% if object.is_captain %}checked{% endif %}>
{% else %}
{{ object.is_captain|yesno:"Yes,No" }} <i>(must be admin to edit)</i>
{% endif %}
...
{% if form.can_edit_captain_field() %}
<input type=checkbox name=is_captain id=id_is_captain {% if object.is_captain %}checked{% endif %}>
{% else %}
...
{# Keep this condition in sync with PirateForm #}
{% if user.name == "Alice" %}
<input type=checkbox name=is_captain id=id_is_captain {% if object.is_captain %}checked{% endif %}>
{% else %}
<p>
{{ form.name.errors }}
<label for=id_name>Name:</label>
{{ form.name }}
</p>
<p>
{{ form.is_captain.errors }}
<label for=id_is_captain>Is Captain?:</label>
{% if user.name == "Alice" %}
<input type=checkbox name=is_captain id=id_is_captain {% if object.is_captain %}checked{% endif %}>