Skip to content

Instantly share code, notes, and snippets.

@charith-elastic
charith-elastic / AST_refactoring.md
Last active January 27, 2021 11:31
AST Refactoring

Refactoring with AST transforms

Problem

  • We want to change the k8s.Client interface to match the client.Client interface.
  • The two interfaces are identical except for the fact that client.Client methods all take a context.Context as the first parameter.
  • k8s.Client is used everywhere in the codebase and manually changing all occurrences would be very tedious and error-prone.
  • In most places, when we modify the method call we need to add an import for context as well.

Possible solutions

{n} version 1.2.0

@charith-elastic
charith-elastic / manifest.yaml
Created June 4, 2020 13:56
Metadata propagation
---
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: hulk
labels:
my-es-label: xxx
annotations:
eck.k8s.elastic.co/propagate-annotations: "*"
eck.k8s.elastic.co/propagate-labels: "*"
package apm
import (
"context"
"crypto/tls"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
Only in .: assets
diff '--exclude=.git' -r -u ../gld/dependency/dependency.go ./dependency/dependency.go
--- ../gld/dependency/dependency.go 2020-04-14 11:51:22.745018794 +0100
+++ ./dependency/dependency.go 2020-04-14 13:10:00.829636828 +0100
@@ -1,6 +1,19 @@
-// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
-// or more contributor license agreements. Licensed under the Elastic License;
-// you may not use this file except in compliance with the Elastic License.
+// Licensed to Elasticsearch B.V. under one or more contributor
+// license agreements. See the NOTICE file distributed with
@charith-elastic
charith-elastic / CLI
Last active April 9, 2020 08:30
ECK manifest generator
-------------------------------------------------------------------------------------------
$ bin/eck manifest
Utilities for generating an installation manifest for ECK
Usage:
eck manifest [command]
Available Commands:
generate Generate ECK manifests
options List manifest options
Copyright 2014-2019 Elasticsearch BV
This product includes software developed by The Apache Software
Foundation (http://www.apache.org/).
================================================================================
Third party libraries used by the Elastic Cloud on Kubernetes project
================================================================================