Skip to content

Instantly share code, notes, and snippets.

View lawrencegripper's full-sized avatar

Lawrence Gripper lawrencegripper

View GitHub Profile
@lawrencegripper
lawrencegripper / start.rego
Created January 13, 2020 20:07
blog opa part1
# The top level response sent to the webrequest
main = {
"apiVersion": "admission.k8s.io/v1beta1",
"kind": "AdmissionReview",
"response": response,
}
# If the conditions on the `response` below aren't met this default `allow` response
# is returned.
default response = {"allowed": true }
trigger:
- master
pool:
vmImage: 'Ubuntu-16.04'
steps:
# Cache the docker image file
- task: CacheBeta@0
inputs:
@lawrencegripper
lawrencegripper / Dockerfile
Created October 25, 2019 16:03
devcontainer kubebuilder
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
FROM golang:1.12
# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive
@lawrencegripper
lawrencegripper / program.cs
Last active September 24, 2019 17:50
C# 8 `defer` like golang
using System;
namespace deferdotnet
{
class Program
{
static void Main(string[] args)
{
try
{
@lawrencegripper
lawrencegripper / launch.json
Created September 12, 2019 13:47
Debugging Terraform Provider test
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch test function",
"type": "go",
"request": "launch",
@lawrencegripper
lawrencegripper / build.yaml
Created July 29, 2019 16:43
azure devops running shellcheck
- bash: |
echo "This checks for formatting and common bash errors. See wiki for error details and ignore options: https://github.com/koalaman/shellcheck/wiki/SC1000"
export scversion="stable"
wget -qO- "https://storage.googleapis.com/shellcheck/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv
sudo mv "shellcheck-${scversion}/shellcheck" /usr/bin/
rm -r "shellcheck-${scversion}"
shellcheck ./scripts/*.sh
displayName: "Validate Scripts: Shellcheck"
@lawrencegripper
lawrencegripper / validate-tf.sh
Last active July 16, 2019 19:25
terraform validate, lint and format checker
#! /bin/bash
set -e
SCRIPT_DIR=$(dirname "$BASH_SOURCE")
cd "$SCRIPT_DIR"
echo -e "\n\n>>> Installing Terraform 0.12"
# Install terraform tooling for linting terraform
wget -q https://releases.hashicorp.com/terraform/0.12.4/terraform_0.12.4_linux_amd64.zip -O /tmp/terraform.zip
sudo unzip -q -o -d /usr/local/bin/ /tmp/terraform.zip
@lawrencegripper
lawrencegripper / keys.tf
Last active July 26, 2022 17:45
Terraform Azure functions keys
# Get the functions keys out of the app
resource "azurerm_template_deployment" "function_keys" {
name = "javafunckeys${var.random_name_ending}"
parameters = {
"functionApp" = "${azurerm_function_app.function-app.name}"
}
resource_group_name = "${var.resource_group_name}"
deployment_mode = "Incremental"
@lawrencegripper
lawrencegripper / azure-pipelines.yml
Last active October 19, 2018 08:43
Run Minikube scripts
pool:
vmImage: 'Ubuntu 16.04'
# Setup for GoLang, can skip for other languages
variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOROOT: '/usr/local/go1.11' # Go installation path
GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code
@lawrencegripper
lawrencegripper / 1-minikubesetup_ci.sh
Last active October 19, 2018 08:36
A script to run a Minikube cluster under a CI system which supports Ubuntu 16 and Docker
#/bin/bash
set -e
# Adapted from: https://github.com/LiliC/travis-minikube/blob/minikube-26-kube-1.10/.travis.yml
export CHANGE_MINIKUBE_NONE_USER=true
echo "--> Downloading minikube"
# Make root mounted as rshared to fix kube-dns issues.
sudo mount --make-rshared /