forked from toolshed/abra
refactor: use central logger
This commit is contained in:
@ -11,6 +11,7 @@ import (
|
||||
|
||||
stdlibErr "errors"
|
||||
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"coopcloud.tech/abra/pkg/upstream/convert"
|
||||
"github.com/docker/cli/cli/command/service/progress"
|
||||
"github.com/docker/cli/cli/command/stack/formatter"
|
||||
@ -23,7 +24,6 @@ import (
|
||||
"github.com/docker/docker/client"
|
||||
dockerClient "github.com/docker/docker/client"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Resolve image constants
|
||||
@ -118,12 +118,12 @@ func IsDeployed(ctx context.Context, cl *dockerClient.Client, stackName string)
|
||||
}
|
||||
}
|
||||
|
||||
logrus.Debugf("%s has been detected as deployed with version %s", stackName, version)
|
||||
log.Debugf("%s has been detected as deployed with version %s", stackName, version)
|
||||
|
||||
return true, version, nil
|
||||
}
|
||||
|
||||
logrus.Debugf("%s has been detected as not deployed", stackName)
|
||||
log.Debugf("%s has been detected as not deployed", stackName)
|
||||
return isDeployed, version, nil
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ func IsDeployed(ctx context.Context, cl *dockerClient.Client, stackName string)
|
||||
func pruneServices(ctx context.Context, cl *dockerClient.Client, namespace convert.Namespace, services map[string]struct{}) {
|
||||
oldServices, err := GetStackServices(ctx, cl, namespace.Name())
|
||||
if err != nil {
|
||||
logrus.Infof("failed to list services: %s\n", err)
|
||||
log.Infof("failed to list services: %s\n", err)
|
||||
}
|
||||
|
||||
pruneServices := []swarm.Service{}
|
||||
@ -213,9 +213,9 @@ func deployCompose(ctx context.Context, cl *dockerClient.Client, opts Deploy, co
|
||||
return err
|
||||
}
|
||||
|
||||
logrus.Infof("waiting for %s to deploy... please hold 🤚", appName)
|
||||
log.Infof("waiting for %s to deploy... please hold 🤚", appName)
|
||||
if err := waitOnServices(ctx, cl, serviceIDs, appName); err == nil {
|
||||
logrus.Infof("Successfully deployed %s", appName)
|
||||
log.Infof("Successfully deployed %s", appName)
|
||||
}
|
||||
return err
|
||||
}
|
||||
@ -265,7 +265,7 @@ func createSecrets(ctx context.Context, cl *dockerClient.Client, secrets []swarm
|
||||
}
|
||||
case dockerClient.IsErrNotFound(err):
|
||||
// secret does not exist, then we create a new one.
|
||||
logrus.Infof("Creating secret %s\n", secretSpec.Name)
|
||||
log.Infof("Creating secret %s\n", secretSpec.Name)
|
||||
if _, err := cl.SecretCreate(ctx, secretSpec); err != nil {
|
||||
return errors.Wrapf(err, "failed to create secret %s", secretSpec.Name)
|
||||
}
|
||||
@ -287,7 +287,7 @@ func createConfigs(ctx context.Context, cl *dockerClient.Client, configs []swarm
|
||||
}
|
||||
case dockerClient.IsErrNotFound(err):
|
||||
// config does not exist, then we create a new one.
|
||||
logrus.Infof("creating config %s\n", configSpec.Name)
|
||||
log.Infof("creating config %s\n", configSpec.Name)
|
||||
if _, err := cl.ConfigCreate(ctx, configSpec); err != nil {
|
||||
return errors.Wrapf(err, "failed to create config %s", configSpec.Name)
|
||||
}
|
||||
@ -318,7 +318,7 @@ func createNetworks(ctx context.Context, cl *dockerClient.Client, namespace conv
|
||||
createOpts.Driver = defaultNetworkDriver
|
||||
}
|
||||
|
||||
logrus.Infof("creating network %s\n", name)
|
||||
log.Infof("creating network %s\n", name)
|
||||
if _, err := cl.NetworkCreate(ctx, name, createOpts); err != nil {
|
||||
return errors.Wrapf(err, "failed to create network %s", name)
|
||||
}
|
||||
@ -355,7 +355,7 @@ func deployServices(
|
||||
)
|
||||
|
||||
if service, exists := existingServiceMap[name]; exists {
|
||||
logrus.Infof("Updating service %s (id: %s)\n", name, service.ID)
|
||||
log.Infof("Updating service %s (id: %s)\n", name, service.ID)
|
||||
|
||||
updateOpts := types.ServiceUpdateOptions{EncodedRegistryAuth: encodedAuth}
|
||||
|
||||
@ -394,12 +394,12 @@ func deployServices(
|
||||
}
|
||||
|
||||
for _, warning := range response.Warnings {
|
||||
logrus.Warn(warning)
|
||||
log.Warn(warning)
|
||||
}
|
||||
|
||||
serviceIDs = append(serviceIDs, service.ID)
|
||||
} else {
|
||||
logrus.Infof("creating service %s\n", name)
|
||||
log.Infof("creating service %s\n", name)
|
||||
|
||||
createOpts := types.ServiceCreateOptions{EncodedRegistryAuth: encodedAuth}
|
||||
|
||||
@ -418,7 +418,7 @@ func deployServices(
|
||||
}
|
||||
|
||||
if dontWait {
|
||||
logrus.Warn("skipping converge logic checks")
|
||||
log.Warn("skipping converge logic checks")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user