fix: improved missing context message
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
cdee6b00c4
commit
c47aa49373
|
@ -98,7 +98,7 @@ can take some time.
|
||||||
alreadySeen := make(map[string]bool)
|
alreadySeen := make(map[string]bool)
|
||||||
for _, app := range apps {
|
for _, app := range apps {
|
||||||
if _, ok := alreadySeen[app.Server]; !ok {
|
if _, ok := alreadySeen[app.Server]; !ok {
|
||||||
if err := context.HasDockerContext(app.Server); err != nil {
|
if err := context.HasDockerContext(app.Name, app.Server); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ func NewAction(c *cli.Context) error {
|
||||||
var secrets AppSecrets
|
var secrets AppSecrets
|
||||||
var secretTable *jsontable.JSONTable
|
var secretTable *jsontable.JSONTable
|
||||||
if Secrets {
|
if Secrets {
|
||||||
if err := context.HasDockerContext(NewAppServer); err != nil {
|
if err := context.HasDockerContext(sanitisedAppName, NewAppServer); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ func ValidateApp(c *cli.Context) config.App {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := context.HasDockerContext(app.Server); err != nil {
|
if err := context.HasDockerContext(app.Name, app.Server); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,10 +44,30 @@ func newContextStore(dir string, config contextStore.Config) contextStore.Store
|
||||||
return contextStore.New(dir, config)
|
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?
|
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:
|
output then you need to run the following command:
|
||||||
|
|
||||||
abra server add %s <args>
|
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
|
// 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
|
// 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.
|
// that they need to fix something up if missing.
|
||||||
func HasDockerContext(serverName string) error {
|
func HasDockerContext(appName, serverName string) error {
|
||||||
dockerContextStore := NewDefaultDockerContextStore()
|
dockerContextStore := NewDefaultDockerContextStore()
|
||||||
contexts, err := dockerContextStore.Store.List()
|
contexts, err := dockerContextStore.Store.List()
|
||||||
if err != nil {
|
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,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func getConnectionHelper(daemonURL string, sshFlags []string) (*connhelper.Conne
|
||||||
return nil, errors.Wrap(err, "ssh host connection is not valid")
|
return nil, errors.Wrap(err, "ssh host connection is not valid")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ctxPkg.HasDockerContext(ctxConnDetails.Host); err != nil {
|
if err := ctxPkg.HasDockerContext("", ctxConnDetails.Host); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue