70 lines
2.4 KiB
Ruby
70 lines
2.4 KiB
Ruby
class InfluxdbCli < Formula
|
|
desc "CLI for managing resources in InfluxDB v2"
|
|
homepage "https://influxdata.com/time-series-platform/influxdb/"
|
|
url "https://github.com/influxdata/influx-cli.git",
|
|
tag: "v2.1.0",
|
|
revision: "e6cad1b4aa05a801e1206496c3369246794555e0"
|
|
license "MIT"
|
|
head "https://github.com/influxdata/influx-cli.git", branch: "main"
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(/^v?((?!9\.9\.9)\d+(?:\.\d+)+)$/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "6cca0d7713416283475fe3fbeacd2b4e9d469c604583c14e3a405667e11d1980"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "c80bf2710eb7f7dd31d298040eb25aa5f4a85ee7fc0c541c791695f7cf9ab393"
|
|
sha256 cellar: :any_skip_relocation, catalina: "ae54b73f3987ed34ab7900017945cf2a493011dc40113f3ad064535f9bb01a28"
|
|
sha256 cellar: :any_skip_relocation, mojave: "11edb46b688e44bec5a372d551a92ef23c18e4656443c5d767609d384f4243ec"
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
depends_on "influxdb" => :test
|
|
|
|
def install
|
|
ldflags = %W[
|
|
-s
|
|
-w
|
|
-X main.version=#{version}
|
|
-X main.commit=#{Utils.git_short_head(length: 10)}
|
|
-X main.date=#{time.iso8601}
|
|
].join(" ")
|
|
|
|
system "go", "build", *std_go_args(ldflags: ldflags),
|
|
"-o", bin/"influx", "./cmd/influx"
|
|
end
|
|
|
|
test do
|
|
# Boot a test server.
|
|
influxd_port = free_port
|
|
influxd = fork do
|
|
exec "influxd", "--bolt-path=#{testpath}/influxd.bolt",
|
|
"--engine-path=#{testpath}/engine",
|
|
"--http-bind-address=:#{influxd_port}",
|
|
"--log-level=error"
|
|
end
|
|
sleep 30
|
|
|
|
# Configure the CLI for the test env.
|
|
influx_host = "http://localhost:#{influxd_port}"
|
|
cli_configs_path = "#{testpath}/influx-configs"
|
|
ENV["INFLUX_HOST"] = influx_host
|
|
ENV["INFLUX_CONFIGS_PATH"] = cli_configs_path
|
|
|
|
# Check that the CLI can connect to the server.
|
|
assert_match "OK", shell_output("#{bin}/influx ping")
|
|
|
|
# Perform initial DB setup.
|
|
system "#{bin}/influx", "setup", "-u", "usr", "-p", "fakepassword", "-b", "bkt", "-o", "org", "-f"
|
|
|
|
# Assert that initial resources show in CLI output.
|
|
assert_match "usr", shell_output("#{bin}/influx user list")
|
|
assert_match "bkt", shell_output("#{bin}/influx bucket list")
|
|
assert_match "org", shell_output("#{bin}/influx org list")
|
|
ensure
|
|
Process.kill("TERM", influxd)
|
|
Process.wait influxd
|
|
end
|
|
end
|