diff --git a/cmd/notify-upgrade.go b/cmd/notify-upgrade.go index 8b4c088..9974e6a 100644 --- a/cmd/notify-upgrade.go +++ b/cmd/notify-upgrade.go @@ -1,3 +1,4 @@ +// cmd contains the watchtower (sub-)commands package cmd import ( @@ -16,7 +17,7 @@ import ( var notifyUpgradeCommand = NewNotifyUpgradeCommand() -// NewRootCommand creates the notify upgrade command for watchtower +// NewNotifyUpgradeCommand creates the notify upgrade command for watchtower func NewNotifyUpgradeCommand() *cobra.Command { return &cobra.Command{ Use: "notify-upgrade", @@ -63,14 +64,14 @@ func runNotifyUpgradeE(cmd *cobra.Command, _ []string) error { tryOrLog(outFile.Sync(), "Failed to sync output file") tryOrLog(outFile.Close(), "Failed to close output file") - containerId := "" + containerID := "" cid, err := container.GetRunningContainerID() tryOrLog(err, "Failed to get running container ID") if cid != "" { - containerId = cid.ShortID() + containerID = cid.ShortID() } 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("Note: This file will be removed in 5 minutes or when this container is stopped!") diff --git a/pkg/container/cgroup_id.go b/pkg/container/cgroup_id.go index 999026f..b5335bf 100644 --- a/pkg/container/cgroup_id.go +++ b/pkg/container/cgroup_id.go @@ -10,6 +10,7 @@ import ( 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) { file, err := os.ReadFile(fmt.Sprintf("/proc/%d/cgroup", os.Getpid())) if err != nil { diff --git a/pkg/container/container.go b/pkg/container/container.go index 82ae205..00b55cf 100644 --- a/pkg/container/container.go +++ b/pkg/container/container.go @@ -1,3 +1,4 @@ +// container package contains code related to dealing with docker containers package container import (