Skip to content

Instantly share code, notes, and snippets.

Avatar
👾
Building.

Mitchell Hashimoto mitchellh

👾
Building.
View GitHub Profile
@mitchellh
mitchellh / RadixTrees.tla
Last active Jun 30, 2021
Radix tree and validation in TLA+
View RadixTrees.tla
This module contains operations for working with radix trees. A radix tree
is a data structure for efficient storage and lookup of values that often
share prefixes, typically used with strings.
A common question when I show this to people is: how do I add to the tree?
delete? update? For these, grab the Range of the tree, use set logic to
add/remove any elements, and construct a new tree with RadixTree.
For educational purposes, I've heavily commented all the operations. I
recommend using the constant expression evaluator to try the building blocks
@mitchellh
mitchellh / example.nix
Created May 10, 2020
Nix function for creating a derivation (package) that installs binaries from releases.hashicorp.com
View example.nix
self: super: {
consul-bin = self.callPackage ./hashicorp-generic.nix {
name = "consul";
version = "1.7.3";
sha256 = "0k03n7h5h8miqhh3n3y47894vhwdcp8m611w55f826swmq9angl1";
};
# and so on...
}
@mitchellh
mitchellh / notarize.md
Last active Aug 31, 2021
macOS Catalina (10.15+) Notarization Requirement for Go
View notarize.md

macOS 10.15 Catalina requires binaries are notarized to run without annoying additional steps. See the issue here: https://github.com/hashicorp/terraform/issues/23033

These are steps to notarize a direct binary. This does not cover stapling, installers (pkg), etc. This is primarily useful for static binary developers such as Go developers.

Manual Steps

Apple Developer Account

You first need an Apple Developer Account ($99/year). You need to accept all the agreements and stuff.

@mitchellh
mitchellh / post.md
Created Aug 13, 2019
Originally posted on Tumblr on Feb 25, 2011.
View post.md

THIS WAS ORIGINALLY POSTED ON MY TUMBLR ON FEB 25, 2011. I forgot I had a Tumblr account. I recently logged in (in light of the acquisition by Automattic), found some old posts, and I'm republishing them exactly as they were with zero modifications.


CloudFormation: The Big Picture

Amazon announced CloudFormation to the public yesterday, and while the general opinion I could glean from various sources shows that people are excited about this new technology, many are still unsure what it is and how it fits into their current cloud workflow. I feel as though I have a firm grasp on CloudFormation and will attempt to answer some questions here.

Note: I'm definitely not a representative of Amazon in any way, and anything here is simply my educated opinion on the matter.

@mitchellh
mitchellh / parse.go
Created Jan 22, 2019
HCL2 parsing example.
View parse.go
package config
import (
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"github.com/hashicorp/hcl2/gohcl"
@mitchellh
mitchellh / Makefile
Created Jan 21, 2019
Makefile target to test all modules in a repo.
View Makefile
.PHONY: test
test:
@find ${CURRENT_DIR} -type f -name go.mod | xargs -n1 dirname | while read line ; do \
echo $${line} ; \
pushd $${line} >/dev/null ; \
go test ./... ; \
popd >/dev/null ; \
echo ; \
done
View response.md

This is a bit of history and a bit of a quirk in timing...

The history first...

Vagrant has all manner of provisioners effectively supporting any CM tool as well as supporting plugins to add more. When I started on Packer, I basically copied this model (nit: provisioners aren't pluggable anymore cause no one ever used that functionality but the interfaces are very similar and Packer also supports all manner of CM tool).

View struct-to-struct.go
import(
"github.com/mitchellh/mapstructure"
)
type A struct {
One string
Metadata map[string]string
}
type B struct {
View keybase.md

Keybase proof

I hereby claim:

  • I am mitchellh on github.
  • I am mitchellh (https://keybase.io/mitchellh) on keybase.
  • I have a public key ASDVPV1p-IwMoQoauwLXF8p2X88ktkQZd-drBOb885_fOgo

To claim this, I am signing this object:

@mitchellh
mitchellh / preview-tf-0.11.md
Last active Nov 7, 2017
Previewing the upcoming module provider configurations in TF 0.11
View preview-tf-0.11.md

Note: This is a preview for TF 0.11. You should reference the official Terraform docs for up to date information.

Before (Terraform <= 0.10.x)

Modules can only inherit provider configurations, and modules inheritance around aliased providers is unclear.

Use case: if you want two have two modules where you want one two create resources in the us-west region and the other to create resources in the us-east region. In Terraform <= 0.10.x, this is not possible.