fix: improved missing context message
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2023-01-24 10:48:53 +01:00
parent cdee6b00c4
commit c47aa49373
5 changed files with 42 additions and 8 deletions

View File

@ -44,10 +44,30 @@ func newContextStore(dir string, config contextStore.Config) contextStore.Store
return contextStore.New(dir, config)
}
// MissingContextMsg helps end-uers debug missing docker context issues.
// missingContextMsg helps end-user debug missing docker context issues. This
// version of the message has no app domain name included. This is due to the
// code paths being unable to determine which app is requesting a server
// connection at certain points. It is preferred to use
// missingContextWithAppMsg where possible and only use missingContextMsg when
// the call path is located too deep in the SSH stack.
var missingContextMsg = `unable to find Docker context for %s?
Please run "abra server ls" to confirm. If you see "unknown" in the table
Please run "abra server ls -p" to confirm. If you see "unknown" in the table
output then you need to run the following command:
abra server add %s <args>
See "abra server add --help" for more.
`
// missingContextWithAppMsg helps end-users debug missing docker context
// issues. The app name is included in this message for extra clarity. See
// missingContextMsg docs for alternative usage.
var missingContextWithAppMsg = `unable to find Docker context for %s?
%s (app) is deployed on %s (server).
Please run "abra server ls -p" to confirm. If you see "unknown" in the table
output then you need to run the following command:
abra server add %s <args>
@ -59,7 +79,7 @@ See "abra server add --help" for more.
// configuration or not. This usually tells us if they'll be able to make a SSH
// connection to a server or not and can be a useful way to signal to end-users
// that they need to fix something up if missing.
func HasDockerContext(serverName string) error {
func HasDockerContext(appName, serverName string) error {
dockerContextStore := NewDefaultDockerContextStore()
contexts, err := dockerContextStore.Store.List()
if err != nil {
@ -72,5 +92,19 @@ func HasDockerContext(serverName string) error {
}
}
return fmt.Errorf(missingContextMsg, serverName, serverName)
if appName != "" {
return fmt.Errorf(
missingContextWithAppMsg,
serverName,
appName,
serverName,
serverName,
)
}
return fmt.Errorf(
missingContextMsg,
serverName,
serverName,
)
}