homebrew-core/Formula/kustomize.rb
2019-06-19 08:28:12 +02:00

67 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 => "v2.1.0",
:revision => "af67c893d87c5fb8200f8a3edac7fdafd61ec0bd"
head "https://github.com/kubernetes-sigs/kustomize.git"
bottle do
cellar :any_skip_relocation
sha256 "cd50a743957a1b3f15b6ebd887f0f7c39f248d6b9d75f6182e960a4e5e1715b2" => :mojave
sha256 "80e464ef646f293212bcace956de93804c9556ac45697bb7f5bf75a276261fc9" => :high_sierra
sha256 "2c7ede4c483f6072a35d098778e32dba19550f93d8268c49c9210222daca08e7" => :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
cd dir do
ldflags = %W[
-s -X sigs.k8s.io/kustomize/pkg/commands/misc.kustomizeVersion=#{version}
-X sigs.k8s.io/kustomize/pkg/commands/misc.gitCommit=#{revision}
-X sigs.k8s.io/kustomize/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