Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build/mockery/mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ recursive: true
# exclude: []

# Include auto-generated files in package discovery when true.
# When false, skips files matching Gos generated file convention (e.g., "// Code generated").
# When false, skips files matching Go's generated file convention (e.g., "// Code generated").
# Default: true
# include-auto-generated: false

Expand Down Expand Up @@ -145,7 +145,7 @@ recursive: true
# with-expecter: true

# Specify build tags for the generated mock files.
# Matches Gos build constraint syntax (e.g., "// +build tag1,tag2").
# Matches Go's build constraint syntax (e.g., "// +build tag1,tag2").
# https://pkg.go.dev/cmd/go#hdr-Build_constraints
# Default: ""
# mock-build-tags: ""
Expand Down Expand Up @@ -179,7 +179,7 @@ pkgname: "mocks"
# inpackage: true

# Define the output directory for mocks using a Go template.
# "{{.InterfaceDir}}/mocks" places mocks in a subdirectory of the interfaces source dir.
# "{{.InterfaceDir}}/mocks" places mocks in a subdirectory of the interface's source dir.
# Default: "mocks/{{.PackagePath}}"
dir: "{{.InterfaceDir}}/mocks"

Expand Down
8 changes: 4 additions & 4 deletions cmd/notify-upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
)

// init registers the notify-upgrade command with the root command.
// It follows Cobras best practice of adding subcommands in an init function,
// It follows Cobra's best practice of adding subcommands in an init function,
// avoiding global variables and ensuring proper command hierarchy setup.
func init() {
rootCmd.AddCommand(&cobra.Command{
Expand Down Expand Up @@ -59,7 +59,7 @@ func runNotifyUpgrade(cmd *cobra.Command, args []string) {
// - cmd: The *cobra.Command instance representing the `notify-upgrade` subcommand, providing access to parsed flags
// such as notification types (e.g., --notifications) and other settings that influence notifier behavior.
// - _: A slice of strings representing positional arguments, unused here as the command accepts no arguments (enforced
// by cobra.NoArgs), included for compatibility with Cobras RunE signature.
// by cobra.NoArgs), included for compatibility with Cobra's RunE signature.
//
// Returns:
// - error: An error value if a critical operation fails (e.g., creating or writing to the temporary file), wrapped with
Expand Down Expand Up @@ -107,7 +107,7 @@ func runNotifyUpgradeE(cmd *cobra.Command, _ []string) error {
urlBuilder.WriteString(u)
}

// Write the constructed string to the temporary file. This is a critical step, as the files purpose is to store this data.
// Write the constructed string to the temporary file. This is a critical step, as the file's purpose is to store this data.
_, err = fmt.Fprint(outFile, urlBuilder.String())
if err != nil {
logrus.WithError(err).
Expand All @@ -127,7 +127,7 @@ func runNotifyUpgradeE(cmd *cobra.Command, _ []string) error {
return fmt.Errorf("%w: %w", errSyncTempFile, err)
}

// Attempt to retrieve the running containers ID to provide precise instructions for copying the file from the container.
// Attempt to retrieve the running container's ID to provide precise instructions for copying the file from the container.
// Use a placeholder ("<CONTAINER>") if this fails, ensuring the user still gets actionable guidance.
containerID := "<CONTAINER>"

Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ var (
//
// It invokes functions from the flags package to set default values and register flags for Docker configuration
// (e.g., --host), system behavior (e.g., --interval), and notifications (e.g., --notifications), establishing
// the CLIs configurable parameters before execution begins.
// the CLI's configurable parameters before execution begins.
func init() {
flags.SetDefaults()
flags.RegisterDockerFlags(rootCmd)
Expand Down Expand Up @@ -457,7 +457,7 @@ func preRun(cmd *cobra.Command, _ []string) {
// builds the container filter, and delegates to runMain for core execution,
// exiting with a status code based on the outcome (0 for success, non-zero for failure).
//
// This function bridges flag parsing and the applications primary workflow.
// This function bridges flag parsing and the application's primary workflow.
//
// Parameters:
// - command: The cobra.Command instance being executed, providing access to parsed flags.
Expand Down
2 changes: 1 addition & 1 deletion internal/actions/doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package actions provides core logic for Watchtowers container update operations.
// Package actions provides core logic for Watchtower's container update operations.
// It handles container staleness checks, updates, and lifecycle management.
//
// Key components:
Expand Down
2 changes: 1 addition & 1 deletion internal/actions/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var (
errStartContainerFailed = errors.New("failed to start container")
// errCreateContainerFailed indicates a failure to create a container during the update process.
errCreateContainerFailed = errors.New("failed to create container")
// errParseImageReference indicates a failure to parse a containers image reference.
// errParseImageReference indicates a failure to parse a container's image reference.
errParseImageReference = errors.New("failed to parse image reference")
// errInvalidImageReference indicates an invalid image reference that cannot be processed.
errInvalidImageReference = errors.New("invalid image reference")
Expand Down
2 changes: 1 addition & 1 deletion internal/actions/mocks/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func CreateMockProgressReport(states ...session.State) types.Report {
progress.AddScanned(c, c.ImageID(), types.UpdateParams{})
progress.MarkRestarted(c.ID())
case session.UnknownState, session.ScannedState, session.StaleState:
// These states are not explicitly handled in this mock as theyre intermediate or unused here.
// These states are not explicitly handled in this mock as they're intermediate or unused here.
continue
}

Expand Down
6 changes: 3 additions & 3 deletions internal/actions/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func Update(
}
}

// Verify the containers configuration if its slated for update to
// Verify the container's configuration if it's slated for update to
// ensure recreation is possible.
if err == nil && shouldUpdate {
err = sourceContainer.VerifyConfiguration()
Expand Down Expand Up @@ -452,7 +452,7 @@ func Update(
}
}

// Update the containers stale status for dependency sorting.
// Update the container's stale status for dependency sorting.
// Only mark as stale if the container should actually be updated.
filteredContainers[i].SetStale(stale && shouldUpdate)

Expand Down Expand Up @@ -1023,7 +1023,7 @@ func parseReference(
return normalizedRef, nil
}

// isPinned checks if a containers image is pinned by a digest reference.
// isPinned checks if a container's image is pinned by a digest reference.
//
// It selects a valid image name from ImageName(), Config.Image,
// or a fallback (imageInfo.ID or container name),
Expand Down
8 changes: 4 additions & 4 deletions internal/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ var (
errOpenFileFailed = errors.New("failed to open secret file")
// errReplaceSliceFailed indicates a failure to replace a slice value in a flag.
errReplaceSliceFailed = errors.New("failed to replace slice value in flag")
// errReadFileFailed indicates a failure to read a files contents for secrets.
// errReadFileFailed indicates a failure to read a file's contents for secrets.
errReadFileFailed = errors.New("failed to read secret file")
// errSetFlagFailed indicates a failure to set a flags value during configuration.
// errSetFlagFailed indicates a failure to set a flag's value during configuration.
errSetFlagFailed = errors.New("failed to set flag value")
// errInvalidFlagName indicates an invalid flag name was provided for modification.
errInvalidFlagName = errors.New("invalid flag name provided")
Expand Down Expand Up @@ -1070,7 +1070,7 @@ func getSecretFromFile(flags *pflag.FlagSet, secret string) error {
func isFilePath(path string) bool {
firstColon := strings.IndexRune(path, ':')
if firstColon != 1 && firstColon != -1 {
// If ':' exists but isnt the second character, its likely not a file path (e.g., URLs).
// If ':' exists but isn't the second character, it's likely not a file path (e.g., URLs).
return false
}

Expand Down Expand Up @@ -1323,7 +1323,7 @@ func appendFlagValue(flags *pflag.FlagSet, name string, values ...string) error
return nil
}

// setFlagIfDefault sets a flags default value if unchanged.
// setFlagIfDefault sets a flag's default value if unchanged.
//
// Parameters:
// - flags: Flag set.
Expand Down
2 changes: 1 addition & 1 deletion internal/flags/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ func TestReadFlags_Errors(t *testing.T) {
cmd := new(cobra.Command)

SetDefaults()
// Dont register flags to force errors
// Don't register flags to force errors
assert.PanicsWithValue(t, "FATAL", func() {
ReadFlags(cmd)
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/container/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ func (c *client) WarnOnHeadPullFailed(container types.Container) bool {
return registry.WarnOnAPIConsumption(container)
}

// IsContainerStale checks if a containers image is outdated.
// IsContainerStale checks if a container's image is outdated.
//
// Parameters:
// - container: Container to check.
Expand Down Expand Up @@ -1136,7 +1136,7 @@ func (c *client) RemoveImageByID(
return nil
}

// GetVersion returns the clients API version.
// GetVersion returns the client's API version.
//
// Returns:
// - string: Docker API version (e.g., "1.44").
Expand Down
8 changes: 4 additions & 4 deletions pkg/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (c *Container) SetLinkedToRestarting(value bool) {
c.LinkedToRestarting = value
}

// IsStale returns whether the containers image is outdated.
// IsStale returns whether the container's image is outdated.
//
// Returns:
// - bool: True if stale, false otherwise.
Expand Down Expand Up @@ -222,7 +222,7 @@ func (c *Container) Name() string {
return c.normalizedName
}

// ImageID returns the ID of the containers image.
// ImageID returns the ID of the container's image.
//
// Returns:
// - types.ImageID: Image ID or empty string if imageInfo is nil.
Expand All @@ -234,7 +234,7 @@ func (c *Container) ImageID() types.ImageID {
return types.ImageID(c.imageInfo.ID)
}

// ImageName returns the name of the containers image.
// ImageName returns the name of the container's image.
//
// It uses the Zodiac label if present, otherwise Config.Image, appending ":latest" if untagged.
//
Expand Down Expand Up @@ -450,7 +450,7 @@ func (c *Container) GetCreateHostConfig() *dockerContainer.HostConfig {
return hostConfig
}

// VerifyConfiguration validates the containers metadata for recreation.
// VerifyConfiguration validates the container's metadata for recreation.
//
// Returns:
// - error: Non-nil if metadata is missing or invalid, nil on success.
Expand Down
10 changes: 5 additions & 5 deletions pkg/container/container_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,12 +653,12 @@ func validateMacAddresses(
}
}

// Retrieve container state to determine if its running, which affects MAC address expectations.
// Retrieve container state to determine if it's running, which affects MAC address expectations.
// Non-running containers (e.g., created, exited) typically lack MAC addresses due to inactive network interfaces.
containerInfo := sourceContainer.ContainerInfo()
isRunning := sourceContainer.IsRunning()

// Extract the containers state (e.g., "running", "created", "exited") for logging context.
// Extract the container's state (e.g., "running", "created", "exited") for logging context.
// Use "unknown" as a fallback if container metadata is incomplete to ensure safe logging.
containerState := "unknown"
if containerInfo != nil && containerInfo.State != nil {
Expand All @@ -680,7 +680,7 @@ func validateMacAddresses(
return nil
}

// Handle host network mode, where the container uses the hosts network stack and should not have its own MAC addresses.
// Handle host network mode, where the container uses the host's network stack and should not have its own MAC addresses.
if isHostNetwork {
if foundMac {
// MAC addresses in host mode are unexpected and indicate a misconfiguration; log a warning and return an error.
Expand Down Expand Up @@ -720,7 +720,7 @@ func validateMacAddresses(
return nil
}

// filterAliases removes the containers short ID from the list of aliases.
// filterAliases removes the container's short ID from the list of aliases.
//
// Parameters:
// - aliases: List of aliases to filter.
Expand All @@ -740,7 +740,7 @@ func filterAliases(aliases []string, shortID string) []string {
return result
}

// debugLogMacAddress logs MAC address info for a containers network config.
// debugLogMacAddress logs MAC address info for a container's network config.
//
// Parameters:
// - networkConfig: Network configuration to check.
Expand Down
4 changes: 2 additions & 2 deletions pkg/container/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
// }
// }
//
// The package integrates with Dockers API via docker/docker client libraries and supports
// Watchtowers update workflows, including authentication, scope filtering, and custom lifecycle hooks.
// The package integrates with Docker's API via docker/docker client libraries and supports
// Watchtower's update workflows, including authentication, scope filtering, and custom lifecycle hooks.
package container
8 changes: 4 additions & 4 deletions pkg/container/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var (
errAttachExecFailed = errors.New("failed to attach to exec instance")
// errReadExecOutputFailed indicates a failure to read output from an exec instance.
errReadExecOutputFailed = errors.New("failed to read exec output")
// errInspectExecFailed indicates a failure to inspect an exec instances status.
// errInspectExecFailed indicates a failure to inspect an exec instance's status.
errInspectExecFailed = errors.New("failed to inspect exec instance")
// errCommandFailed indicates a command executed in a container failed with a non-zero exit code.
errCommandFailed = errors.New("command execution failed")
Expand All @@ -24,7 +24,7 @@ var (
var (
// errListContainersFailed indicates a failure to list containers from the Docker host.
errListContainersFailed = errors.New("failed to list containers")
// errInspectContainerFailed indicates a failure to inspect a containers details.
// errInspectContainerFailed indicates a failure to inspect a container's details.
errInspectContainerFailed = errors.New("failed to inspect container")
// errStopContainerFailed indicates a failure to stop a container with a signal.
errStopContainerFailed = errors.New("failed to stop container")
Expand Down Expand Up @@ -56,7 +56,7 @@ var (
errNoImageInfo = errors.New("no image info available")
// errNoContainerInfo indicates the container lacks metadata required for recreation.
errNoContainerInfo = errors.New("no container info available")
// errInvalidConfig indicates the containers configuration is invalid for recreation.
// errInvalidConfig indicates the container's configuration is invalid for recreation.
errInvalidConfig = errors.New("invalid container configuration")
// ErrUnexpectedContainerType indicates an unexpected container type was encountered.
ErrUnexpectedContainerType = errors.New("unexpected container type")
Expand Down Expand Up @@ -86,7 +86,7 @@ var (

// Errors for label operations in metadata.go.
var (
// errLabelNotFound indicates a requested label is not present in the containers metadata.
// errLabelNotFound indicates a requested label is not present in the container's metadata.
errLabelNotFound = errors.New("label not found")
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/container/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type imageClient struct {
api dockerClient.APIClient
}

// IsContainerStale determines if a containers image is outdated.
// IsContainerStale determines if a container's image is outdated.
//
// It skips pulling if NoPull is set, otherwise pulls and compares images.
//
Expand Down
8 changes: 4 additions & 4 deletions pkg/container/mocks/ApiServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
assertionOffset = 2 // Call stack offset for Gomega assertions in nested calls
)

// Returns the file contents or an error if the file isnt found.
// Returns the file contents or an error if the file isn't found.
func getMockJSONFile(relPath string) ([]byte, error) {
absPath, _ := filepath.Abs(relPath)

Expand All @@ -50,7 +50,7 @@ func RespondWithJSONFile(
return handler
}

// Returns the handler and an error if the file cant be read.
// Returns the handler and an error if the file can't be read.
func respondWithJSONFile(
relPath string,
statusCode int,
Expand All @@ -73,7 +73,7 @@ func GetContainerHandlers(containerRefs ...*ContainerRef) []http.HandlerFunc {
for _, ref := range containerRef.references {
handlers = append(handlers, getContainerFileHandler(ref))
}
// Append image handler for each containers image
// Append image handler for each container's image
handlers = append(handlers, getImageHandler(containerRef.image.id,
RespondWithJSONFile(containerRef.image.getFileName(), http.StatusOK),
))
Expand Down Expand Up @@ -178,7 +178,7 @@ const (
NetSupplierContainerName = "/wt-contnet-producer-1"
)

// Fails the test if the file cant be retrieved; returns a 404 handler if the container is missing.
// Fails the test if the file can't be retrieved; returns a 404 handler if the container is missing.
func getContainerFileHandler(container *ContainerRef) http.HandlerFunc {
if container.isMissing {
return containerNotFoundResponse(string(container.id))
Expand Down
4 changes: 2 additions & 2 deletions pkg/container/mocks/container_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type ContainerRef struct {
isMissing bool
}

// Uses the explicit file if set, otherwise falls back to the container name; returns an error if the file doesnt exist.
// Uses the explicit file if set, otherwise falls back to the container name; returns an error if the file doesn't exist.
func (cr *ContainerRef) getContainerFile() (string, error) {
file := cr.file
if file == "" {
Expand All @@ -50,7 +50,7 @@ func (cr *ContainerRef) getContainerFile() (string, error) {
return containerFile, nil
}

// ContainerID returns the mock containers ID.
// ContainerID returns the mock container's ID.
func (cr *ContainerRef) ContainerID() types.ContainerID {
return cr.id
}
2 changes: 1 addition & 1 deletion pkg/lifecycle/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func ExecutePreUpdateCommand(
"timeout": timeout,
})

// Skip if no command or container isnt running.
// Skip if no command or container isn't running.
if len(command) == 0 {
clog.Debug("No pre-update command supplied. Skipping")

Expand Down
2 changes: 1 addition & 1 deletion pkg/notifications/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func newEmailNotifier(c *cobra.Command) types.ConvertibleNotifier {
}
}

// GetURL generates the SMTP URL from the notifiers configuration.
// GetURL generates the SMTP URL from the notifier's configuration.
//
// Parameters:
// - c: Cobra command (unused here).
Expand Down
Loading
Loading