Skip to content

Instantly share code, notes, and snippets.

Task Java Clojure
Instantiation new Widget(“Foo”) (Widget. “Foo”)
Instance method rnd.nextInd() (.nextInt rnd)
Instance field object.field (.-field object)
Static method Math.Sqrt(25) (Math/sqrt 25)
Static field Math.PI (Math/PI)
@achilles42
achilles42 / goreleaser.sh
Created September 28, 2018 10:47
goreleaser for proctor
#!/bin/sh
set -e
TAR_FILE="/tmp/goreleaser.tar.gz"
RELEASES_URL="https://github.com/goreleaser/goreleaser/releases"
TMP_DIR="/tmp/"
last_version() {
curl -sL -o /dev/null -w %{url_effective} "$RELEASES_URL/latest" |
rev |
## start server foobar.mydomain.com
server {
server_name foobar.mydomain.com ;
listen 80;
listen [::]:80;
set $proxy_upstream_name "-";
location / {
log_by_lua_block {
}
port_in_redirect off;
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
name: foobar
namespace: default
spec:
rules:
- host: foobar.mydomain.com
controller:
ingressClass: nginx
service:
annotations:
cloud.google.com/load-balancer-type: Internal

Traditionally, most of infrastructure is managed manually or by using scripts. This inconsistency causes many issues in infrastructure. TDD is known for increasing code quality, improving overall design, and allowing safe refactoring throughout a project. Explaining about how, why and which tools we should use to test code. So, I am going to explain about the how and why we should test our code and what are tools are available to test our infrastructure code.

Before Getting into actual usage of tool we should understand the phases of

  1. Pre-convergence: Testing phase that does not require any node to run the test.
  2. Convergence: Chef runs and make changes to the system on node.
  3. Post-convergence: Node finishes running Chef, also verifying that node is in the desired state.
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'google_client/version'
Gem::Specification.new do |spec|
spec.name = "google-client"
spec.version = GapiClient::VERSION
spec.authors = ["praveen shukla"]
spec.email = ["praveen.shukla@c42.in"]
package main
import "fmt"
type Rectangle struct {
length, width int
}
func (r *Rectangle) Area() int {
return r.length * r.width
package main
import "fmt"
type Shaper interface {
Area() int
}
type Rectangle struct {
length, width int
Rectangle is: {4 3}
Rectangle area is: 12