homebrew-core/Formula/vault.rb

80 lines
2.5 KiB
Ruby

# Please don't update this formula until the release is official via
# mailing list or blog post. There's a history of GitHub tags moving around.
# https://github.com/hashicorp/vault/issues/1051
class Vault < Formula
desc "Secures, stores, and tightly controls access to secrets"
homepage "https://vaultproject.io/"
url "https://github.com/hashicorp/vault.git",
tag: "v1.6.3",
revision: "b540be4b7ec48d0dd7512c8d8df9399d6bf84d76"
license "MPL-2.0"
head "https://github.com/hashicorp/vault.git"
livecheck do
url "https://releases.hashicorp.com/vault/"
regex(%r{href=.*?v?(\d+(?:\.\d+)+)/?["' >]}i)
end
bottle do
sha256 cellar: :any_skip_relocation, big_sur: "79533af24d10955d68163da97bea338253b800c90eb939827cf424558a14cc86"
sha256 cellar: :any_skip_relocation, catalina: "0794305b753438b9631801e9cf4c850ae9cd46170a8ce8e500ce214b2eb11186"
sha256 cellar: :any_skip_relocation, mojave: "143f8720a199827a818954eadc95bbbf6a216333fcc3bb2d1eca8cb278a0710a"
end
depends_on "go" => :build
depends_on "gox" => :build
depends_on "node@10" => :build
depends_on "yarn" => :build
def install
ENV.prepend_path "PATH", "#{ENV["GOPATH"]}/bin"
system "make", "bootstrap", "static-dist", "dev-ui"
bin.install "bin/vault"
end
plist_options manual: "vault server -dev"
def plist
<<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/vault</string>
<string>server</string>
<string>-dev</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{var}</string>
<key>StandardErrorPath</key>
<string>#{var}/log/vault.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/vault.log</string>
</dict>
</plist>
EOS
end
test do
port = free_port
ENV["VAULT_DEV_LISTEN_ADDRESS"] = "127.0.0.1:#{port}"
ENV["VAULT_ADDR"] = "http://127.0.0.1:#{port}"
pid = fork { exec bin/"vault", "server", "-dev" }
sleep 5
system bin/"vault", "status"
Process.kill("TERM", pid)
end
end