summaryrefslogtreecommitdiff
path: root/lua/promql/health.lua
blob: 03f20b56c2c7c625ddfb76a181487ea4548917f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
local health = vim.health

local M = {}

local binaries = {
  { bin = "promtool", optional = false },
}

local binary_installed = function(binary)
  return vim.fn.executable(binary)
end

M.check = function()
  for _, binary in ipairs(binaries) do
    if not binary_installed(binary.bin) then
      local bin_not_installed = binary.bin .. " not found"
      if binary.optional then
        health.warn(("%s %s"):format(bin_not_installed, binary.info))
      else
        health.error(binary.bin .. " not found")
      end
    else
      health.ok(binary.bin .. " found")
    end
  end
end

return M