Skip to content

Instantly share code, notes, and snippets.

View imjasonh's full-sized avatar
🏠
Working from home

Jason Hall imjasonh

🏠
Working from home
View GitHub Profile
@imjasonh
imjasonh / markdown.css
Last active February 12, 2024 17:18
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
module logrustest
go 1.20
require github.com/sirupsen/logrus v1.9.3
require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
@imjasonh
imjasonh / demo.md
Last active May 17, 2023 13:36
cgr.dev Tag History API

Demoing cgr.dev tag history

We're going to use the new tag history API to see tag updates to cgr.dev/chainguard/static:latest!

First, exchange your Chainguard token for a registry token. This assumes you've set up auth with chainctl auth configure-docker:

tok=$(curl -H "Authorization: Bearer $(echo 'cgr.dev' | docker-credential-cgr get)" -v "https://cgr.dev/token?scope=repository:chainguard/static:pull" | jq -r .token)
package must
import (
"testing"
"github.com/google/go-containerregistry/pkg/name"
v1 "github.com/google/go-containerregistry/pkg/v1"
)
// must.Testing(t).Digest(img)
@imjasonh
imjasonh / example.tf
Created April 26, 2023 00:08
Example using a bunch of TF providers
// Example using our bevy of TF providers (in order):
// - https://github.com/chainguard-dev/terraform-provider-apko
// - https://github.com/chainguard-dev/terraform-provider-oci
// - https://github.com/ko-build/terraform-provider-ko
// - https://github.com/chainguard-dev/terraform-provider-cosign
// - https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/cloud_run_service
// This could be a resource like:
// https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/artifact_registry_repository
variable "repo" {
module cp-progress
go 1.20
require (
github.com/charmbracelet/bubbles v0.15.0
github.com/google/go-containerregistry v0.14.0
)
require (

container-report

This is an experimental tool that emits a JSON report of the contents of an image.

It's current intended use is to be passed two images and to have their reports diffed using diff.

Example:

function gauth() {
gcloud auth login && gcloud auth application-default login
}
# Diff two image filesystems
function cdiff-fs() {
diff \
<(crane export $1 - --platform ${3:-linux/amd64} | tar -tvf - | sort) \
<(crane export $2 - --platform ${3:-linux/amd64} | tar -tvf - | sort)
}
@imjasonh
imjasonh / .zshrc
Created January 11, 2023 16:26
image inspection helpers
# Diff two image filesystems
function cdiff-fs() {
diff \
<(crane export $1 - --platform ${3:-linux/amd64} | tar -tvf - | sort) \
<(crane export $2 - --platform ${3:-linux/amd64} | tar -tvf - | sort)
}
# Diff two image configs
function cdiff-cfg() {
diff \
<(crane config $1 --platform ${3:-linux/amd64} | jq) \
@imjasonh
imjasonh / glob_test.go
Created May 23, 2022 14:03
Unit test for image ref glob matching, with support for **
package glob_test
import (
"fmt"
"regexp"
"strings"
"testing"
"github.com/google/go-containerregistry/pkg/name"
)