78 lines
2.5 KiB
Ruby
78 lines
2.5 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/v4.0.5",
|
|
revision: "9e8e7a7fe99ec9fbf801463e8607928322fc5245"
|
|
license "Apache-2.0"
|
|
head "https://github.com/kubernetes-sigs/kustomize.git"
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(%r{^kustomize/v?(\d+(?:\.\d+)+)$}i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "350e7316e722e71ec14164e37518836d8894dc145300ab1f7a16c7e6be11ff26"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "0f9593449e5ad9416c98048c19ae23cfa0e47c31a4a6a894ac08934c8c72adaf"
|
|
sha256 cellar: :any_skip_relocation, catalina: "721180bb3af5da9429e586e775deb2bc9880e6482db64782185e25d683206f71"
|
|
sha256 cellar: :any_skip_relocation, mojave: "7082426de27c2f8a4e740c31ee312255cdb318a1932168ce77e186594e6f1e92"
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
commit = Utils.git_head
|
|
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=#{commit}
|
|
-X sigs.k8s.io/kustomize/api/provenance.buildDate=#{Time.now.iso8601}
|
|
]
|
|
system "go", "build", "-ldflags", ldflags.join(" "), "-o", bin/"kustomize"
|
|
end
|
|
|
|
output = Utils.safe_popen_read("#{bin}/kustomize", "completion", "bash")
|
|
(bash_completion/"kustomize").write output
|
|
|
|
output = Utils.safe_popen_read("#{bin}/kustomize", "completion", "zsh")
|
|
(zsh_completion/"_kustomize").write output
|
|
|
|
output = Utils.safe_popen_read("#{bin}/kustomize", "completion", "fish")
|
|
(fish_completion/"kustomize.fish").write output
|
|
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
|