Skip to content

Commit

Permalink
Add simple health check
Browse files Browse the repository at this point in the history
  • Loading branch information
erichlf committed Apr 27, 2024
1 parent af3f409 commit 5988560
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Devcontainer CLI (Nvim Plugin)
# Devcontainer CLI (NVIM Plugin)

Develop your next Repo in a Devcontainer using Nvim thanks to the
Develop your next Repo in a Devcontainer using *nvim* thanks to the
[Devconatiner CLI](https://github.com/devcontainers/cli) and this plugin
![](doc/gifs/nvim_devcontainer_cli-description.gif)

Expand Down Expand Up @@ -54,7 +54,7 @@ But, what is happening under the hood?
A very nice devcontainer feature that can do this is
[apt package](https://github.com/rocker-org/devcontainer-features/tree/main/src/apt-packages).
3. The last step is connecting inside the container via `devcontainer exec`
([here](https://github.com/erichlf/nvim-devcontainer-cli/blob/main/bin/connect_to_devcontainer.sh)).
([here](https://github.com/erichlf/devcontainer-cli.nvim/blob/main/bin/connect_to_devcontainer.sh)).

The main thing this plugin does is bringup your devcontainer and execute
commands via a convenient interface. It attempts to stay out of your way and
Expand All @@ -63,7 +63,7 @@ allows you to do things as you wish, but gives you the tools to do that easily.
**Inspiration:**

This plugin has been inspired by the work previously done by
[arnaupv](https://github.com/arnaupv/nvim-devcontainer-cli),
[arnaupv](https://github.com/arnaupv/devcontainer-cli.nvim),
[esensar](https://github.com/esensar/nvim-dev-container) and by
[jamestthompson3](https://github.com/jamestthompson3/nvim-remote-containers).
The main difference between this version and arnaupv is that it tries to not
Expand All @@ -80,7 +80,7 @@ make assumptions about how you work.

```lua
{
"erichlf/nvim-devcontainer-cli",
"erichlf/devcontainer-cli.nvim",
opts = {
-- whather to verify that the final devcontainer should be run
interactive = false,
Expand Down Expand Up @@ -178,7 +178,7 @@ make test
1. [x] Capability to create and run a devcontainer using the [Devconatiner CLI](https://github.com/devcontainers/cli).
2. [x] Capability to attach in a running devcontainer.
3. [x] The floating window created during the devcontainer Up process (:DevcontainerUp<cr>) is closed when the process finishes successfully.
4. [x] [Give the possibility of defining custom dotfiles when setting up the devcontainer](https://github.com/erichlf/nvim-devcontainer-cli/issues/1)
4. [x] [Give the possibility of defining custom dotfiles when setting up the devcontainer](https://github.com/erichlf/devcontainer-cli.nvim/issues/1)
5. [ ] Add unit tests using plenary.busted lua module.
6. [ ] The logs printed in the floating window when preparing the Devcontainer are saved and easy to access.
7. [ ] Convert bash scripts in lua code.
6 changes: 3 additions & 3 deletions doc/devcontainer_cli.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
================================================================================
*nvim-devcontainer-cli*
*devcontainer-cli.nvim*

nvim-devcontainer-cli is a nvim plugin which intends to use the devcontainer-cli
devcontainer-cli.nvim is a nvim plugin which intends to use the devcontainer-cli
developed by microsoft for creating your own local development environments when
developing docker containers.

Development is in progress, but the plugin can already be used.

To find out more:
https://github.com/erichlf/nvim-devcontainer-cli
https://github.com/erichlf/devcontainer-cli.nvim

:h DevcontainerUp

Expand Down
29 changes: 29 additions & 0 deletions lua/devcontainer_cli/health.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
local remote_nvim = require("remote-nvim")
local utils = require("remote-nvim.utils")
local M = {}

local function verify_binary(binary_name)
local succ, _ = pcall(utils.find_binary, binary_name)
if not succ then
vim.health.error(("`%s` executable not found."):format(binary_name))
else
vim.health.ok(("`%s` executable found."):format(binary_name))
end
end
-- TODO: create a test that checks that a devcontainer can be brought up,
-- this needs to be done after creating the ability to stop a container
-- TODO: create a test that checks that a command can be executed within the
-- running container

function M.check()
vim.health.start("devcontainer_cli")
local required_binaries = {
"docker",
"devcontainer-cli",
}
for _, bin_name in ipairs(required_binaries) do
verify_binary(bin_name)
end
end

return M

0 comments on commit 5988560

Please sign in to comment.