66 lines
2 KiB
Ruby
66 lines
2 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 => "v2.0.1",
|
|
:revision => "ce7e5ee2c30cc5856fea01fe423cf167f2a2d0c3"
|
|
head "https://github.com/kubernetes-sigs/kustomize.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "1e68c6e2c149ee16acababbfd675eedec2447af3036dc26dd111354a3c64cdaa" => :mojave
|
|
sha256 "d5d03a7c6b55c1a8c7cdfcb78caaa34273f7a0e38334bc109d40069b6428eb07" => :high_sierra
|
|
sha256 "14426a1904e5e60f1fdbb873f203ab41e653f76fa2adb225ffde669f893125a0" => :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
|