homebrew-core/Formula/kustomize.rb
2019-07-13 14:20:35 +02:00

66 lines
2 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 => "v3.0.2",
:revision => "aa2313c2825a7712b12309c1cd7798f371a0bb18"
head "https://github.com/kubernetes-sigs/kustomize.git"
bottle do
cellar :any_skip_relocation
sha256 "02bf820f389fbe121b43e094fcdc75b69a6426d7419519eb5d02fde320767d99" => :mojave
sha256 "826822195a990807abc5114f9df3a6f8edb88fab6cd742b245f38bddbe841149" => :high_sierra
sha256 "238ae6fb878b34ccf1633e6af4e4c2f4081e7ceaa91f3f0ab9d76e39319bfaa0" => :sierra
end
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
ENV["GO111MODULE"] = "on"
revision = Utils.popen_read("git", "rev-parse", "HEAD").strip
dir = buildpath/"src/kubernetes-sigs/kustomize"
dir.install buildpath.children
dir.cd do
ldflags = %W[
-s -X sigs.k8s.io/kustomize/v3/pkg/commands/misc.kustomizeVersion=#{version}
-X sigs.k8s.io/kustomize/v3/pkg/commands/misc.gitCommit=#{revision}
-X sigs.k8s.io/kustomize/v3/pkg/commands/misc.buildDate=#{Time.now.iso8601}
]
system "go", "build", "-ldflags", ldflags.join(" "), "-o", bin/"kustomize", "cmd/kustomize/main.go"
prefix.install_metafiles
end
end
test do
assert_match version.to_s, 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