From 25c7853f0301f760140237b13ad45c9cd232b929 Mon Sep 17 00:00:00 2001 From: Alexandre Menif Date: Thu, 31 May 2018 19:29:32 +0200 Subject: [PATCH] Add and correct comments for pre/post update command code. --- container/command_info.go | 6 ++++++ container/container.go | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/container/command_info.go b/container/command_info.go index 6c02c25..08b0a37 100644 --- a/container/command_info.go +++ b/container/command_info.go @@ -4,6 +4,8 @@ import ( "encoding/json" ) +// CommandInfo is the data structure used to encode information about a +// pre/post-update command. type CommandInfo struct { User string Privileged bool @@ -11,6 +13,8 @@ type CommandInfo struct { 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) { commandInfo := CommandInfo{} @@ -22,6 +26,8 @@ func ReadCommandInfoFromJSON(commandInfoJSON string) (CommandInfo, error) { return commandInfo, nil } +// IsDefined returns true if a CommandInfo actually contains a command to +// execute or false otherwise. func (commandInfo CommandInfo) IsDefined() bool { return commandInfo.Cmd != nil && len(commandInfo.Cmd) > 0 } \ No newline at end of file diff --git a/container/container.go b/container/container.go index 4582a98..702949d 100644 --- a/container/container.go +++ b/container/container.go @@ -119,7 +119,7 @@ func (c Container) StopSignal() string { 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. func (c Container) PreUpdateCommandInfo() (CommandInfo, error) { if val, ok := c.containerInfo.Config.Labels[preUpdateCommandLabel]; ok { @@ -134,7 +134,7 @@ func (c Container) PreUpdateCommandInfo() (CommandInfo, error) { 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. func (c Container) PostUpdateCommandInfo() (CommandInfo, error) { if val, ok := c.containerInfo.Config.Labels[postUpdateCommandLabel]; ok {