homebrew-core/Formula/kube-aws.rb
2017-12-09 11:55:31 -08:00

57 lines
2.3 KiB
Ruby

class KubeAws < Formula
desc "CoreOS Kubernetes on AWS"
homepage "https://coreos.com/kubernetes/docs/latest/kubernetes-on-aws.html"
url "https://github.com/kubernetes-incubator/kube-aws/archive/v0.9.9.tar.gz"
sha256 "4ad421cb58913c27b9f297161eb87b0587f8420d6f0573cee052b17370c519aa"
head "https://github.com/kubernetes-incubator/kube-aws.git"
bottle do
cellar :any_skip_relocation
sha256 "f19411b6841900a0f55134394c70478cb7760f8dc80a49afa00b6ea197363cd4" => :high_sierra
sha256 "6500d191e1595000eff888ee7175ba9cc2c3c16af571a7581b7e1f8c1c35e0c0" => :sierra
sha256 "e992403707995cb4862515ddf5ba75d527799f3db3def9c4ec6693f43fe28dc6" => :el_capitan
end
depends_on "go" => :build
def install
gopath_vendor = buildpath/"_gopath-vendor"
gopath_kube_aws = buildpath/"_gopath-kube-aws"
kube_aws_dir = "#{gopath_kube_aws}/src/github.com/kubernetes-incubator/kube-aws"
gopath_vendor.mkpath
mkdir_p File.dirname(kube_aws_dir)
ln_s buildpath/"vendor", "#{gopath_vendor}/src"
ln_s buildpath, kube_aws_dir
ENV["GOPATH"] = "#{gopath_vendor}:#{gopath_kube_aws}"
cd kube_aws_dir do
system "go", "generate", "./core/controlplane/config"
system "go", "generate", "./core/nodepool/config"
system "go", "generate", "./core/root/config"
system "go", "build", "-ldflags",
"-X github.com/kubernetes-incubator/kube-aws/core/controlplane/cluster.VERSION=#{version}",
"-a", "-tags", "netgo", "-installsuffix", "netgo",
"-o", bin/"kube-aws", "./"
end
end
test do
system "#{bin}/kube-aws"
system "#{bin}/kube-aws", "init", "--cluster-name", "test-cluster",
"--external-dns-name", "dns", "--region", "west",
"--availability-zone", "zone", "--key-name", "key",
"--kms-key-arn", "arn", "--no-record-set"
cluster_yaml = (testpath/"cluster.yaml").read
assert_match "clusterName: test-cluster", cluster_yaml
assert_match "dnsName: dns", cluster_yaml
assert_match "region: west", cluster_yaml
assert_match "availabilityZone: zone", cluster_yaml
assert_match "keyName: key", cluster_yaml
assert_match "kmsKeyArn: \"arn\"", cluster_yaml
installed_version = shell_output("#{bin}/kube-aws version 2>&1")
assert_match "kube-aws version #{version}", installed_version
end
end