homebrew-core/Formula/kubeprod.rb

78 lines
2.6 KiB
Ruby
Raw Normal View History

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.2.0.tar.gz"
sha256 "8d458c8c4bf818a06fb802e191f97f1124188d07edf1d12e15868831f44ab392"
2019-01-29 11:17:25 +00:00
bottle do
cellar :any_skip_relocation
2019-03-20 10:09:24 +00:00
sha256 "9cdb73d130c9443eabf6d4ae362cbe9aa252465b786bcece8f8b3cbd69c81e46" => :mojave
sha256 "3d96877ec020557916ef129f56ec6d34337cc62fec21b9fd431037521ee1a8a3" => :high_sierra
sha256 "939870405708627b1ddd53bffcb1c9982d176fe5ee51c07298d25e8cb0360aa4" => :sierra
2019-01-29 11:17:25 +00:00
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