Refactor names to avoid stutter (#1)

Since client code uses the package name as a prefix when referring to
the package contents, the names for those contents need not repeat the
package name.

- Rename base.BaseCommand to base.Command
- Rename base.BaseServer to base.Server
- Rename config.DevConfig() to config.Dev()
- Rename config.LoadConfigFile() to config.LoadFile()
- Rename config.NewConfig() to config.New()
- Rename config.ParseConfig() to config.Parse()
- Rename controller.ControllerCommand to controller.Command
- Rename controller.NewController() to controller.New()
- Rename dev.DevCommand to dev.Command
- Rename listener.ListenerFactory to listener.Factory
- Rename listener.NewListener() to listener.New()
- Rename version.GetVersion() to version.Get()
- Rename version.VersionInfo to version.Info

See:
- https://golang.org/doc/effective_go.html#package-names
- https://blog.golang.org/package-names#TOC_3.
- https://github.com/golang/go/wiki/CodeReviewComments#package-names
This commit is contained in:
Michael Gaffney authored and GitHub committed 2020-03-10 15:48:04 -04:00
1 parent 39c629631f
commit 5e5a56cac0
14 files changed
+91 -91

No files matched your search

@@ -17,8 +17,8 @@ type Config struct {
*configutil.SharedConfig `hcl:"-"`
}
// DevConfig is a Config that is used for dev mode of Watchtower
func DevConfig() (*Config, error) {
// Dev is a Config that is used for dev mode of Watchtower
func Dev() (*Config, error) {
randBuf := new(bytes.Buffer)
n, err := randBuf.ReadFrom(&io.LimitedReader{
R: rand.Reader,
@@ -61,28 +61,28 @@ kms "aead" {
`
hclStr = fmt.Sprintf(hclStr, controllerKey, workerAuthKey)
parsed, err := ParseConfig(hclStr)
parsed, err := Parse(hclStr)
if err != nil {
return nil, fmt.Errorf("error parsing dev config: %w", err)
}
return parsed, nil
}
func NewConfig() *Config {
func New() *Config {
return &Config{
SharedConfig: new(configutil.SharedConfig),
}
}
// LoadConfigFile loads the configuration from the given file.
func LoadConfigFile(path string) (*Config, error) {
// LoadFile loads the configuration from the given file.
func LoadFile(path string) (*Config, error) {
// Read the file
d, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
conf, err := ParseConfig(string(d))
conf, err := Parse(string(d))
if err != nil {
return nil, err
}
@@ -90,14 +90,14 @@ func LoadConfigFile(path string) (*Config, error) {
return conf, nil
}
func ParseConfig(d string) (*Config, error) {
func Parse(d string) (*Config, error) {
obj, err := hcl.Parse(d)
if err != nil {
return nil, err
}
// Nothing to do here right now
result := NewConfig()
result := New()
if err := hcl.DecodeObject(result, obj); err != nil {
return nil, err
}