-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
local commands = require 'kubectl.actions.commands' | ||
local tables = require 'kubectl.utils.tables' | ||
|
||
vim.schedule(function() | ||
vim.api.nvim_buf_set_keymap(0, 'n', '<Plug>(kubectl.select)', '', { | ||
noremap = true, | ||
silent = true, | ||
desc = 'Go to application', | ||
callback = function() | ||
local _, buf_name = pcall(vim.api.nvim_buf_get_var, 0, 'buf_name') | ||
local lower_buf_name = string.lower(buf_name) | ||
|
||
if lower_buf_name == 'applications.argoproj.io' then | ||
local name = tables.getCurrentSelection(2) | ||
if not name then | ||
return | ||
end | ||
local ingress_host = commands.shell_command( | ||
'kubectl', | ||
{ 'get', 'ingress', '-n', 'argocd', '-l', 'app.kubernetes.io/component=server', '-o', 'jsonpath={.items[].spec.rules[].host}' } | ||
) | ||
|
||
local final_host = string.format('https://%s/applications/argocd/%s', ingress_host, name) | ||
vim.notify('Opening ' .. final_host) | ||
vim.ui.open(final_host) | ||
end | ||
end, | ||
}) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters