mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-18 16:10:12 +01:00
Add and correct comments for pre/post update command code.
This commit is contained in:
parent
f8e053dc46
commit
25c7853f03
2 changed files with 8 additions and 2 deletions
|
|
@ -4,6 +4,8 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CommandInfo is the data structure used to encode information about a
|
||||||
|
// pre/post-update command.
|
||||||
type CommandInfo struct {
|
type CommandInfo struct {
|
||||||
User string
|
User string
|
||||||
Privileged bool
|
Privileged bool
|
||||||
|
|
@ -11,6 +13,8 @@ type CommandInfo struct {
|
||||||
Cmd []string
|
Cmd []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadCommandInfoFromJSON takes a JSON formatted description of a
|
||||||
|
// pre/post-update as input and returns the parsed data as a CommandInfo.
|
||||||
func ReadCommandInfoFromJSON(commandInfoJSON string) (CommandInfo, error) {
|
func ReadCommandInfoFromJSON(commandInfoJSON string) (CommandInfo, error) {
|
||||||
commandInfo := CommandInfo{}
|
commandInfo := CommandInfo{}
|
||||||
|
|
||||||
|
|
@ -22,6 +26,8 @@ func ReadCommandInfoFromJSON(commandInfoJSON string) (CommandInfo, error) {
|
||||||
return commandInfo, nil
|
return commandInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsDefined returns true if a CommandInfo actually contains a command to
|
||||||
|
// execute or false otherwise.
|
||||||
func (commandInfo CommandInfo) IsDefined() bool {
|
func (commandInfo CommandInfo) IsDefined() bool {
|
||||||
return commandInfo.Cmd != nil && len(commandInfo.Cmd) > 0
|
return commandInfo.Cmd != nil && len(commandInfo.Cmd) > 0
|
||||||
}
|
}
|
||||||
|
|
@ -119,7 +119,7 @@ func (c Container) StopSignal() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// PreUpdateCommand returns the pre-update command set in the container's
|
// PreUpdateCommandInfo returns the pre-update command set in the container's
|
||||||
// metadata or an empty string if the user did not set it.
|
// metadata or an empty string if the user did not set it.
|
||||||
func (c Container) PreUpdateCommandInfo() (CommandInfo, error) {
|
func (c Container) PreUpdateCommandInfo() (CommandInfo, error) {
|
||||||
if val, ok := c.containerInfo.Config.Labels[preUpdateCommandLabel]; ok {
|
if val, ok := c.containerInfo.Config.Labels[preUpdateCommandLabel]; ok {
|
||||||
|
|
@ -134,7 +134,7 @@ func (c Container) PreUpdateCommandInfo() (CommandInfo, error) {
|
||||||
return CommandInfo{}, nil
|
return CommandInfo{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PostUpdateCommand returns the post-update command set in the container's
|
// PostUpdateCommandInfo returns the post-update command set in the container's
|
||||||
// metadata or an empty string if the user did not set it.
|
// metadata or an empty string if the user did not set it.
|
||||||
func (c Container) PostUpdateCommandInfo() (CommandInfo, error) {
|
func (c Container) PostUpdateCommandInfo() (CommandInfo, error) {
|
||||||
if val, ok := c.containerInfo.Config.Labels[postUpdateCommandLabel]; ok {
|
if val, ok := c.containerInfo.Config.Labels[postUpdateCommandLabel]; ok {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue