fix: defers after checking for err
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
542e9eea5c
commit
7835c1f91d
|
@ -111,10 +111,10 @@ var appCpCommand = &cli.Command{
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
content, _, err := cl.CopyFromContainer(ctx, container.ID, srcPath)
|
content, _, err := cl.CopyFromContainer(ctx, container.ID, srcPath)
|
||||||
defer content.Close()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
defer content.Close()
|
||||||
fromTarOpts := &archive.TarOptions{NoOverwriteDirNonDir: true, Compression: archive.Gzip}
|
fromTarOpts := &archive.TarOptions{NoOverwriteDirNonDir: true, Compression: archive.Gzip}
|
||||||
if err := archive.Untar(content, dstPath, fromTarOpts); err != nil {
|
if err := archive.Untar(content, dstPath, fromTarOpts); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
|
|
|
@ -42,6 +42,10 @@ func stackLogs(stackName string, client *dockerClient.Client) {
|
||||||
Timestamps: true,
|
Timestamps: true,
|
||||||
}
|
}
|
||||||
logs, err := client.ServiceLogs(ctx, s, logOpts)
|
logs, err := client.ServiceLogs(ctx, s, logOpts)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
// defer after err check as any err returns a nil io.ReadCloser
|
||||||
defer logs.Close()
|
defer logs.Close()
|
||||||
|
|
||||||
_, err = io.Copy(os.Stdout, logs)
|
_, err = io.Copy(os.Stdout, logs)
|
||||||
|
@ -107,6 +111,10 @@ var appLogsCommand = &cli.Command{
|
||||||
Timestamps: true,
|
Timestamps: true,
|
||||||
}
|
}
|
||||||
logs, err := cl.ServiceLogs(ctx, services[0].ID, logOpts)
|
logs, err := cl.ServiceLogs(ctx, services[0].ID, logOpts)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
// defer after err check as any err returns a nil io.ReadCloser
|
||||||
defer logs.Close()
|
defer logs.Close()
|
||||||
|
|
||||||
_, err = io.Copy(os.Stdout, logs)
|
_, err = io.Copy(os.Stdout, logs)
|
||||||
|
|
Loading…
Reference in New Issue