diff --git a/go/pkg/container/service.go b/go/pkg/container/service.go index 3ff3aff5..3dbbb270 100644 --- a/go/pkg/container/service.go +++ b/go/pkg/container/service.go @@ -18,6 +18,18 @@ var timContainerNamePattern = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9_.-]*$`) func NewService(c *core.Core, options TIMOptions) *Service { options, err := normalizeTIMOptions(options) + if options.Exec == nil && c != nil { + options.Exec = func(ctx context.Context, name string, args ...string) error { + result := c.Process().Run(ctx, name, args...) + if result.OK { + return nil + } + if err, ok := result.Value.(error); ok { + return err + } + return core.E("container.TIMManager.Exec", result.Error(), nil) + } + } return &Service{ ServiceRuntime: core.NewServiceRuntime(c, options), manager: NewTIMManager(options), diff --git a/go/pkg/display/marketplace.go b/go/pkg/display/marketplace.go index f0181015..ced04a80 100644 --- a/go/pkg/display/marketplace.go +++ b/go/pkg/display/marketplace.go @@ -89,7 +89,7 @@ func (s *Service) registerMarketplaceActions() { installer := marketplace.Installer{ HTTPClient: marketplaceHTTPClient, GitBinary: input.GitBinary, - GitRunner: marketplaceGitRunner, + GitRunner: s.marketplaceGitRunner(), InstallDir: marketplaceInstallRoot(input.InstallDir), } manifest, err := installer.Verify(ctx, input.ManifestURL) @@ -132,3 +132,29 @@ func marketplaceInstallRoot(raw string) string { } return core.PathJoin(home, ".core", "apps") } + +func (s *Service) marketplaceGitRunner() func(context.Context, string, ...string) ([]byte, error) { + if marketplaceGitRunner != nil { + return marketplaceGitRunner + } + coreRef := s.coreRef() + if coreRef == nil { + return nil + } + return func(ctx context.Context, binary string, args ...string) ([]byte, error) { + result := coreRef.Process().Run(ctx, binary, args...) + if !result.OK { + return nil, coreResultError(result, "failed to run marketplace git command") + } + switch output := result.Value.(type) { + case []byte: + return append([]byte(nil), output...), nil + case string: + return []byte(output), nil + case nil: + return nil, nil + default: + return []byte(core.Sprint(output)), nil + } + } +}