Skip to content

Instantly share code, notes, and snippets.

Avatar

Aslak Knutsen aslakknutsen

View GitHub Profile
View Dockerfile
# 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,
View keybase.md

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 Jul 19, 2019
Template based json patch
View template_test.go
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 Mar 6, 2019
istio API duplication on DeepCopy
View vs_test.go
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"
)
View deployment_test.go
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...),
}
View deployment_test.go
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...),
}
View test.md

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 Mar 21, 2018
OSiO: Incident Report
View 1.adoc

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 Jan 24, 2018
WIT API Generator (requires pre setup of iterations, randomly distributes across iterations and states)
View generator_test.go
package wit
import (
"context"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"net/url"
"testing"
@aslakknutsen
aslakknutsen / cache.go
Created Oct 27, 2017
Multi level locked cache with Promise, single resovler
View cache.go
package middlewares
import (
"sync"
)
type Cache struct {
mux sync.Mutex
m map[string]Promise
}
You can’t perform that action at this time.