[ARVADOS] created: 1.3.0-2739-g4818df92d

Git user git at public.arvados.org
Thu Jul 9 13:48:02 UTC 2020


        at  4818df92d9cfec5a247b978d44f03ce9762face2 (commit)


commit 4818df92d9cfec5a247b978d44f03ce9762face2
Author: Nico Cesar <nico at nicocesar.com>
Date:   Thu Jul 9 09:44:12 2020 -0400

    Small improvements to Go documentation
    
    Arvados-DCO-1.1-Signed-off-by: Nico Cesar <nico at curii.com>

diff --git a/lib/cmd/cmd.go b/lib/cmd/cmd.go
index 611c95d23..08c443311 100644
--- a/lib/cmd/cmd.go
+++ b/lib/cmd/cmd.go
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: Apache-2.0
 
-// package cmd helps define reusable functions that can be exposed as
+// Package cmd helps define reusable functions that can be exposed as
 // [subcommands of] command line programs.
 package cmd
 
@@ -18,12 +18,15 @@ import (
 	"strings"
 )
 
+// Handler interface exposes RunCommand() that executes the (sub)command and returns exit value
 type Handler interface {
 	RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int
 }
 
+// HandlerFunc is the function version of Handler interface
 type HandlerFunc func(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int
 
+// RunCommand executes the (sub)command and return exit value from HanderFunc f
 func (f HandlerFunc) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
 	return f(prog, args, stdin, stdout, stderr)
 }
@@ -63,6 +66,7 @@ func (versionCommand) RunCommand(prog string, args []string, stdin io.Reader, st
 // ...prints "baz" and exits 2.
 type Multi map[string]Handler
 
+// RunCommand satisfies Handler interface
 func (m Multi) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
 	_, basename := filepath.Split(prog)
 	if i := strings.Index(basename, "~"); i >= 0 {
@@ -94,6 +98,7 @@ func (m Multi) RunCommand(prog string, args []string, stdin io.Reader, stdout, s
 	}
 }
 
+// Usage lists all the available commands to stderr
 func (m Multi) Usage(stderr io.Writer) {
 	fmt.Fprintf(stderr, "\nAvailable commands:\n")
 	m.listSubcommands(stderr, "")
@@ -121,6 +126,7 @@ func (m Multi) listSubcommands(out io.Writer, prefix string) {
 	}
 }
 
+// FlagSet interface for the flags and arguments to subcommand
 type FlagSet interface {
 	Init(string, flag.ErrorHandling)
 	Args() []string
diff --git a/lib/config/cmd.go b/lib/config/cmd.go
index d64106fbc..2c2a3b76f 100644
--- a/lib/config/cmd.go
+++ b/lib/config/cmd.go
@@ -18,6 +18,8 @@ import (
 	"github.com/sirupsen/logrus"
 )
 
+// DumpCommand implements cmd.Handler interface. This prints out the config
+// to stderr, this is useful for Operations.
 var DumpCommand dumpCommand
 
 type dumpCommand struct{}
@@ -67,6 +69,8 @@ func (dumpCommand) RunCommand(prog string, args []string, stdin io.Reader, stdou
 	return 0
 }
 
+// CheckCommand implements cmd.Handler interface. This checks if is a valid
+// configuration and also deprecation flags
 var CheckCommand checkCommand
 
 type checkCommand struct{}
@@ -161,9 +165,8 @@ func (checkCommand) RunCommand(prog string, args []string, stdin io.Reader, stdo
 
 	if problems {
 		return 1
-	} else {
-		return 0
 	}
+	return 0
 }
 
 func warnAboutProblems(logger logrus.FieldLogger, cfg *arvados.Config) bool {
@@ -181,6 +184,8 @@ func warnAboutProblems(logger logrus.FieldLogger, cfg *arvados.Config) bool {
 	return warned
 }
 
+// DumpDefaultsCommand implements cmd.Handler interface. This dumps the default configuration.
+// This is useful when starting an arvados cluster from scratch
 var DumpDefaultsCommand defaultsCommand
 
 type defaultsCommand struct{}
diff --git a/lib/config/generated_config.go b/lib/config/generated_config.go
index 96da19dfc..b38faefc2 100644
--- a/lib/config/generated_config.go
+++ b/lib/config/generated_config.go
@@ -4,6 +4,7 @@
 
 package config
 
+// DefaultYAML contains the default configuration as a []byte.7
 var DefaultYAML = []byte(`# Copyright (C) The Arvados Authors. All rights reserved.
 #
 # SPDX-License-Identifier: AGPL-3.0
diff --git a/lib/config/load.go b/lib/config/load.go
index be6181bbe..a276d958c 100644
--- a/lib/config/load.go
+++ b/lib/config/load.go
@@ -21,8 +21,10 @@ import (
 	"github.com/sirupsen/logrus"
 )
 
+// ErrNoClustersDefined is an error type when the config does not define any clusters
 var ErrNoClustersDefined = errors.New("config does not define any clusters")
 
+// Loader type is the main type load a configuration
 type Loader struct {
 	Stdin          io.Reader
 	Logger         logrus.FieldLogger
@@ -172,6 +174,8 @@ func (ldr *Loader) loadBytes(path string) ([]byte, error) {
 	return ioutil.ReadAll(f)
 }
 
+// Load returns an *arvados.Config. This is the main method to be called
+// once the Loader was initilized.
 func (ldr *Loader) Load() (*arvados.Config, error) {
 	if ldr.configdata == nil {
 		buf, err := ldr.loadBytes(ldr.Path)

commit 4ae35eda3130511ec7d5c0ac3d45879093b03f45
Author: Nico Cesar <nico at nicocesar.com>
Date:   Mon Jun 29 11:12:03 2020 -0400

    config.go documentation
    
    Arvados-DCO-1.1-Signed-off-by: Nico Cesar <nico at curii.com>

diff --git a/lib/config/config.go b/lib/config/config.go
new file mode 100644
index 000000000..002ae3e01
--- /dev/null
+++ b/lib/config/config.go
@@ -0,0 +1,6 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
+// Package config loads the config.
+package config

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list