feat: debug logging

Closes coop-cloud/organising#164.
This commit is contained in:
2021-09-11 00:54:02 +02:00
parent 27d665c3be
commit 9fcdc45851
38 changed files with 305 additions and 95 deletions

View File

@ -48,5 +48,7 @@ func New(contextName string) (*client.Client, error) {
logrus.Fatalf("unable to create Docker client: %s", err)
}
logrus.Debugf("created client for '%s'", contextName)
return cl, nil
}

View File

@ -10,6 +10,7 @@ import (
"github.com/docker/cli/cli/context/docker"
contextStore "github.com/docker/cli/cli/context/store"
"github.com/moby/term"
"github.com/sirupsen/logrus"
)
type Context = contextStore.Metadata
@ -26,6 +27,7 @@ func CreateContext(contextName string, user string, port string) error {
if err := createContext(contextName, host); err != nil {
return err
}
logrus.Debugf("created the '%s' context", contextName)
return nil
}
@ -36,13 +38,16 @@ func createContext(name string, host string) error {
Endpoints: make(map[string]interface{}),
Name: name,
}
contextTLSData := contextStore.ContextTLSData{
Endpoints: make(map[string]contextStore.EndpointTLSData),
}
dockerEP, dockerTLS, err := getDockerEndpointMetadataAndTLS(host)
if err != nil {
return err
}
contextMetadata.Endpoints[docker.DockerEndpoint] = dockerEP
if dockerTLS != nil {
contextTLSData.Endpoints[docker.DockerEndpoint] = *dockerTLS
@ -51,9 +56,11 @@ func createContext(name string, host string) error {
if err := s.CreateOrUpdate(contextMetadata); err != nil {
return err
}
if err := s.ResetTLSMaterial(name, &contextTLSData); err != nil {
return err
}
return nil
}
@ -61,6 +68,7 @@ func DeleteContext(name string) error {
if name == "default" {
return errors.New("context 'default' cannot be removed")
}
if _, err := GetContext(name); err != nil {
return err
}
@ -81,6 +89,7 @@ func GetContext(contextName string) (contextStore.Metadata, error) {
if err != nil {
return contextStore.Metadata{}, err
}
return ctx, nil
}