92 lines
3.0 KiB
Ruby
92 lines
3.0 KiB
Ruby
class Tm < Formula
|
|
desc "TriggerMesh CLI to work with knative objects"
|
|
homepage "https://triggermesh.com"
|
|
url "https://github.com/triggermesh/tm/archive/v1.0.0.tar.gz"
|
|
sha256 "cca47e3a51bf0fcaada1e4afe03f4eb6aa63e75a7819fd7e8cae1c91e5d939b4"
|
|
license "Apache-2.0"
|
|
head "https://github.com/triggermesh/tm.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "5f37b9116247e25c34b6888bbecb20f3e3998f293a16ac69502579cf44d33954" => :big_sur
|
|
sha256 "557c1d43923c836f9428f43a48fd385856524a72e30e7bd8e66cdf2dcc3e5e67" => :catalina
|
|
sha256 "e2345f38c556f7dd62a3a19cef806ea1a7c24266cc200964e22c8341425ecf0e" => :mojave
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
ldflags = %W[
|
|
-s -w
|
|
-X github.com/triggermesh/tm/cmd.version=v#{version}
|
|
]
|
|
|
|
system "go", "build", *std_go_args, "-ldflags", ldflags.join(" ")
|
|
end
|
|
|
|
test do
|
|
(testpath/"kubeconfig").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
|
|
|
|
ENV["KUBECONFIG"] = testpath/"kubeconfig"
|
|
|
|
# version
|
|
version_output = shell_output("#{bin}/tm version")
|
|
assert_match "Triggermesh CLI, version v#{version}", version_output
|
|
|
|
# node
|
|
system "#{bin}/tm", "generate", "node", "foo-node"
|
|
assert_predicate testpath/"foo-node/serverless.yaml", :exist?
|
|
assert_predicate testpath/"foo-node/handler.js", :exist?
|
|
|
|
runtime = "https://raw.githubusercontent.com/triggermesh/knative-lambda-runtime/master/node10/runtime.yaml"
|
|
yaml = File.read("foo-node/serverless.yaml")
|
|
assert_match "runtime: #{runtime}", yaml
|
|
|
|
# python
|
|
system "#{bin}/tm", "generate", "python", "foo-python"
|
|
assert_predicate testpath/"foo-python/serverless.yaml", :exist?
|
|
assert_predicate testpath/"foo-python/handler.py", :exist?
|
|
|
|
runtime = "https://raw.githubusercontent.com/triggermesh/knative-lambda-runtime/master/python37/runtime.yaml"
|
|
yaml = File.read("foo-python/serverless.yaml")
|
|
assert_match "runtime: #{runtime}", yaml
|
|
|
|
# go
|
|
system "#{bin}/tm", "generate", "go", "foo-go"
|
|
assert_predicate testpath/"foo-go/serverless.yaml", :exist?
|
|
assert_predicate testpath/"foo-go/main.go", :exist?
|
|
|
|
runtime = "https://raw.githubusercontent.com/triggermesh/knative-lambda-runtime/master/go/runtime.yaml"
|
|
yaml = File.read("foo-go/serverless.yaml")
|
|
assert_match "runtime: #{runtime}", yaml
|
|
|
|
# ruby
|
|
system "#{bin}/tm", "generate", "ruby", "foo-ruby"
|
|
assert_predicate testpath/"foo-ruby/serverless.yaml", :exist?
|
|
assert_predicate testpath/"foo-ruby/handler.rb", :exist?
|
|
|
|
runtime = "https://raw.githubusercontent.com/triggermesh/knative-lambda-runtime/master/ruby25/runtime.yaml"
|
|
yaml = File.read("foo-ruby/serverless.yaml")
|
|
assert_match "runtime: #{runtime}", yaml
|
|
end
|
|
end
|