homebrew-core/Formula/click.rb
2019-02-28 17:18:59 -08:00

66 lines
1.9 KiB
Ruby

class Click < Formula
desc "The command-line interactive controller for Kubernetes"
homepage "https://github.com/databricks/click"
url "https://github.com/databricks/click/archive/v0.4.0.tar.gz"
sha256 "69df76f57af8b0c244ef4c975a242d3fe84f8e4f4fd44e62b2ccdf24ea82b23d"
head "https://github.com/databricks/click.git"
bottle do
cellar :any_skip_relocation
sha256 "e879a6d855395353f4d6bf94c86db2581681be41be9a8d892344cc64190b72c4" => :mojave
sha256 "ae13dc5304de63ae3cf3af67f0919d8c5c8ac7a4ac5ce63b4d297476eff302b8" => :high_sierra
sha256 "d1da447c91387264409aef3256198c1863d4840bdeb9b218c8e5da2fc6fc0d34" => :sierra
end
depends_on "rust" => :build
def install
system "cargo", "install", "--root", prefix, "--path", "."
end
test do
mkdir testpath/"config"
# Default state configuration file to avoid warning on startup
(testpath/"config/click.config").write <<~EOS
---
namespace: ~
context: ~
editor: ~
terminal: ~
EOS
# Fake K8s configuration
(testpath/"config/config").write <<~EOS
apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: 'https://localhost:6443'
name: test-cluster
contexts:
- context:
cluster: test-cluster
user: test-user
name: test-context
current-context: test-context
kind: Config
preferences:
colors: true
users:
- name: test-cluster
user:
client-certificate-data: >-
invalid
client-key-data: >-
invalid
EOS
# This test cannot test actual K8s connectivity, but it is enough to prove click starts
(testpath/"click-test").write <<~EOS
spawn "#{bin}/click" --config_dir "#{testpath}/config"
expect "*\\[*none*\\]* *\\[*none*\\]* *\\[*none*\\]* >"
send "quit\\r"
EOS
system "expect", "-f", "click-test"
end
end