Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ test-coverage.*
*.syso
msi-builder/build/
contrib/packaging/rpm/rpmbuild
coverage*
18 changes: 7 additions & 11 deletions cmd/finch/devcontainer_patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/containerd/nerdctl/v2/pkg/inspecttypes/dockercompat"
"github.com/docker/go-connections/nat"
"github.com/sirupsen/logrus"
"golang.org/x/exp/slices"

"github.com/runfinch/finch/pkg/command"
)
Expand Down Expand Up @@ -111,15 +110,12 @@ func inspectContainerOutputHandler(cmd command.Command) error {
return err
}

func handleDockerCompatComposeVersion(cmdName string, nc nerdctlCommand, runArgs []string) error {
if cmdName == "compose" && nc.fc.DockerCompat && slices.Contains(runArgs, "version") {
ver := nc.systemDeps.Env("DOCKER_COMPOSE_VERSION")
if ver != "" {
logrus.Warn("Displaying docker compose version set as environment variable DOCKER_COMPOSE_VERSION...")
fmt.Println(ver)
return nil
}
return errors.New("DOCKER_COMPOSE_VERSION environment variable is not set")
func handleDockerCompatComposeVersion(nc nerdctlCommand) error {
ver := nc.systemDeps.Env("DOCKER_COMPOSE_VERSION")
if ver != "" {
logrus.Warn("Displaying docker compose version set as environment variable DOCKER_COMPOSE_VERSION...")
fmt.Println(ver)
return nil
}
return errors.New("")
return errors.New("DOCKER_COMPOSE_VERSION environment variable is not set")
}
25 changes: 19 additions & 6 deletions cmd/finch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,26 @@ func initializeNerdctlCommands(
nerdctlCommandCreator := newNerdctlCommandCreator(ncc, ecc, system.NewStdLib(), logger, fs, fc)
var allNerdctlCommands []*cobra.Command
for cmdName, cmdDescription := range nerdctlCmds {
allNerdctlCommands = append(allNerdctlCommands, nerdctlCommandCreator.create(cmdName, cmdDescription))
}

if fc != nil && fc.DockerCompat {
for cmdName, cmdDescription := range dockerCompatCmds {
allNerdctlCommands = append(allNerdctlCommands, nerdctlCommandCreator.create(cmdName, cmdDescription))
if fc != nil && fc.DockerCompat {
switch cmdName {
case "build":
allNerdctlCommands = append(allNerdctlCommands, nerdctlCommandCreator.createDockerCompatBuildCmd())
continue
case "image":
allNerdctlCommands = append(allNerdctlCommands, nerdctlCommandCreator.createDockerCompatImageCmd())
continue
case "inspect":
allNerdctlCommands = append(allNerdctlCommands, nerdctlCommandCreator.createDockerCompatInspectCmd())
continue
case "run":
allNerdctlCommands = append(allNerdctlCommands, nerdctlCommandCreator.createDockerCompatRunCmd())
continue
case "compose":
allNerdctlCommands = append(allNerdctlCommands, nerdctlCommandCreator.createDockerCompatComposeCmd())
continue
}
}
allNerdctlCommands = append(allNerdctlCommands, nerdctlCommandCreator.create(cmdName, cmdDescription))
}

return allNerdctlCommands
Expand Down
Loading
Loading