Skip to content

Instantly share code, notes, and snippets.

View carolynvs's full-sized avatar

Carolyn Van Slyck carolynvs

View GitHub Profile
@carolynvs
carolynvs / main.go
Created October 4, 2021 01:19
exit main and execute defered statements
func main() {
run := func() int {
p := porter.New()
defer p.Close()
cmd := buildRootCommandFrom(p)
if err := cmd.Execute(); err != nil {
return 1
}
return 0
@carolynvs
carolynvs / magefile.go
Last active January 24, 2021 01:34
example magefile
// +build mage
package main
import (
"github.com/carolynvs/magex/pkg"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
)
@carolynvs
carolynvs / create-user-namespace.sh
Last active January 11, 2021 14:13
Create a user and a dedicated namespace for it. Grant admin on the namespace and also to CRDs and RBAC.
#!/bin/bash
set -eo pipefail
# https://computingforgeeks.com/restrict-kubernetes-service-account-users-to-a-namespace-with-rbac/
if [[ "$1" == "" ]]; then
echo "usage: create-user-namespace.sh USERNAME"
exit 1
fi
@carolynvs
carolynvs / .gitconfig
Last active October 19, 2022 14:44
git wip - Show what branches you have been working on lately
[alias]
wip = for-each-ref --sort='authordate:iso8601' --format=' %(color:green)%(authordate:relative)%09%(color:white)%(refname:short)' refs/heads
@carolynvs
carolynvs / gofind.sh
Last active July 10, 2020 14:16
Find a go project in your GOPATH, written by @steder
#!/usr/bin/env bash
# Just source this file or copy/paste this function in your ~/.bashrc or ~/.bash_profile
function gof {
if (( $# == 0 )); then
echo "usage: $gof <dir>"
echo "jumps to $GOPATH/src directory matching <dir>"
return
fi
GOPATH=${GOPATH:-~/go}
@carolynvs
carolynvs / sketchtool-diff-steps.md
Last active March 5, 2019 13:01
Configure Diffs for Sketch Files
  1. Add the following line to your ~/.bash-profile
    export PATH=$PATH:"$(mdfind kMDItemCFBundleIdentifier == 'com.bohemiancoding.sketch3' | head -n 1)/Contents/Resources/sketchtool/bin/"
    
  2. Add the following lines to your ~/.gitconfig
    [diff "sketchtool"]
      textconv = "sketchtool dump"
      cachetextconv = true
    

binary = true

@carolynvs
carolynvs / publish-charts.mk
Last active March 2, 2019 12:57
Publish Helm Charts to Azure storage
build-image:
docker build -t build-image ./scripts/build-image/
charts-push: build-image
docker run --rm -it \
-v `pwd`:/go/src/github.com/carolynvs/mypkg \
-e AZURE_STORAGE_CONNECTION_STRING \
build-image ./scripts/push-charts.sh
@carolynvs
carolynvs / push-charts.Dockerfile
Created March 2, 2019 12:23
Publish Helm Charts to Azure
FROM golang:1.12-stretch
WORKDIR /tmp
# Install Helm
ENV HELM_VERSION=2.13.0
RUN curl -sLO https://kubernetes-helm.storage.googleapis.com/helm-v${HELM_VERSION}-linux-amd64.tar.gz && \
tar -zxvf helm-v${HELM_VERSION}-linux-amd64.tar.gz && \
mv linux-amd64/helm /usr/local/bin/
@carolynvs
carolynvs / push-charts.sh
Last active March 2, 2019 12:22
Publish Helm Charts to Azure Storage
#!/usr/bin/env bash
set -xeuo pipefail
helm init --client-only
#####
# set up the repo dir, and package up all charts
#####
CHARTS_REPO="https://athens.blob.core.windows.net"
@carolynvs
carolynvs / svcat-plugin-experience-report.md
Last active April 5, 2022 20:38
Experience Report: Building a kubectl plugin for Service Catalog

Experience Report: Building a kubectl plugin for Service Catalog

Why a kubectl plugin?

The goal of the service catalog cli (svcat) is to reduce the learning curve for developers and follow precedent set by kubectl when reasonable so that "finger memory" built-up from using kubectl translates to being able to use svcat without reading the help text much.

It isn't intended to be a replacement for kubectl, and instead users will jump back and forth between kubectl and svcat. As a plugin, it reinforces the mental model that svcat conforms to the way kubectl works, and makes the switch between the two less noticeable.