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.0", :revision => "9a0f301b69d841c32f36b78008afb2dee8a9c40b" head "https://github.com/hashicorp/consul-template.git" bottle do cellar :any_skip_relocation sha256 "7559cba6cb21be7511ef392022525f592a357598093f1169b90a6e5305b14ba9" => :mojave sha256 "06faa71caea243c485c42cc7e5401b973462ae191bb3a5fd89527a6dcaa0beec" => :high_sierra sha256 "f5d28452d05955eb0a95206be5d2252f6e4c25438c6a57d7d854f7a1d8242a3d" => :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