homebrew-core/Formula/tm.rb

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.14.0.tar.gz"
sha256 "56b4133b096265f459bc44ab68b4f085a31fd1cbf075230a9de3b886b760406f"
license "Apache-2.0"
head "https://github.com/triggermesh/tm.git", branch: "main"
bottle do
sha256 cellar: :any_skip_relocation, arm64_monterey: "7dc35727f294bae8409754cff0e3462fed565c8c19aef526e957cb6509562234"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "9f5d4e164201f3dae27391b9de766b23a0b8b54cb344784f91c44a5644f85132"
sha256 cellar: :any_skip_relocation, monterey: "8bf5790627f1e388982506bbd47f7e520a118c74db38c8cc63f61f64545ce2b6"
sha256 cellar: :any_skip_relocation, big_sur: "d51c43427e855c225399912b28537860b32938db4db0ad94a5da1ca881557c20"
sha256 cellar: :any_skip_relocation, catalina: "dbd1d463c42c8763d354d1fc3fc1ec7106c4775ba06c7690a8b4572a0334f680"
sha256 cellar: :any_skip_relocation, x86_64_linux: "7b269e910e51cf88348d99b13ca3d9d6e21efa5239c6dc17ff9388e814e6fb13"
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