kubeless 0.3.0 (new formula)
Closes #19506. Signed-off-by: ilovezfs <ilovezfs@icloud.com>
This commit is contained in:
parent
f2ac6423fe
commit
e271837acc
1 changed files with 77 additions and 0 deletions
77
Formula/kubeless.rb
Normal file
77
Formula/kubeless.rb
Normal file
|
@ -0,0 +1,77 @@
|
|||
class Kubeless < Formula
|
||||
desc "Kubernetes Native Serverless Framework"
|
||||
homepage "https://github.com/kubeless/kubeless"
|
||||
url "https://github.com/kubeless/kubeless.git",
|
||||
:tag => "v0.3.0",
|
||||
:revision => "3103df24bccf67a71bef2ce792592d4ba9f09293"
|
||||
|
||||
depends_on "go" => :build
|
||||
depends_on "kubernetes-cli" => :recommended
|
||||
|
||||
def install
|
||||
commit = Utils.popen_read("git rev-parse --short HEAD").chomp
|
||||
ENV["GOPATH"] = buildpath
|
||||
(buildpath/"src/github.com/kubeless/kubeless").install buildpath.children
|
||||
cd "src/github.com/kubeless/kubeless" do
|
||||
ldflags = %W[
|
||||
-w -X github.com/kubeless/kubeless/version.VERSION=v#{version}
|
||||
-X github.com/kubeless/kubeless/version.GITCOMMIT=#{commit}
|
||||
]
|
||||
system "go", "build", "-o", bin/"kubeless", "-ldflags", ldflags.join(" "),
|
||||
"./cmd/kubeless"
|
||||
prefix.install_metafiles
|
||||
end
|
||||
end
|
||||
|
||||
test do
|
||||
require "socket"
|
||||
|
||||
server = TCPServer.new("127.0.0.1", 0)
|
||||
port = server.addr[1]
|
||||
pid = fork do
|
||||
loop do
|
||||
socket = server.accept
|
||||
response = "OK"
|
||||
socket.print "HTTP/1.1 200 OK\r\n" \
|
||||
"Content-Length: #{response.bytesize}\r\n" \
|
||||
"Connection: close\r\n"
|
||||
socket.print "\r\n"
|
||||
socket.print response
|
||||
socket.close
|
||||
end
|
||||
end
|
||||
|
||||
(testpath/"kube-config").write <<~EOS
|
||||
apiVersion: v1
|
||||
clusters:
|
||||
- cluster:
|
||||
certificate-authority-data: test
|
||||
server: http://127.0.0.1:#{port}
|
||||
name: test
|
||||
contexts:
|
||||
- context:
|
||||
cluster: test
|
||||
user: test
|
||||
name: test
|
||||
current-context: test
|
||||
kind: Config
|
||||
preferences: {}
|
||||
users:
|
||||
- name: test
|
||||
user:
|
||||
token: test
|
||||
EOS
|
||||
|
||||
(testpath/"test.py").write "function_code"
|
||||
|
||||
begin
|
||||
ENV["KUBECONFIG"] = testpath/"kube-config"
|
||||
system bin/"kubeless", "function", "deploy", "--from-file", "test.py",
|
||||
"--runtime", "python2.7", "--handler", "test.foo",
|
||||
"test"
|
||||
ensure
|
||||
Process.kill("TERM", pid)
|
||||
Process.wait(pid)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue