Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

Commit 0d17f41

Browse files
committed
Improve the log output to better explain whats going on
1 parent cec58db commit 0d17f41

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

compose/internal/composebinary/composebinary.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ func NewComposeWrapper(binaryPath, configPath string) (libstack.Deployer, error)
3535
func (wrapper *ComposeWrapper) Deploy(ctx context.Context, workingDir, host, projectName string, filePaths []string, envFilePath string, forceRereate bool) error {
3636
output, err := wrapper.Command(newUpCommand(filePaths, forceRereate), workingDir, host, projectName, envFilePath)
3737
if len(output) != 0 {
38-
log.Printf("[libstack,composebinary] [message: finish deploying] [output: %s] [err: %s]", output, err)
38+
if err != nil {
39+
log.Printf("[libstack,composebinary] [message: deploy complete] [output: %s] [err: %s]", output, err)
40+
return nil
41+
}
42+
43+
log.Printf("[libstack,composebinary] [message: deploy complete] [output: %s] [success]", output)
3944
}
4045

4146
return err
@@ -45,7 +50,12 @@ func (wrapper *ComposeWrapper) Deploy(ctx context.Context, workingDir, host, pro
4550
func (wrapper *ComposeWrapper) Remove(ctx context.Context, workingDir, host, projectName string, filePaths []string) error {
4651
output, err := wrapper.Command(newDownCommand(filePaths), workingDir, host, projectName, "")
4752
if len(output) != 0 {
48-
log.Printf("[libstack,composebinary] [message: finish deploying] [output: %s] [err: %s]", output, err)
53+
if err != nil {
54+
log.Printf("[libstack,composebinary] [message: remove complete] [output: %s] [err: %s]", output, err)
55+
return nil
56+
}
57+
58+
log.Printf("[libstack,composebinary] [message: remove complete] [output: %s] [success]", output)
4959
}
5060

5161
return err
@@ -56,7 +66,12 @@ func (wrapper *ComposeWrapper) Remove(ctx context.Context, workingDir, host, pro
5666
func (wrapper *ComposeWrapper) Pull(ctx context.Context, workingDir, host, projectName string, filePaths []string) error {
5767
output, err := wrapper.Command(newPullCommand(filePaths), workingDir, host, projectName, "")
5868
if len(output) != 0 {
59-
log.Printf("[libstack,composebinary] [message: finish deploying] [output: %s] [err: %s]", output, err)
69+
if err != nil {
70+
log.Printf("[libstack,composebinary] [message: pull complete] [output: %s] [err: %s]", output, err)
71+
return nil
72+
}
73+
74+
log.Printf("[libstack,composebinary] [message: pull complete] [output: %s] [success]", output)
6075
}
6176

6277
return err

compose/internal/composeplugin/composeplugin.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ func NewPluginWrapper(binaryPath, configPath string) (libstack.Deployer, error)
6565
func (wrapper *PluginWrapper) Deploy(ctx context.Context, workingDir, host, projectName string, filePaths []string, envFilePath string, forceRereate bool) error {
6666
output, err := wrapper.command(newUpCommand(filePaths, forceRereate), workingDir, host, projectName, envFilePath)
6767
if len(output) != 0 {
68-
log.Printf("[libstack,composebinary] [message: finish deploying] [output: %s] [err: %s]", output, err)
68+
if err != nil {
69+
log.Printf("[libstack,composebinary] [message: deploy complete] [output: %s] [err: %s]", output, err)
70+
return err
71+
}
72+
73+
log.Printf("[libstack,composebinary] [message: deploy complete] [output: %s] [success]", output)
6974
}
7075

7176
return err
@@ -75,7 +80,12 @@ func (wrapper *PluginWrapper) Deploy(ctx context.Context, workingDir, host, proj
7580
func (wrapper *PluginWrapper) Remove(ctx context.Context, workingDir, host, projectName string, filePaths []string) error {
7681
output, err := wrapper.command(newDownCommand(filePaths), workingDir, host, projectName, "")
7782
if len(output) != 0 {
78-
log.Printf("[libstack,composebinary] [message: finish deploying] [output: %s] [err: %s]", output, err)
83+
if err != nil {
84+
log.Printf("[libstack,composebinary] [message: remove complete] [output: %s] [err: %s]", output, err)
85+
return err
86+
}
87+
88+
log.Printf("[libstack,composebinary] [message: remove complete] [output: %s] [success]", output)
7989
}
8090

8191
return err
@@ -85,7 +95,12 @@ func (wrapper *PluginWrapper) Remove(ctx context.Context, workingDir, host, proj
8595
func (wrapper *PluginWrapper) Pull(ctx context.Context, workingDir, host, projectName string, filePaths []string) error {
8696
output, err := wrapper.command(newPullCommand(filePaths), workingDir, host, projectName, "")
8797
if len(output) != 0 {
88-
log.Printf("[libstack,composebinary] [message: finish pulling] [output: %s] [err: %s]", output, err)
98+
if err != nil {
99+
log.Printf("[libstack,composebinary] [message: pull complete] [output: %s] [err: %s]", output, err)
100+
return err
101+
}
102+
103+
log.Printf("[libstack,composebinary] [message: pull complete] [output: %s] [success]", output)
89104
}
90105

91106
return err

0 commit comments

Comments
 (0)