This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Prints a PlantUML diagram that shows the DAG of the GitLab pipeline""" | |
import sys | |
import yaml | |
from pprint import pprint | |
def merge(user, default): | |
if isinstance(user,dict) and isinstance(default,dict): | |
for k,v in default.items(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set +e | |
result="$(kubectl patch "$@")" | |
code="$?" | |
if [[ "$code" != "0" && "$result" == "* not patched" ]]; then | |
echo "$result" 1>&2 | |
exit "$code" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
while true; do | |
# API call to GoCD to retrieve list of agents + status | |
OUTPUT="$(curl -s "${GOCD_URL}/api/agents" -u "${GOCD_USERNAME}:${GOCD_PASSWORD}" -H 'Accept: application/vnd.go.cd.v4+json')" | |
# Extract the status of the the current agent from the returned JSON using jq | |
CUR_STATE="$(echo "${OUTPUT}" | jq -r "._embedded.agents[] | select(.hostname == \"${HOSTNAME}\") | .build_state")" | |
if [[ "${CUR_STATE}" == "Building" ]] && ! [[ "${CUR_STATE}" == "${PREV_STATE}" ]]; then # if the agent's state has changed from something to Building, protect the instance | |
aws autoscaling set-instance-protection --region "${EC2_REGION}" --instance-ids "${INSTANCE_ID}" --auto-scaling-group-name "${ASG_NAME}" --protected-from-scale-in & | |
elif [[ "${PREV_STATE}" == "Building" ]] && ! [[ "${CUR_STATE}" == "${PREV_STATE}" ]]; then # if the agent's state has changed from Building to something else, unprotect it | |
aws autoscaling set-instance-protection --region "${ |