|
| 1 | +class Fnox < Formula |
| 2 | + desc "Fort Knox for your secrets - flexible secret management tool" |
| 3 | + homepage "https://fnox.jdx.dev/" |
| 4 | + url "https://github.com/jdx/fnox/archive/refs/tags/v1.5.2.tar.gz" |
| 5 | + sha256 "93e47266a278ebdb203e3cbd96cda775923b1c1ee15cb6791a67e2dba7ab54ff" |
| 6 | + license "MIT" |
| 7 | + head "https://github.com/jdx/fnox.git", branch: "main" |
| 8 | + |
| 9 | + bottle do |
| 10 | + sha256 cellar: :any_skip_relocation, arm64_tahoe: "9d14f559608e0e3c6028c2087ad23a3685720ccec6dd6a652e46e2f42331a584" |
| 11 | + sha256 cellar: :any_skip_relocation, arm64_sequoia: "d01cd1d29c7a2ea35057f6a541511b4121d6d9493197c5ddcbd5dcbca9f2ddee" |
| 12 | + sha256 cellar: :any_skip_relocation, arm64_sonoma: "c93fc57d70ad41f741644d0e21874fdc8ab9f8be4c0b31ad2ffa65536e661472" |
| 13 | + sha256 cellar: :any_skip_relocation, sonoma: "e2b3eb2bc7cf9ff61fc2656accc94b276763b520574fc43cc11a70ad1d8561b7" |
| 14 | + sha256 cellar: :any_skip_relocation, arm64_linux: "ba5e7319c1eb7c94c41648eeb9ff6f4e06b4df258b2ba2b0bf24bf397841dba5" |
| 15 | + sha256 cellar: :any_skip_relocation, x86_64_linux: "cf4064aefd82c5a176ab9c35e7ca565c68b5a2411502fa10e18b11052a3eb950" |
| 16 | + end |
| 17 | + |
| 18 | + depends_on "pkgconf" => :build |
| 19 | + depends_on "rust" => :build |
| 20 | + depends_on "age" => :test |
| 21 | + depends_on "usage" |
| 22 | + |
| 23 | + on_linux do |
| 24 | + depends_on "openssl@3" |
| 25 | + end |
| 26 | + |
| 27 | + def install |
| 28 | + # Ensure that the `openssl` crate picks up the intended library. |
| 29 | + ENV["OPENSSL_DIR"] = Formula["openssl@3"].opt_prefix |
| 30 | + ENV["OPENSSL_NO_VENDOR"] = "1" |
| 31 | + |
| 32 | + system "cargo", "install", *std_cargo_args |
| 33 | + |
| 34 | + generate_completions_from_executable(bin/"fnox", "completion") |
| 35 | + end |
| 36 | + |
| 37 | + test do |
| 38 | + assert_match version.to_s, shell_output("#{bin}/fnox --version") |
| 39 | + |
| 40 | + test_key = shell_output("age-keygen") |
| 41 | + test_key_line = test_key.lines.grep(/^# public key:/).first.sub(/^# public key: /, "").strip |
| 42 | + secret_key_line = test_key.lines.grep(/^AGE-SECRET-KEY-/).first.strip |
| 43 | + |
| 44 | + (testpath/"fnox.toml").write <<~TOML |
| 45 | + [providers] |
| 46 | + age = { type = "age", recipients = ["#{test_key_line}"] } |
| 47 | + TOML |
| 48 | + |
| 49 | + ENV["FNOX_AGE_KEY"] = secret_key_line |
| 50 | + system bin/"fnox", "set", "TEST_SECRET", "test-secret-value", "--provider", "age" |
| 51 | + assert_match "TEST_SECRET", shell_output("#{bin}/fnox list") |
| 52 | + assert_match "test-secret-value", shell_output("#{bin}/fnox get TEST_SECRET") |
| 53 | + end |
| 54 | +end |
0 commit comments