Skip to content

Commit

Permalink
Merge pull request #40 from desdic/feature/kitchenlogin
Browse files Browse the repository at this point in the history
feat(kitchen): add kitchen login if suite is converged
  • Loading branch information
desdic authored Sep 2, 2024
2 parents 8e43bc5 + 95397e0 commit b9b6e33
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions lua/greyjoy/_extensions/kitchen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ local health = vim.health
local M = {}
local uv = vim.uv

local valid_target = function(target, suite)
if target ~= "login" then
return true
end

if
target == "login" and utils.file_exists(".kitchen/" .. suite .. ".yml")
then
return true
end

return false
end

M.parse = function(fileinfo)
if type(fileinfo) ~= "table" then
vim.notify(
Expand Down Expand Up @@ -61,15 +75,17 @@ M.parse = function(fileinfo)
table.insert(tmp, "all")
end

for _, v in ipairs(tmp) do
if v ~= "" then
for _, suite in ipairs(tmp) do
if suite ~= "" then
for _, target in ipairs(M.config.targets) do
local elem = {}
elem["name"] = "kitchen " .. target .. " " .. v
elem["command"] = { "kitchen", target, v }
elem["path"] = filepath
elem["plugin"] = "kitchen"
table.insert(elements, elem)
if valid_target(target, suite) then
local elem = {}
elem["name"] = "kitchen " .. target .. " " .. suite
elem["command"] = { "kitchen", target, suite }
elem["path"] = filepath
elem["plugin"] = "kitchen"
table.insert(elements, elem)
end
end
end
end
Expand All @@ -96,7 +112,8 @@ M.setup = function(config)
M.config = config

if not M.config.targets then
M.config["targets"] = { "converge", "verify", "test", "destroy" }
M.config["targets"] =
{ "converge", "verify", "test", "destroy", "login" }
end

M.config.include_all = utils.if_nil(M.config.include_all, false)
Expand Down

0 comments on commit b9b6e33

Please sign in to comment.