grim/convey

A bunch of golint cleanups

2018-01-13, Gary Kramlich
f92879e96f9e
Parents 947047a8e382
Children 5950f37a050a
A bunch of golint cleanups
--- a/color/ansi.go Fri Jan 12 23:44:56 2018 -0600
+++ b/color/ansi.go Sat Jan 13 00:00:58 2018 -0600
@@ -39,6 +39,7 @@
ansiColorMap = map[string]string{}
)
+// Ansi returns an ansi color based on the hash of the given string.
func Ansi(identifier string) string {
return lookup(identifier, ansiColorList, ansiColorMap)
}
--- a/color/x11.go Fri Jan 12 23:44:56 2018 -0600
+++ b/color/x11.go Sat Jan 13 00:00:58 2018 -0600
@@ -43,6 +43,7 @@
x11ColorMap = map[string]string{}
)
+// X11 returns an x11 color based on the hash of the given string.
func X11(identifier string) string {
return lookup(identifier, x11ColorList, x11ColorMap)
}
--- a/command/command.go Fri Jan 12 23:44:56 2018 -0600
+++ b/command/command.go Sat Jan 13 00:00:58 2018 -0600
@@ -36,6 +36,8 @@
lock sync.Mutex
)
+// Run runs the command specified in cmdTemplate which is rendered with the
+// given params and logs stderr and stdout to a new log adapter.
func Run(name, cmdTemplate string, params map[string]interface{}, timeout time.Duration) error {
var (
logger = logging.NewAdapter(name)
@@ -46,6 +48,8 @@
return run(name, cmdTemplate, params, timeout, outCollector, errCollector)
}
+// RunOutput works just like Run but returns stdout and stderr instead of
+// logging it.
func RunOutput(name, cmdTemplate string, params map[string]interface{}, timeout time.Duration) (string, string, error) {
var (
wg = &sync.WaitGroup{}
--- a/config/config.go Fri Jan 12 23:44:56 2018 -0600
+++ b/config/config.go Sat Jan 13 00:00:58 2018 -0600
@@ -22,6 +22,7 @@
"bitbucket.org/rw_grim/convey/tasks"
)
+// Config represents a full convey configuration.
type Config struct {
Tasks map[string]tasks.Task
Plans map[string]plans.Plan
--- a/config/loader.go Fri Jan 12 23:44:56 2018 -0600
+++ b/config/loader.go Sat Jan 13 00:00:58 2018 -0600
@@ -26,6 +26,7 @@
"bitbucket.org/rw_grim/convey/state"
)
+// Loader defines all the functions that a config loader needs to implement.
type Loader interface {
Load(path, base string, data []byte, disableDeprecated bool) (*Config, error)
LoadOverride(path, base string, data []byte, config *Config, disableDeprecated bool)
@@ -60,6 +61,8 @@
loader.LoadOverride(path, base, data, cfg, disableDeprecated)
}
+// LoadFile will determine the file name and override file name and then
+// call the loaders methods to load them.
func LoadFile(file string, loader Loader, disableDeprecated bool) (*Config, error) {
// split the filename into our parts
path, base := filepath.Split(file)
--- a/config/tasks.go Fri Jan 12 23:44:56 2018 -0600
+++ b/config/tasks.go Sat Jan 13 00:00:58 2018 -0600
@@ -22,9 +22,11 @@
"bitbucket.org/rw_grim/convey/tasks"
)
+// TaskMap is a type alias for a map of task names to tasks.
type TaskMap map[string]tasks.Task
var (
+ // TasksMap is a lookup table for tasks
TasksMap = map[string]tasks.Task{}
)
--- a/workspace/workspace.go Fri Jan 12 23:44:56 2018 -0600
+++ b/workspace/workspace.go Sat Jan 13 00:00:58 2018 -0600
@@ -17,6 +17,7 @@
// Package workspace contains the workspace definition.
package workspace
+// Workspace is a simple interface for creating a Convey workspace.
type Workspace interface {
Name() string
Destroy() error
--- a/yaml/yaml.go Fri Jan 12 23:44:56 2018 -0600
+++ b/yaml/yaml.go Sat Jan 13 00:00:58 2018 -0600
@@ -21,8 +21,12 @@
"github.com/go-yaml/yaml"
)
+// StringOrSlice is a []string type alias that has a custom UnmarshalYAML
+// implementation.
type StringOrSlice []string
+// UnmarshalYAML will return a string slice for a single string or a slice of
+// strings.
func (s *StringOrSlice) UnmarshalYAML(unmarshal func(interface{}) error) error {
// check to see if we were just provided a string
str := ""