Skip to content

Instantly share code, notes, and snippets.

View cmaster11's full-sized avatar
🐒
G'day!

Alberto Marchetti cmaster11

🐒
G'day!
View GitHub Profile
@cmaster11
cmaster11 / yargs-commander-compare.js
Last active July 5, 2024 12:03
A yargs/commander.js little comparison on how they handle multiple CLI arguments
import yargs from "yargs";
import {hideBin} from "yargs/helpers";
import {inspect} from 'node:util'
import {Command} from "commander";
// Compare yargs and commander.js multiple CLI args array handling
// Run:
//
// node yargs-commander-compare.js --str "a string" --arr "array string 1"
// node yargs-commander-compare.js --str "a string" --str "another string" --arr "array string 1" --arr "array string 2"
@cmaster11
cmaster11 / Markdium-TypeScript.ts
Created April 18, 2024 05:52
Markdium-CDK: Force-tagging stacks with a repository name
import * as cdk from 'aws-cdk-lib';
import { KiwiStack } from '../lib/stack';
import { getSynthesizer } from '../lib/synthesizer';
const app = new cdk.App();
async function main() {
new KiwiStack(app, 'MyStack', {
// Use the current environment variables to figure out which account
// and region we want to deploy to
@cmaster11
cmaster11 / Markdium-TypeScript.ts
Created April 18, 2024 05:52
Markdium-CDK: Force-tagging stacks with a repository name
import simpleGit from 'simple-git';
export async function getSynthesizer(synthProps?: cdk.DefaultStackSynthesizerProps) {
// Extract the current repository name
const remoteUrl = (await simpleGit().remote(['get-url', 'origin']))!.trim();
const repository = /github.com[:/]([^/]+\/[^/]+)\.git/.exec(remoteUrl)![1];
return new KiwiSynthesizer({
...synthProps,
forcedTags: {
@cmaster11
cmaster11 / Markdium-TypeScript.ts
Created April 18, 2024 05:52
Markdium-CDK: Force-tagging stacks with a repository name
import * as cdk from 'aws-cdk-lib';
export type KiwiSynthesizerProps = cdk.DefaultStackSynthesizerProps & {
forcedTags: Record;
};
export class KiwiSynthesizer extends cdk.DefaultStackSynthesizer {
readonly forcedTags: KiwiSynthesizerProps['forcedTags'];
constructor(props: KiwiSynthesizerProps) {
@cmaster11
cmaster11 / Markdium-YAML.yaml
Created July 6, 2021 11:31
Markdium-Restart Kubernetes deployments using HTTP requests
apiVersion: apps/v1
kind: Deployment
metadata:
name: restart-helper
labels:
app: restart-helper
spec:
replicas: 1
template:
metadata:
@cmaster11
cmaster11 / Markdium-YAML.yaml
Created July 6, 2021 11:31
Markdium-Restart Kubernetes deployments using HTTP requests
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: restart-helper
spec:
rules:
- host: myhost.mydomain.com
http:
paths:
- path: /
@cmaster11
cmaster11 / Markdium-YAML.yaml
Created July 6, 2021 11:31
Markdium-Restart Kubernetes deployments using HTTP requests
apiVersion: v1
kind: Service
metadata:
name: restart-helper
spec:
selector:
app: restart-helper
ports:
- port: 7055
name: http
@cmaster11
cmaster11 / Markdium-YAML.yaml
Created July 6, 2021 11:31
Markdium-Restart Kubernetes deployments using HTTP requests
apiVersion: v1
kind: ServiceAccount
metadata:
name: restart-helper
---
# Allows the service account to:
#
# - Get namespaces.
# - Get/patch our deployments and statefulsets, to allow the
# "restart rollout" command to work.
@cmaster11
cmaster11 / Markdium-YAML.yaml
Created July 6, 2021 11:31
Markdium-Restart Kubernetes deployments using HTTP requests
"/restart/:type/:name":
logOutput: true
logArgs: true
returnOutput: true
command: kubectl
args:
- rollout
- restart
@cmaster11
cmaster11 / Markdium-YAML.yaml
Created July 6, 2021 11:30
Markdium-Restart Kubernetes deployments using HTTP requests
"/restart/:type/:name":
logOutput: true
logArgs: true
returnOutput: true
command: kubectl
args:
- rollout
- restart