Skip to content

Instantly share code, notes, and snippets.

# Copyright 2018 Datawire. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,

Keybase proof

I hereby claim:

  • I am aslakknutsen on github.
  • I am aslakknutsen (https://keybase.io/aslakknutsen) on keybase.
  • I have a public key ASA0usfakObuP-k6yxY1STXfA80Ais1oIALzlZ_d27Z7AQo

To claim this, I am signing this object:

@aslakknutsen
aslakknutsen / template_test.go
Last active July 19, 2019 15:06
Template based json patch
func TestX(t *testing.T) {
patchs := []Patch{
Patch{
Name: "telepresence",
Template: []byte(`[
{{ if .Data.Has "/spec/template/metadata/labels/version" }}
{"op": "copy", "from": "/spec/template/metadata/labels/version", "path": "/spec/template/metadata/labels/version-source"},
{{ end }}
{"op": "replace", "path": "/metadata/name", "value": "{{.Data.Value "/metadata/name"}}-{{.NewVersion}}"},
{"op": "replace", "path": "/spec/template/spec/replicas", "value": "1"},
@aslakknutsen
aslakknutsen / vs_test.go
Last active March 6, 2019 16:15
istio API duplication on DeepCopy
import (
"testing"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
v1alpha3 "istio.io/api/networking/v1alpha3"
istionetwork "istio.io/api/pkg/kube/apis/networking/v1alpha3"
)
var objects []runtime.Object
var ctx model.SessionContext
BeforeEach(func() {
ctx = model.SessionContext{
Context: context.TODO(),
Name: "test",
Namespace: "test",
Log: logf.Log.WithName("test"),
Client: fake.NewFakeClient(objects...),
}
var objects []runtime.Object
var ctx model.SessionContext
BeforeEach(func() {
ctx = model.SessionContext{
Context: context.TODO(),
Name: "test",
Namespace: "test",
Log: logf.Log.WithName("test"),
Client: fake.NewFakeClient(objects...),
}
@aslakknutsen
aslakknutsen / test.md
Last active September 11, 2018 16:57

Start up with user having a running Server:

time="2018-09-11T18:26:25+02:00" level=info msg="UserIdler created." component=user-idler id=xxxxxx-a31f-471c-a3e7-9402c086d1be username=xxxxxxx 
time="2018-09-11T18:26:25+02:00" level=info msg="UserIdler started." checkIdle=5m component=user-idler id=xxxxxx-a31f-471c-a3e7-9402c086d1be maxRetriesQuietInterval=5m username=xxxxxxx 
time="2018-09-11T18:26:25+02:00" level=info msg="Will send user xxxxxxx to idler due to done build" 
time="2018-09-11T18:26:25+02:00" level=info msg="Sending user xxxxxxx to idler from a Build event" 
time="2018-09-11T18:26:26+02:00" level=info msg="Will send user xxxxxxx to idler due to a new version of DC or an existing version is coming up" 
time="2018-09-11T18:26:26+02:00" level=info msg="Sending user xxxxxxx to idler from a Deployment Config event" 
time="2018-09-11T18:26:26+02:00" level=info msg="About to idle jenkins, Reason: DoneBuild BuildName:cuckoo-1 Last:2018-07-20 05:05:22 +0000 UTC" attempt="(1/5)" component=user-idler id
@aslakknutsen
aslakknutsen / 1.adoc
Last active March 21, 2018 04:06
OSiO: Incident Report

The incident report is intended as a write up for transparency, cross-team knowledge transfer and to get in the habit of thinking in terms of continues improvement.

An Incident report should be created for each OSiO outage(small or large) in GitHub with label "type/incident": https://github.com/openshiftio/openshift.io/issues

Note: this is a public report so de sensitise data. No tokens, no users, no internal links etc

@aslakknutsen
aslakknutsen / generator_test.go
Last active January 24, 2018 16:56
WIT API Generator (requires pre setup of iterations, randomly distributes across iterations and states)
package wit
import (
"context"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"net/url"
"testing"
@aslakknutsen
aslakknutsen / cache.go
Created October 27, 2017 17:05
Multi level locked cache with Promise, single resovler
package middlewares
import (
"sync"
)
type Cache struct {
mux sync.Mutex
m map[string]Promise
}