Skip to content

Instantly share code, notes, and snippets.

@jpreese
jpreese / Dockerfile
Created June 8, 2020 23:10
dockerfile-unzip
FROM golang:1.13 as builder
RUN apt-get update \
&& apt-get install unzip
violation[msg] {
container := input.spec.template.spec.containers[_]
not container.resources.requests.cpu
not container.resources.limits.cpu
msg := sprintf("(%s): Container resource constraints must be specified.", [input.metadata.name])
}
package main
violation[msg] {
input.kind == "Namespace"
not input.metadata.labels["owner"]
msg := "All namespaces must contain an owner label"
}
# The version of Terraform to include with the bundle.
terraform {
version = "0.12.21"
}
# The providers to pre-download and include in the Atlantis image.
providers {
azurerm = ["~> 2.0.0"]
azuread = ["~> 0.7.0"]
random = ["~> 2.2.0"]
[credential "https://dev.azure.com"]
helper = "/bin/sh /home/atlantis/azure-devops-helper.sh"
#!/bin/sh
# These values are already provided to the container from
# the Kubernetes manifest.
echo username=$ATLANTIS_AZUREDEVOPS_WEBHOOK_USER
echo password=$ATLANTIS_AZUREDEVOPS_TOKEN
repos:
# The list of repositories Atlantis watches. Supports wildcards/*
- id: dev.azure.com/org/project/first-repo
# Only allow "apply" comments if the PR is approved and can be merged
apply_requirements: [approved, mergeable]
workflow: terragrunt
# Instead of terraform commands, run these for plan and apply
workflows:
FROM golang:1.13 as builder
RUN apt-get update \
&& apt-get install unzip
# Install terraform-bundle
RUN git clone \
--depth 1 \
--single-branch \
--branch "v0.12.0" \
https://github.com/hashicorp/terraform.git \
@jpreese
jpreese / kforward.go
Created February 13, 2020 21:57
Helper function to forward ports on a Kubernetes pod and run a function
// Pod starts a port-forward on a given pod
func Pod(config *rest.Config, namespace string, pod string, ports []string, fn func() error) error {
roundTripper, upgrader, err := spdy.RoundTripperFor(config)
if err != nil {
return fmt.Errorf("get roundtripper: %w", err)
}
path := fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/portforward", namespace, pod)
hostIP := strings.TrimLeft(config.Host, "https://")
serverURL := url.URL{Scheme: "https", Path: path, Host: hostIP}
// EXAMPLE 1
for i := range feed.Index[mixin][version].Files {
if feed.Index[mixin][version].Files[i].File == filename {
if feed.Index[mixin][version].Files[i].Updated.Before(updated) {
feed.Index[mixin][version].Files[i].Updated = updated
}
return nil
}
}