94 lines
3.5 KiB
Ruby
94 lines
3.5 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.12.0.tar.gz"
|
|
sha256 "33132477d595bab475f4ef7b2d60b971b2e1031f37b262216fdd60f11a9cfcb5"
|
|
license "Apache-2.0"
|
|
head "https://github.com/triggermesh/tm.git", branch: "main"
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_monterey: "7070f94d34159ce7b01dbb92fc2b60904c0c74181a733844a22024e1b48403de"
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "3bc5301e8d8a7b69b141d5fd35532cb291581ae9ed0c5527ea616a7d5629a9c6"
|
|
sha256 cellar: :any_skip_relocation, monterey: "794efa6b502fe00a1c85ac832c34925f5cb5a2962e872e13d7f1f2e3c42ef134"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "b2ebb6f6d1b57643639fd28b955f4ebacd1142366f119696e566b3a233675b54"
|
|
sha256 cellar: :any_skip_relocation, catalina: "86ffbc39f432451cdf042994d9912958ddaf11d67b35955bd497681d9a970f19"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "ee2936f679c2a86b54d5f222179bf88824007fe42278e6bb873c448f32168c49"
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
ldflags = %W[
|
|
-s -w
|
|
-X github.com/triggermesh/tm/cmd.version=v#{version}
|
|
].join(" ")
|
|
|
|
system "go", "build", *std_go_args(ldflags: ldflags)
|
|
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
|