Skip to content
Merged
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
12 changes: 12 additions & 0 deletions go/pkg/container/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
28 changes: 27 additions & 1 deletion go/pkg/display/marketplace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
}
}
Loading