Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Holditch kevholditch

View GitHub Profile
@kevholditch
kevholditch / deserialisation.go
Created Jul 31, 2018
Custom go JSON deserialisation
View deserialisation.go
func (a *Api) UnmarshalJSON(data []byte) error {
fixedJson := strings.Replace(string(data), `"hosts":{}`, `"hosts":[]`, -1)
fixedJson = strings.Replace(fixedJson, `"uris":{}`, `"uris":[]`, -1)
fixedJson = strings.Replace(fixedJson, `"methods":{}`, `"methods":[]`, -1)
type Alias Api
aux := &struct {
*Alias
}{
@kevholditch
kevholditch / deserialisation.go
Created Jul 31, 2018
json deserialisation broken first try
View deserialisation.go
func (a *Api) UnmarshalJSON(data []byte) error {
fixedJson := strings.Replace(string(data), `"hosts":{}`, `"hosts":[]`, -1)
fixedJson = strings.Replace(fixedJson, `"uris":{}`, `"uris":[]`, -1)
fixedJson = strings.Replace(fixedJson, `"methods":{}`, `"methods":[]`, -1)
return json.Unmarshal([]byte(fixedJson), &a)
}
View .travis.yml
env:
matrix:
- KONG_VERSION=0.11 TF_ACC=1
- KONG_VERSION=0.11.1 TF_ACC=1
- KONG_VERSION=0.11.2 TF_ACC=1
View make release
git tag -a v0.1.0 -m "My release"
git push origin v0.1.0
View Makefile
release:
go get github.com/goreleaser/goreleaser; \
goreleaser; \
View goreleaser.yml
builds:
- binary: terraform-provider-kong
goos:
- darwin
- linux
- windows
goarch:
- amd64
archive:
format: zip
View nginx.template
server {
server_name notification_proxy;
listen 8117;
location / {
resolver $DNS_ADDR ipv6=off;
set_by_lua_block $proxy_addr {
return ngx.unescape_uri(ngx.var.arg_address)
}
View envsubst nginx.sh
#!/usr/local/bin/dumb-init /bin/bash
set -e
export DNS_ADDR=`cat /etc/resolv.conf | grep nameserver | cut -d' ' -f2-`
envsubst '$DNS_ADDR' < /etc/nginx/nginx.template > /usr/local/openresty/nginx/conf/nginx.conf
/usr/local/openresty/bin/openresty -g "daemon off;"
View nginx proxy.conf
server {
server_name notification_proxy;
listen 8117;
location / {
resolver 127.0.0.11 ipv6=off;
set_by_lua_block $proxy_addr {
return ngx.unescape_uri(ngx.var.arg_address)
}
View ExampleTest.go
func Test_ApisGetById(t *testing.T) {
apiRequest := &ApiRequest{
Name: "test-" + uuid.NewV4().String(),
Hosts: []string{"example.com"},
Uris: []string{"/example"},
Methods: []string{"GET", "POST"},
UpstreamUrl: "http://localhost:4140/testservice",
StripUri: true,
PreserveHost: true,
Retries: 3,
You can’t perform that action at this time.