homebrew-core/Formula/kubeprod.rb
2019-07-04 14:28:58 +02:00

77 lines
2.6 KiB
Ruby

class Kubeprod < Formula
desc "Installer for the Bitnami Kubernetes Production Runtime (BKPR)"
homepage "https://kubeprod.io"
url "https://github.com/bitnami/kube-prod-runtime/archive/v1.3.4.tar.gz"
sha256 "e705bf5037b118da5ea7e42d992908e97ecd88dd0bf092bbf25464ec49c3804b"
bottle do
cellar :any_skip_relocation
sha256 "f3852b0cda86dea52d921b20ac901e5b652ce58900ab09d1be40e11fd68cc24a" => :mojave
sha256 "df62b2babd18f9817887c642aa999bdb13a307c6c01517558faf57e382e1e986" => :high_sierra
sha256 "8f43bb6a265a3200f7c57f3de66cfd0d528dffe29dffbbea3cffcd2a02ec746d" => :sierra
end
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
ENV["TARGETS"] = "darwin/amd64"
dir = buildpath/"src/github.com/bitnami/kube-prod-runtime"
dir.install buildpath.children
cd dir do
system "make", "-C", "kubeprod", "release", "VERSION=v#{version}"
bin.install "kubeprod/_dist/darwin-amd64/bkpr-v#{version}/kubeprod"
end
end
test do
version_output = shell_output("#{bin}/kubeprod version")
assert_match "Installer version: v#{version}", version_output
(testpath/"kube-config").write <<~EOS
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: test
server: http://127.0.0.1:8080
name: test
contexts:
- context:
cluster: test
user: test
name: test
current-context: test
kind: Config
preferences: {}
users:
- name: test
user:
token: test
EOS
authz_domain = "castle-black.com"
project = "white-walkers"
oauth_client_id = "jon-snow"
oauth_client_secret = "king-of-the-north"
contact_email = "jon@castle-black.com"
ENV["KUBECONFIG"] = testpath/"kube-config"
system "#{bin}/kubeprod", "install", "gke",
"--authz-domain", authz_domain,
"--project", project,
"--oauth-client-id", oauth_client_id,
"--oauth-client-secret", oauth_client_secret,
"--email", contact_email,
"--only-generate"
json = File.read("kubeprod-autogen.json")
assert_match "\"authz_domain\": \"#{authz_domain}\"", json
assert_match "\"client_id\": \"#{oauth_client_id}\"", json
assert_match "\"client_secret\": \"#{oauth_client_secret}\"", json
assert_match "\"contactEmail\": \"#{contact_email}\"", json
jsonnet = File.read("kubeprod-manifest.jsonnet")
assert_match "https://releases.kubeprod.io/files/v#{version}/manifests/platforms/gke.jsonnet", jsonnet
end
end