fix lint suggestions

This commit is contained in:
nils måsén 2022-09-17 12:34:02 +02:00
parent cc40a3c3a7
commit 8408b6b46f
3 changed files with 7 additions and 4 deletions

View file

@ -1,3 +1,4 @@
// cmd contains the watchtower (sub-)commands
package cmd package cmd
import ( import (
@ -16,7 +17,7 @@ import (
var notifyUpgradeCommand = NewNotifyUpgradeCommand() var notifyUpgradeCommand = NewNotifyUpgradeCommand()
// NewRootCommand creates the notify upgrade command for watchtower // NewNotifyUpgradeCommand creates the notify upgrade command for watchtower
func NewNotifyUpgradeCommand() *cobra.Command { func NewNotifyUpgradeCommand() *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "notify-upgrade", Use: "notify-upgrade",
@ -63,14 +64,14 @@ func runNotifyUpgradeE(cmd *cobra.Command, _ []string) error {
tryOrLog(outFile.Sync(), "Failed to sync output file") tryOrLog(outFile.Sync(), "Failed to sync output file")
tryOrLog(outFile.Close(), "Failed to close output file") tryOrLog(outFile.Close(), "Failed to close output file")
containerId := "<CONTAINER>" containerID := "<CONTAINER>"
cid, err := container.GetRunningContainerID() cid, err := container.GetRunningContainerID()
tryOrLog(err, "Failed to get running container ID") tryOrLog(err, "Failed to get running container ID")
if cid != "" { if cid != "" {
containerId = cid.ShortID() containerID = cid.ShortID()
} }
logf("To get the environment file, use:") logf("To get the environment file, use:")
logf("cp %v:%v ./watchtower-notifications.env", containerId, outFile.Name()) logf("cp %v:%v ./watchtower-notifications.env", containerID, outFile.Name())
logf("") logf("")
logf("Note: This file will be removed in 5 minutes or when this container is stopped!") logf("Note: This file will be removed in 5 minutes or when this container is stopped!")

View file

@ -10,6 +10,7 @@ import (
var dockerContainerPattern = regexp.MustCompile(`[0-9]+:.*:/docker/([a-f|0-9]{64})`) var dockerContainerPattern = regexp.MustCompile(`[0-9]+:.*:/docker/([a-f|0-9]{64})`)
// GetRunningContainerID tries to resolve the current container ID from the current process cgroup information
func GetRunningContainerID() (cid types.ContainerID, err error) { func GetRunningContainerID() (cid types.ContainerID, err error) {
file, err := os.ReadFile(fmt.Sprintf("/proc/%d/cgroup", os.Getpid())) file, err := os.ReadFile(fmt.Sprintf("/proc/%d/cgroup", os.Getpid()))
if err != nil { if err != nil {

View file

@ -1,3 +1,4 @@
// container package contains code related to dealing with docker containers
package container package container
import ( import (