Skip to content

Commit

Permalink
fix/misc (#354)
Browse files Browse the repository at this point in the history
* fix topaz version -c output

* refactor WithContainerPlatform
  • Loading branch information
gertd authored Mar 23, 2024
1 parent af57166 commit e71770d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/cli/cmd/startrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (cmd *StartRunCmd) run(c *cc.CommonCtx, mode runMode) error {

opts := []dockerx.RunOption{
dockerx.WithContainerImage(image),
dockerx.WithContainerPlatform("linux", strings.TrimPrefix(cmd.ContainerPlatform, "linux/")),
dockerx.WithContainerPlatform(cmd.ContainerPlatform),
dockerx.WithContainerName(cmd.ContainerName),
dockerx.WithContainerHostname(cmd.ContainerHostname),
dockerx.WithWorkingDir("/app"),
Expand Down
7 changes: 3 additions & 4 deletions pkg/cli/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"fmt"
"strings"

"github.com/aserto-dev/topaz/pkg/cli/cc"
"github.com/aserto-dev/topaz/pkg/cli/dockerx"
Expand Down Expand Up @@ -43,15 +42,15 @@ func (cmd *VersionCmd) Run(c *cc.CommonCtx) error {
)

if !dc.ImageExists(image) {
fmt.Fprintf(c.UI.Output(), "!!! image %s does not exist locally\n", image)
fmt.Fprint(c.UI.Output(), "!!! run `topaz install` to download\n", image)
fmt.Fprintf(c.UI.Output(), "!!! container image %q does not exist locally\n", image)
fmt.Fprint(c.UI.Output(), "!!! run 'topaz install' to download\n")
return nil
}

if err := dc.Run(
dockerx.WithContainerImage(image),
dockerx.WithEntrypoint([]string{"/app/topazd", "version"}),
dockerx.WithContainerPlatform("linux", strings.TrimPrefix(cmd.ContainerPlatform, "linux/")),
dockerx.WithContainerPlatform(cmd.ContainerPlatform),
dockerx.WithContainerName("topazd-version"),
dockerx.WithOutput(c.UI.Output()),
dockerx.WithError(c.UI.Err()),
Expand Down
5 changes: 4 additions & 1 deletion pkg/cli/dockerx/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"os/signal"
"path"
"strings"
"syscall"

"github.com/docker/docker/api/types"
Expand Down Expand Up @@ -189,7 +190,9 @@ func WithCmd(cmds []string) RunOption {
}
}

func WithContainerPlatform(goos, goarch string) RunOption {
func WithContainerPlatform(platform string) RunOption {
goos, goarch := "linux", strings.TrimPrefix(platform, "linux/")

return func(r *runner) {
r.platform.OS = goos
r.platform.Architecture = goarch
Expand Down

0 comments on commit e71770d

Please sign in to comment.