Lots of various golint fixes
Changes some names to match go conventions Comments all exported methods Removes dot imports
This commit is contained in:
parent
b5cf681458
commit
88795e0a14
19 changed files with 417 additions and 257 deletions
|
@ -23,9 +23,9 @@ type Configuration struct {
|
|||
Storage Storage `yaml:"storage"`
|
||||
}
|
||||
|
||||
// v_0_1_Configuration is a Version 0.1 Configuration struct
|
||||
// v0_1Configuration is a Version 0.1 Configuration struct
|
||||
// This is currently aliased to Configuration, as it is the current version
|
||||
type v_0_1_Configuration Configuration
|
||||
type v0_1Configuration Configuration
|
||||
|
||||
// Version is a major/minor version pair of the form Major.Minor
|
||||
// Major version upgrades indicate structure or type changes
|
||||
|
@ -195,7 +195,7 @@ func Parse(in []byte) (*Configuration, error) {
|
|||
// Parse the remainder of the configuration depending on the provided version
|
||||
switch untypedConfig.Version {
|
||||
case "0.1":
|
||||
config, err = parseV_0_1_Registry(in)
|
||||
config, err = parseV0_1Registry(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -206,11 +206,11 @@ func Parse(in []byte) (*Configuration, error) {
|
|||
return config, nil
|
||||
}
|
||||
|
||||
// parseV_0_1_Registry parses a registry Configuration for Version 0.1
|
||||
func parseV_0_1_Registry(in []byte) (*Configuration, error) {
|
||||
// parseV0_1Registry parses a registry Configuration for Version 0.1
|
||||
func parseV0_1Registry(in []byte) (*Configuration, error) {
|
||||
envMap := getEnvMap()
|
||||
|
||||
var config v_0_1_Configuration
|
||||
var config v0_1Configuration
|
||||
err := yaml.Unmarshal(in, &config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
// Hook up gocheck into the "go test" runner
|
||||
func Test(t *testing.T) { TestingT(t) }
|
||||
|
||||
// configStruct is a canonical example configuration, which should map to configYamlV_0_1
|
||||
// configStruct is a canonical example configuration, which should map to configYamlV0_1
|
||||
var configStruct = Configuration{
|
||||
Version: "0.1",
|
||||
Loglevel: "info",
|
||||
|
@ -31,8 +31,8 @@ var configStruct = Configuration{
|
|||
},
|
||||
}
|
||||
|
||||
// configYamlV_0_1 is a Version 0.1 yaml document representing configStruct
|
||||
var configYamlV_0_1 = `
|
||||
// configYamlV0_1 is a Version 0.1 yaml document representing configStruct
|
||||
var configYamlV0_1 = `
|
||||
version: 0.1
|
||||
loglevel: info
|
||||
storage:
|
||||
|
@ -48,9 +48,9 @@ storage:
|
|||
port: ~
|
||||
`
|
||||
|
||||
// inmemoryConfigYamlV_0_1 is a Version 0.1 yaml document specifying an inmemory storage driver with
|
||||
// inmemoryConfigYamlV0_1 is a Version 0.1 yaml document specifying an inmemory storage driver with
|
||||
// no parameters
|
||||
var inmemoryConfigYamlV_0_1 = `
|
||||
var inmemoryConfigYamlV0_1 = `
|
||||
version: 0.1
|
||||
loglevel: info
|
||||
storage: inmemory
|
||||
|
@ -77,9 +77,9 @@ func (suite *ConfigSuite) TestMarshalRoundtrip(c *C) {
|
|||
c.Assert(config, DeepEquals, suite.expectedConfig)
|
||||
}
|
||||
|
||||
// TestParseSimple validates that configYamlV_0_1 can be parsed into a struct matching configStruct
|
||||
// TestParseSimple validates that configYamlV0_1 can be parsed into a struct matching configStruct
|
||||
func (suite *ConfigSuite) TestParseSimple(c *C) {
|
||||
config, err := Parse([]byte(configYamlV_0_1))
|
||||
config, err := Parse([]byte(configYamlV0_1))
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(config, DeepEquals, suite.expectedConfig)
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ func (suite *ConfigSuite) TestParseSimple(c *C) {
|
|||
func (suite *ConfigSuite) TestParseInmemory(c *C) {
|
||||
suite.expectedConfig.Storage = Storage{"inmemory": Parameters{}}
|
||||
|
||||
config, err := Parse([]byte(inmemoryConfigYamlV_0_1))
|
||||
config, err := Parse([]byte(inmemoryConfigYamlV0_1))
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(config, DeepEquals, suite.expectedConfig)
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ func (suite *ConfigSuite) TestParseWithSameEnvStorage(c *C) {
|
|||
os.Setenv("REGISTRY_STORAGE", "s3")
|
||||
os.Setenv("REGISTRY_STORAGE_S3_REGION", "us-east-1")
|
||||
|
||||
config, err := Parse([]byte(configYamlV_0_1))
|
||||
config, err := Parse([]byte(configYamlV0_1))
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(config, DeepEquals, suite.expectedConfig)
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ func (suite *ConfigSuite) TestParseWithDifferentEnvStorageParams(c *C) {
|
|||
os.Setenv("REGISTRY_STORAGE_S3_SECURE", "true")
|
||||
os.Setenv("REGISTRY_STORAGE_S3_NEWPARAM", "some Value")
|
||||
|
||||
config, err := Parse([]byte(configYamlV_0_1))
|
||||
config, err := Parse([]byte(configYamlV0_1))
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(config, DeepEquals, suite.expectedConfig)
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ func (suite *ConfigSuite) TestParseWithDifferentEnvStorageType(c *C) {
|
|||
|
||||
os.Setenv("REGISTRY_STORAGE", "inmemory")
|
||||
|
||||
config, err := Parse([]byte(configYamlV_0_1))
|
||||
config, err := Parse([]byte(configYamlV0_1))
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(config, DeepEquals, suite.expectedConfig)
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ func (suite *ConfigSuite) TestParseWithDifferentEnvStorageTypeAndParams(c *C) {
|
|||
os.Setenv("REGISTRY_STORAGE", "filesystem")
|
||||
os.Setenv("REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY", "/tmp/testroot")
|
||||
|
||||
config, err := Parse([]byte(configYamlV_0_1))
|
||||
config, err := Parse([]byte(configYamlV0_1))
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(config, DeepEquals, suite.expectedConfig)
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ func (suite *ConfigSuite) TestParseWithDifferentEnvStorageTypeAndParams(c *C) {
|
|||
func (suite *ConfigSuite) TestParseWithSameEnvLoglevel(c *C) {
|
||||
os.Setenv("REGISTRY_LOGLEVEL", "info")
|
||||
|
||||
config, err := Parse([]byte(configYamlV_0_1))
|
||||
config, err := Parse([]byte(configYamlV0_1))
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(config, DeepEquals, suite.expectedConfig)
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ func (suite *ConfigSuite) TestParseWithDifferentEnvLoglevel(c *C) {
|
|||
|
||||
os.Setenv("REGISTRY_LOGLEVEL", "error")
|
||||
|
||||
config, err := Parse([]byte(configYamlV_0_1))
|
||||
config, err := Parse([]byte(configYamlV0_1))
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(config, DeepEquals, suite.expectedConfig)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue