Skip to content

Commit

Permalink
chore(cli): add deprecation notice when running a transaction (#3069)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbdias committed Aug 16, 2023
1 parent 3cebb5b commit 966f266
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cli/cmd/resources.go
Expand Up @@ -25,7 +25,7 @@ var (
formatters.TestSuiteRun(func() string { return cliConfig.URL() }, true),
)

runnerRegistry = runner.NewRegistry().
runnerRegistry = runner.NewRegistry(cliLogger).
Register(runner.TestRunner(
testClient,
openapiClient,
Expand Down
23 changes: 14 additions & 9 deletions cli/runner/registry.go
Expand Up @@ -2,17 +2,21 @@ package runner

import (
"fmt"

"go.uber.org/zap"
)

type Registry struct {
runners map[string]Runner
proxies map[string]string
logger *zap.Logger
}

func NewRegistry() Registry {
func NewRegistry(logger *zap.Logger) Registry {
return Registry{
runners: map[string]Runner{},
proxies: map[string]string{},
logger: logger,
}
}

Expand All @@ -30,17 +34,18 @@ var ErrNotFound = fmt.Errorf("runner not found")

func (r Registry) Get(name string) (Runner, error) {
runner, ok := r.runners[name]
if !ok {
if runnerName, ok := r.proxies[name]; ok {
if !ok {
return nil, ErrNotFound
}
if ok {
return runner, nil // found runner, return it to the user
}

return r.Get(runnerName)
}
// fallback, check if the runner has a proxy
runnerName, ok := r.proxies[name]
if !ok {
return nil, ErrNotFound
}

return runner, nil
r.logger.Warn(fmt.Sprintf("The resource `%s` is deprecated and will be removed in a future version. Please use `%s` instead.", name, runnerName))
return r.Get(runnerName)
}

func (r Registry) List() []string {
Expand Down

0 comments on commit 966f266

Please sign in to comment.