Skip to content

Instantly share code, notes, and snippets.

View developer-guy's full-sized avatar
🐾
Every artifact can be verifiably traced to Source Code and Hardware

Batuhan Apaydın developer-guy

🐾
Every artifact can be verifiably traced to Source Code and Hardware
View GitHub Profile
type patchOperation struct {
Op string `json:"op"`
Path string `json:"path"`
Value interface{} `json:"value,omitempty"`
}
func (p *patches) addContainers(pod *corev1.Pod, containers []corev1.Container) {
first := len(pod.Spec.Containers) == 0
path := "/spec/containers"
var value interface{}
for _, c := range containers {
value = c
tempPath := path
if first {
first = false
value = []corev1.Container{c}
@developer-guy
developer-guy / opa.go
Created June 16, 2020 07:02
opaAsGoLib
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"os"
"github.com/open-policy-agent/opa/rego"
# example.rego
package authz
allow {
input.path == ["users"]
input.method == "POST"
}
# example_test.rego
test_post_allowed {
allow with input as {"path": ["users"], "method": "POST"}
package myapi.policy
import data.myapi.acl
import input
default allow = false
allow {
access = acl[input.user]
access[_] == input.access
@developer-guy
developer-guy / myapi-acl.json
Created June 16, 2020 09:58
myapi-acl.json
{
"alice": [
"read",
"write"
],
"bob": [
"read"
]
}
@developer-guy
developer-guy / get-latest-tag-on-git.sh
Created August 11, 2020 06:53 — forked from rponte/get-latest-tag-on-git.sh
Getting latest tag on git repository
# The command finds the most recent tag that is reachable from a commit.
# If the tag points to the commit, then only the tag is shown.
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object
# and the abbreviated object name of the most recent commit.
git describe
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:
git describe --abbrev=0
# other examples
@developer-guy
developer-guy / Vagrantfile
Created September 29, 2020 09:00
podman + buildah + skopeo Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-18.04"
config.vm.define "buildah" do |buildah|
buildah.vm.network "private_network", ip: "192.168.33.10"
buildah.vm.provider "virtualbox" do |vb|
vb.name = "buildah"
$ export PATH=$(pwd):$PATH
$ podman-machine create box
Podman machine "box" already exists
$ podman-machine start box
Starting "box"...
@developer-guy
developer-guy / Podman-on-MacOS.md
Created October 1, 2020 06:51 — forked from rbo/Podman-on-MacOS.md
Podman on Mac OS
$ export PATH=$(pwd):$PATH
$ podman-machine create box
Podman machine "box" already exists
$ podman-machine start box
Starting "box"...