* refactor(enter): define command options
Refactor the `enter` command package so that adheres to the convention
to define its own arguments as options and read them in the Execute
method.
* refactor(containermanager): add InspectContainer to the public interface
* refactor(rm): move preflight checks in the command layer
That simplifies the containermanager.Remove interface and improve the
separation between the container manager and the presentation logic as
prompting it's not handled at containermanager level anymore.
It also improves efficiency as the userenv is fetch only once.
* refactor(ui): pass the prompter by reference
Use pointer to optimize memory footprint. It also allows nullable
references, hence a validation is required for the `rm` command when
executing on interactive mode.
* feat(ephemeral): add ephemeral command
The command is a composition of create, enter and rm commands.
It accepts the same arguments as the create command.
Add the stop command to stop executing containers. The command is a
wrapper of the container manager's stop feature.
If no container name is provided and the `--all` flag is not set, the
default container name is implied.
* add Exists function to containermanager
This public function tells if the container exists or not.
No output parsing is necessary, hence for performance we avoid using the
already-present InspectContainer function.
* fail if container with the same name already exists
* output error
Replace helper functions (lastString, lastBool, allStrings, splitString)
with a single loop that fetches ValueWithShadows() once per key. This
avoids repeated calls to the ini library for each field.
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
* move the Propter under screen package
* add color formatters
* add progress
This module allows for printing a sequence of lines with check marks.
Useful to show progress on a long running action (example: container
init).
* implement progess on create
* implement progress on assemble
* implement progress on enter
* implement color
* move internal/screen to pkg/ui
* add printer
* implement printer
* fix progress finalize method
* fix progress implementation for enter command
Manifest can either be file or remote URLs. In the latter case, the content is fetched into a temporary file; then the parsing follows as usual.
Note that the HTTP fetch has no constraint on protocol to use nor an allowed list of URLs, just like in the original `assemble` command. https://github.com/89luca89/distrobox/blob/main/distrobox-assemble#L240
```
if command -v curl > /dev/null 2>&1; then
download="curl --connect-timeout 3 --retry 1 -sLo"
elif command -v wget > /dev/null 2>&1; then
download="wget --timeout=3 --tries=1 -qO"
```
The only difference with the original implementation is that the file input is checked to be a valid URL.
* feat(enter): rewrite in go
* chore: make InspectContainer public
* chore: use userenv package for user's environment
* chore: export InspectResult type for convenience
* fix: rename containerInspect to inpectOutput
* fix: use userenv inside generateEnterCommand
* fix(enter): more userenv
* chore: add some unit tests for buildContainerPath and buildCommandArgs
* embed shell scripts to execute inside the distrobox
The command init, export and host-exec must be accessible from inside
the distrobox container.
When needed, the embedded scripts will be written to a host directory
and then mounted as volume on the created container.
The host directory is determined by configuration and environment
variables.
The script will be not converted to GO to keep then
architecture-agnostic.
* add Create to the Docker container manager
The function will compose argument string to append to the `docker`
command.
If `DryRun=true`, the command is just printed on screen and not
executed.
* add Create command package
* mount cli command
* add GenerateEntryCommand package
The package mimics the actual distrobox-generate-entry shell command
that installs a desktop entry file so that the host's desktop
environment can render the appropriate application icon.
This first implementantion scaffolds the command package and implements
the simplest scenario for a single container.
* delete entry
If the `delete` flag is provided, the command remove the desktop entry
if present.
Deleting a non-existing item does not raise an error.
* generate entries for all containers
With `opts.All` we implement an abstraction over the
`GenerateEntryCommand` that iterates across all the containers to
generate or delete the relative desktop entries.
`ListCommand` is used to fetch the list of containers.
* mount the generate-entry cli command
Mount the command so that is reachable from the CLI. Define parameters
with type and basic validation.
Depending on the flag `--all`, the appropriate set of options is provided
to the `GenerateEntryCommand.Execute()` method.
If `--all` is set, `container-name` and `icon` arguments will be ignored.
* feat(cli): validate sudo (sudo -v) in beforeCommand if --root is set
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
* feat(docker): add root and sudoCommand and execute commands with sudo if root is set
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
* feat(cli): add --root description and -r alias
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
---------
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
* chore: disable mdlint (#6)
* resolve lint issues
Some issues where detected by the CI once run:
* use of `fmt.Printf` forbidden by pattern `^(fmt\.Print(|f|ln)|print|println)$` (forbidigo)
* File is not properly formatted (goimports)
* Magic number: 12, in <condition> detected (mnd)
* error-format: fmt.Errorf can be replaced with errors.New (perfsprint)
---------
Co-authored-by: Alessio Biancalana <alessio@dottorblaster.it>