This script takes two URLs, the permalink URL for a hub profile, and a user-direct URL (e.g. an nbgitpuller URL), and fuses them together.
python ./permalink.py <USER-URL> <PERMALINK-URL>The output is the fixed URL.
| #!/usr/bin/env bash | |
| : "${nodegroup:?Need nodegroup}" | |
| : "${region:?Need region}" | |
| : "${cluster:?Need cluster}" | |
| # Get the autoscaling group name from the EKS node pool | |
| autoscaling_group_name=$(aws --region "${region}" eks describe-nodegroup --cluster-name "${cluster}" --nodegroup-name "${nodegroup}" --output json | jq '.nodegroup.resources.autoScalingGroups | last | .name' -r) | |
| # Determine the ASG launch template for this ASG | |
| launch_template_name=$(aws --region "${region}" autoscaling describe-auto-scaling-groups --auto-scaling-group-names "${autoscaling_group_name}" | jq '.AutoScalingGroups | last | .MixedInstancesPolicy.LaunchTemplate.LaunchTemplateSpecification.LaunchTemplateName' -r ) | |
| # Now query the image ID for that template |
| #!/usr/bin/env python | |
| import argparse | |
| from kubernetes import client, config | |
| from kubernetes.client.exceptions import NotFoundException | |
| if __name__ == "__main__": | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("replicas", type=int) | |
| parser.add_argument("--deployment", default="node-placeholder") |
| import argparse | |
| import collections | |
| import csv | |
| import escapism | |
| import string | |
| import sys | |
| def escape_email(email): | |
| return escapism.escape(email, safe=safe_chars, escape_char="-").lower() |
| { | |
| description = "nbgitpuller"; | |
| inputs = { | |
| nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; | |
| }; | |
| outputs = { | |
| self, | |
| nixpkgs, |
| xterm_colors = [ | |
| # colors 0..15: 16 basic colors | |
| (0x00, 0x00, 0x00), # 0 | |
| (0xCD, 0x00, 0x00), # 1 | |
| (0x00, 0xCD, 0x00), # 2 | |
| (0xCD, 0xCD, 0x00), # 3 | |
| (0x00, 0x00, 0xEE), # 4 | |
| (0xCD, 0x00, 0xCD), # 5 | |
| (0x00, 0xCD, 0xCD), # 6 | |
| (0xE5, 0xE5, 0xE5), # 7 |
| { | |
| "nodes": { | |
| "nixpkgs": { | |
| "locked": { | |
| "lastModified": 1770841267, | |
| "narHash": "sha256-9xejG0KoqsoKEGp2kVbXRlEYtFFcDTHjidiuX8hGO44=", | |
| "owner": "nixos", | |
| "repo": "nixpkgs", | |
| "rev": "ec7c70d12ce2fc37cb92aff673dcdca89d187bae", | |
| "type": "github" |
I always feel like state machines can quickly become a lot of pain. Although I have had my reservations about the Python case/match feature, it's a perfect fit for this.