homebrew-core/Formula/consul-template.rb
2019-11-14 11:50:47 -05:00

44 lines
1.6 KiB
Ruby

class ConsulTemplate < Formula
desc "Generic template rendering and notifications with Consul"
homepage "https://github.com/hashicorp/consul-template"
url "https://github.com/hashicorp/consul-template.git",
:tag => "v0.23.0",
:revision => "521adf1df1b6640fddc06462c21c645f054f55b4"
head "https://github.com/hashicorp/consul-template.git"
bottle do
cellar :any_skip_relocation
sha256 "8ecc8df95c94b73382f690c9d2301ee9a5a8eded8b1e8c944e8f8363a3701de8" => :catalina
sha256 "6e4ef92c9d9df78fbf8c33a927a96d93a5999cdf9d8ff8b367c898737d955a3a" => :mojave
sha256 "33068b4281a72484886af4fb598fd24510d7065957e52cbbcf8f6bb70d23e277" => :high_sierra
end
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
ENV["XC_OS"] = "darwin"
ENV["XC_ARCH"] = "amd64"
dir = buildpath/"src/github.com/hashicorp/consul-template"
dir.install buildpath.children - [buildpath/".brew_home"]
cd dir do
project = "github.com/hashicorp/consul-template"
commit = Utils.popen_read("git rev-parse --short HEAD").chomp
ldflags = ["-X #{project}/version.Name=consul-template",
"-X #{project}/version.GitCommit=#{commit}"]
system "go", "build", "-o", bin/"consul-template", "-ldflags",
ldflags.join(" ")
prefix.install_metafiles
end
end
test do
(testpath/"template").write <<~EOS
{{"homebrew" | toTitle}}
EOS
system bin/"consul-template", "-once", "-template", "template:test-result"
assert_equal "Homebrew", (testpath/"test-result").read.chomp
end
end