homebrew-core/Formula/kustomize.rb

69 lines
2.1 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.7",
revision: "ad092cc7a91c07fdf63a2e4b7f13fa588a39af4f"
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
sha256 "8acb76a17f3e1ffb883afad25067d7c0edb3b97be50c716a7c50f67d4f830d5e" => :big_sur
sha256 "4f8c41d3363378894b482f1e836f3feedb296ff999519142f6b4493109960a10" => :catalina
sha256 "9f68b22960ab0ee9ef69dd3e12d5f39b8f5f7c233c8840a2327013ce07d28ec8" => :mojave
sha256 "1be07ef980cf63b9bd3b89a47bc08101f18afd6c65c3a9b8847b615dc7d22a0c" => :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