homebrew-core/Formula/kustomize.rb

69 lines
2.0 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: "kustomize/v3.8.2",
revision: "e2973f6ecc9be6187cfd5ecf5e180f842249b3c6"
license "Apache-2.0"
head "https://github.com/kubernetes-sigs/kustomize.git"
livecheck do
url :head
regex(%r{kustomize/v?(\d+(?:\.\d+)+)$}i)
end
bottle do
cellar :any_skip_relocation
rebuild 1
sha256 "601a07e4f64fd9cfaf6d5711affacf90021d6aff686211883b062bb2971a24e8" => :catalina
sha256 "cd22865db58698712c60458745895ef9e54ca77c115c8696299e93ee36fb7b84" => :mojave
sha256 "e165140a287fd347501dce99b3f3e873361063f1a3f70ed16e0e883388fbb6e3" => :high_sierra
end
depends_on "go" => :build
def install
revision = Utils.safe_popen_read("git", "rev-parse", "HEAD").strip
tag = Utils.safe_popen_read("git", "tag", "--contains", "HEAD").strip
cd "kustomize" do
ldflags = %W[
-s -X sigs.k8s.io/kustomize/api/provenance.version=#{tag}
-X sigs.k8s.io/kustomize/api/provenance.gitCommit=#{revision}
-X sigs.k8s.io/kustomize/api/provenance.buildDate=#{Time.now.iso8601}
]
system "go", "build", "-ldflags", ldflags.join(" "), "-o", bin/"kustomize"
end
end
test do
assert_match "kustomize/v#{version}", shell_output("#{bin}/kustomize version")
(testpath/"kustomization.yaml").write <<~EOS
resources:
- service.yaml
patchesStrategicMerge:
- 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