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.20.1", :revision => "668c77b30f6ddcb5c80856dbec6f16b86f1b7023" head "https://github.com/hashicorp/consul-template.git" bottle do cellar :any_skip_relocation sha256 "fe5380c1104a607b3970058432c75a798999bf63afa588db28428e84e933701e" => :mojave sha256 "c809f774afb8305d1a581b7a2869cf42ca311370cf233a3b13b0988ee9a0afe8" => :high_sierra sha256 "f181d44f0d605373b0bf1b6452fa0b6f5a7157355808ba3023ec5dc39c8944f1" => :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