67 lines
2.1 KiB
Ruby
67 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 => "v2.0.2",
|
|
:revision => "b67179e951ebe11d00125bdf3c2670e88dca8817"
|
|
head "https://github.com/kubernetes-sigs/kustomize.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "40b323083b642fe94c7136dc407f0dfa7c0351123ead91f755e2ec2afd5ec7ce" => :mojave
|
|
sha256 "326dedd023477b62faf46307e3d6bf12ebc41da616892ea3d2527a966fad56c6" => :high_sierra
|
|
sha256 "4fecb30cbb4558d7726dfaf682e7c50e5b25301957aa0aaa32c704ccc7361ee1" => :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/misc.kustomizeVersion=#{tag}
|
|
-X sigs.k8s.io/kustomize/pkg/commands/misc.gitCommit=#{revision}
|
|
-X sigs.k8s.io/kustomize/pkg/commands/misc.buildDate=#{Time.now.iso8601}
|
|
]
|
|
system "go", "install", "-ldflags", ldflags.join(" ")
|
|
bin.install buildpath/"bin/kustomize"
|
|
prefix.install_metafiles
|
|
end
|
|
end
|
|
|
|
test do
|
|
assert_match "KustomizeVersion:v#{version}", 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
|