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.1.2.tar.gz" sha256 "1145150acf696830c780fb4d9a9f05c5eb34a792e81c0db840f0728e6be920ea" bottle do cellar :any_skip_relocation sha256 "310dcc094f93c2bb8b79f53c95f35ac07f1ce60f87b1f33f0c311246e28bf9f3" => :mojave sha256 "0cbf1afda0ad5381d70b9df823ed78ff2ce556bfc1fab7430cec57cbf93a1b1c" => :high_sierra sha256 "66680d2eca38574cb5e5cf7f407a7da917f105247d562c151d539d775e0944b1" => :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