Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cli): add deprecation notice when running a transaction #3069

Merged
merged 1 commit into from
Aug 16, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/cmd/resources.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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