homebrew-core/Formula/consul-template.rb
2018-06-12 23:05:44 -07: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.19.5",
:revision => "f8c8205caf458dfd0ecab69d029ab112803aa587"
head "https://github.com/hashicorp/consul-template.git"
bottle do
cellar :any_skip_relocation
sha256 "859b8ac6cb1aaff1d1b7be4b41d0eef356d86634eb76a2601d3cce1626d03bb4" => :high_sierra
sha256 "4bc3abb371cf2a3f6243800d7b9325a0479639d488a20911eff3ff11a68f2a15" => :sierra
sha256 "dec98da73d913cf2a2d4364826427eb42dab3638d09ac198e7f9e449082aa8ad" => :el_capitan
end
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
arch = MacOS.prefer_64_bit? ? "amd64" : "386"
ENV["XC_OS"] = "darwin"
ENV["XC_ARCH"] = arch
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