feat: added error to GetContextEndpoint
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
this ill make the progam not fail if there is a non-docker swarm context
This commit is contained in:
parent
a2bb0ed027
commit
37c06c82bf
|
@ -26,10 +26,16 @@ var serverListCommand = &cli.Command{
|
||||||
|
|
||||||
serverNames := config.ReadServerNames()
|
serverNames := config.ReadServerNames()
|
||||||
for _, serverName := range serverNames {
|
for _, serverName := range serverNames {
|
||||||
|
|
||||||
var row []string
|
var row []string
|
||||||
for _, ctx := range contexts {
|
for _, ctx := range contexts {
|
||||||
|
endpoint, err := client.GetContextEndpoint(ctx)
|
||||||
|
if err != nil {
|
||||||
|
// This most likely means its a non-docker swarm context and we can ignore
|
||||||
|
continue
|
||||||
|
}
|
||||||
if ctx.Name == serverName {
|
if ctx.Name == serverName {
|
||||||
row = []string{serverName, client.GetContextEndpoint(ctx)}
|
row = []string{serverName, endpoint}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(row) == 0 {
|
if len(row) == 0 {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -49,10 +50,14 @@ func NewClientWithContext(contextURL string) *dClient.Client {
|
||||||
return cl
|
return cl
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetContextEndpoint(ctx dCliContextStore.Metadata) string {
|
func GetContextEndpoint(ctx dCliContextStore.Metadata) (string, error) {
|
||||||
// safe to use docker key hardcoded since abra doesn't use k8s... yet...
|
// safe to use docker key hardcoded since abra doesn't use k8s... yet...
|
||||||
endpointmeta := ctx.Endpoints["docker"].(dContext.EndpointMetaBase)
|
endpointmeta, ok := ctx.Endpoints["docker"].(dContext.EndpointMetaBase)
|
||||||
return endpointmeta.Host
|
if !ok {
|
||||||
|
err := errors.New("context lacks Docker endpoint")
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return endpointmeta.Host, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDefaultDockerContextStore() *dCliCommand.ContextStoreWithDefault {
|
func NewDefaultDockerContextStore() *dCliCommand.ContextStoreWithDefault {
|
||||||
|
|
Loading…
Reference in New Issue