homebrew-core/Formula/kustomize.rb
2018-11-04 11:48:04 +00:00

65 lines
1.9 KiB
Ruby

class Kustomize < Formula
desc "Template-free customization of Kubernetes YAML manifests"
homepage "https://github.com/kubernetes-sigs/kustomize"
url "https://github.com/kubernetes-sigs/kustomize.git",
:tag => "v1.0.10",
:revision => "383b3e798b7042f8b7431f93e440fb85631890a3"
bottle do
cellar :any_skip_relocation
sha256 "8413ec0b8fd4f9ee3bac2629b51fafdd5cf81a1cbbc2a19ec12b5bd08a0547c5" => :mojave
sha256 "07f52df1f41f4daf9a8e7b1c2925967ee50527f7f3fc09c4e44fa2c331fd82cd" => :high_sierra
sha256 "3ed58091ed7be69a7432f4e1049cac9b780fed064eeb083196b4f63b60f88d49" => :sierra
end
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
ENV["CGO_ENABLED"] = "0"
revision = Utils.popen_read("git", "rev-parse", "HEAD").strip
tag = Utils.popen_read("git", "describe", "--tags").strip
dir = buildpath/"src/sigs.k8s.io/kustomize"
dir.install buildpath.children - [buildpath/".brew_home"]
cd dir do
ldflags = %W[
-s -X sigs.k8s.io/kustomize/pkg/commands.kustomizeVersion=#{tag}
-X sigs.k8s.io/kustomize/pkg/commands.gitCommit=#{revision}
]
system "go", "install", "-ldflags", ldflags.join(" ")
bin.install buildpath/"bin/kustomize"
prefix.install_metafiles
end
end
test do
assert_match "KustomizeVersion:", shell_output("#{bin}/kustomize version")
(testpath/"kustomization.yaml").write <<~EOS
resources:
- service.yaml
patches:
- patch.yaml
EOS
(testpath/"patch.yaml").write <<~EOS
apiVersion: v1
kind: Service
metadata:
name: brew-test
spec:
selector:
app: foo
EOS
(testpath/"service.yaml").write <<~EOS
apiVersion: v1
kind: Service
metadata:
name: brew-test
spec:
type: LoadBalancer
EOS
output = shell_output("#{bin}/kustomize build #{testpath}")
assert_match /type:\s+"?LoadBalancer"?/, output
end
end