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.3",
|
|
revision: "043e8c36e5f6a0e69201256f842342c4b6d33516"
|
|
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: "e969b4596a2613d4a0218d0539247b414f1454761cd45515096828e769940cc3"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "76da148cdd5123bba6c93dcf1acc2f6c336b50068bf91540eebae7cf59770e31"
|
|
sha256 cellar: :any_skip_relocation, catalina: "484f462718022edb82ff247f255e899dd840f9074b8ce806793f93d45bee6fbf"
|
|
sha256 cellar: :any_skip_relocation, mojave: "79d9b040c8f2fc00116b389e393ec788af235534a8998a7407b1303e50c4608c"
|
|
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
|