Skip to content

Commit c1f597a

Browse files
authored
tools/homebrew: use hashicorp/tap/terraform for terraform (#87)
* Move the homebrew template into a different file and embed it into the binary * Retab the homebrew template to use spaces instead of tabs as it's Ruby * Update the terraform dep to use hashicorp/tap/terraform Signed-off-by: Ryan Cragun <[email protected]>
1 parent 479e7e7 commit c1f597a

File tree

4 files changed

+88
-87
lines changed

4 files changed

+88
-87
lines changed

tools/homebrew/main.go

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"bufio"
55
"bytes"
6+
"embed"
67
"fmt"
78
"io"
89
"os"
@@ -22,56 +23,10 @@ func main() {
2223
}
2324
}
2425

25-
const formulaTemplate = `require_relative "../Strategies/private_strategy"
26-
class Enos < Formula
27-
desc "A tool for powering Software Quality as Code by writing Terraform-based quality requirement scenarios using a composable and shareable declarative language."
28-
homepage "https://github.com/hashicorp/enos"
29-
version "{{.Version}}"
30-
31-
depends_on "terraform"
32-
33-
on_macos do
34-
if Hardware::CPU.arm?
35-
url "https://github.com/hashicorp/enos/releases/download/{{.VersionTag}}/enos_{{.Version}}_darwin_arm64.zip", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
36-
sha256 "{{.DarwinARM64SHA}}"
37-
38-
def install
39-
bin.install "enos"
40-
end
41-
end
42-
if Hardware::CPU.intel?
43-
url "https://github.com/hashicorp/enos/releases/download/{{.VersionTag}}/enos_{{.Version}}_darwin_amd64.zip", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
44-
sha256 "{{.DarwinAMD64SHA}}"
45-
46-
def install
47-
bin.install "enos"
48-
end
49-
end
50-
end
51-
52-
on_linux do
53-
if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
54-
url "https://github.com/hashicorp/enos/releases/download/{{.VersionTag}}/enos_{{.Version}}_linux_arm64.zip", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
55-
sha256 "{{.LinuxARM64SHA}}"
56-
57-
def install
58-
bin.install "enos"
59-
end
60-
end
61-
if Hardware::CPU.intel?
62-
url "https://github.com/hashicorp/enos/releases/download/{{.VersionTag}}/enos_{{.Version}}_linux_amd64.zip", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
63-
sha256 "{{.LinuxAMD64SHA}}"
64-
65-
def install
66-
bin.install "enos"
67-
end
68-
end
69-
end
70-
end
71-
`
72-
73-
// Create a new template
74-
var t = template.Must(template.New("formula").Parse(formulaTemplate))
26+
//go:embed support/enos.rb.tmpl
27+
var formulaTemplate embed.FS
28+
29+
var t = template.Must(template.ParseFS(formulaTemplate, "support/enos.rb.tmpl"))
7530

7631
var rootCmd = cobra.Command{
7732
Use: "homebrew",

tools/homebrew/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ func Test_renderHomebrewFormulaTemplate(t *testing.T) {
4747
expected, err := io.ReadAll(f)
4848
require.NoError(t, err)
4949

50-
require.Equal(t, expected, buf.Bytes())
50+
require.Equal(t, string(expected), buf.String())
5151
}

tools/homebrew/support/enos.rb

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
require_relative "../Strategies/private_strategy"
22
class Enos < Formula
3-
desc "A tool for powering Software Quality as Code by writing Terraform-based quality requirement scenarios using a composable and shareable declarative language."
4-
homepage "https://github.com/hashicorp/enos"
5-
version "0.0.1"
3+
desc "A tool for powering Software Quality as Code by writing Terraform-based quality requirement scenarios using a composable and shareable declarative language."
4+
homepage "https://github.com/hashicorp/enos"
5+
version "0.0.1"
66

7-
depends_on "terraform"
7+
depends_on "hashicorp/tap/terraform"
88

9-
on_macos do
10-
if Hardware::CPU.arm?
11-
url "https://github.com/hashicorp/enos/releases/download/v0.0.1/enos_0.0.1_darwin_arm64.zip", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
12-
sha256 "15d82aa03f5585966bc747e04ee31c025391dc1c80b3ba6419c95f6b764eebbd"
9+
on_macos do
10+
if Hardware::CPU.arm?
11+
url "https://github.com/hashicorp/enos/releases/download/v0.0.1/enos_0.0.1_darwin_arm64.zip", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
12+
sha256 "15d82aa03f5585966bc747e04ee31c025391dc1c80b3ba6419c95f6b764eebbd"
1313

14-
def install
15-
bin.install "enos"
16-
end
17-
end
18-
if Hardware::CPU.intel?
19-
url "https://github.com/hashicorp/enos/releases/download/v0.0.1/enos_0.0.1_darwin_amd64.zip", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
20-
sha256 "788eda2be1887fa13b2aca2a5bcad4535278310946c8f6f68fa561e72f7a351b"
14+
def install
15+
bin.install "enos"
16+
end
17+
end
18+
if Hardware::CPU.intel?
19+
url "https://github.com/hashicorp/enos/releases/download/v0.0.1/enos_0.0.1_darwin_amd64.zip", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
20+
sha256 "788eda2be1887fa13b2aca2a5bcad4535278310946c8f6f68fa561e72f7a351b"
2121

22-
def install
23-
bin.install "enos"
24-
end
25-
end
26-
end
22+
def install
23+
bin.install "enos"
24+
end
25+
end
26+
end
2727

28-
on_linux do
29-
if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
30-
url "https://github.com/hashicorp/enos/releases/download/v0.0.1/enos_0.0.1_linux_arm64.zip", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
31-
sha256 "2a1677b83d6ec24038ef949420afa79269a405e35396aefec432412233cfc251"
28+
on_linux do
29+
if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
30+
url "https://github.com/hashicorp/enos/releases/download/v0.0.1/enos_0.0.1_linux_arm64.zip", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
31+
sha256 "2a1677b83d6ec24038ef949420afa79269a405e35396aefec432412233cfc251"
3232

33-
def install
34-
bin.install "enos"
35-
end
36-
end
37-
if Hardware::CPU.intel?
38-
url "https://github.com/hashicorp/enos/releases/download/v0.0.1/enos_0.0.1_linux_amd64.zip", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
39-
sha256 "dc1f9597b024b59bf444d894c633c3fe796b7d57d74d7983ad57c4d7d37a516d"
33+
def install
34+
bin.install "enos"
35+
end
36+
end
37+
if Hardware::CPU.intel?
38+
url "https://github.com/hashicorp/enos/releases/download/v0.0.1/enos_0.0.1_linux_amd64.zip", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
39+
sha256 "dc1f9597b024b59bf444d894c633c3fe796b7d57d74d7983ad57c4d7d37a516d"
4040

41-
def install
42-
bin.install "enos"
43-
end
44-
end
45-
end
41+
def install
42+
bin.install "enos"
43+
end
44+
end
45+
end
4646
end
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
require_relative "../Strategies/private_strategy"
2+
class Enos < Formula
3+
desc "A tool for powering Software Quality as Code by writing Terraform-based quality requirement scenarios using a composable and shareable declarative language."
4+
homepage "https://github.com/hashicorp/enos"
5+
version "{{.Version}}"
6+
7+
depends_on "hashicorp/tap/terraform"
8+
9+
on_macos do
10+
if Hardware::CPU.arm?
11+
url "https://github.com/hashicorp/enos/releases/download/{{.VersionTag}}/enos_{{.Version}}_darwin_arm64.zip", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
12+
sha256 "{{.DarwinARM64SHA}}"
13+
14+
def install
15+
bin.install "enos"
16+
end
17+
end
18+
if Hardware::CPU.intel?
19+
url "https://github.com/hashicorp/enos/releases/download/{{.VersionTag}}/enos_{{.Version}}_darwin_amd64.zip", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
20+
sha256 "{{.DarwinAMD64SHA}}"
21+
22+
def install
23+
bin.install "enos"
24+
end
25+
end
26+
end
27+
28+
on_linux do
29+
if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
30+
url "https://github.com/hashicorp/enos/releases/download/{{.VersionTag}}/enos_{{.Version}}_linux_arm64.zip", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
31+
sha256 "{{.LinuxARM64SHA}}"
32+
33+
def install
34+
bin.install "enos"
35+
end
36+
end
37+
if Hardware::CPU.intel?
38+
url "https://github.com/hashicorp/enos/releases/download/{{.VersionTag}}/enos_{{.Version}}_linux_amd64.zip", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
39+
sha256 "{{.LinuxAMD64SHA}}"
40+
41+
def install
42+
bin.install "enos"
43+
end
44+
end
45+
end
46+
end

0 commit comments

Comments
 (0)