Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Zylman committed May 8, 2014
1 parent e3a015f commit 1e01e55
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Limit struct {
Excludes map[string]interface{}
}

// LoadYaml loads byte data for a yaml file into a Config
func LoadYaml(data []byte) (Config, error) {
config := Config{}
if err := yaml.Unmarshal(data, &config); err != nil {
Expand All @@ -43,8 +44,7 @@ func LoadYaml(data []byte) (Config, error) {
return config, nil
}

// LoadAndValidateYaml turns a sequence of bytes into a Config and validates that all the necessary
// fields are set
// ValidateConfig validates that a Config has all the required fields
func ValidateConfig(config Config) error {
if config.Proxy.Handler == "" {
return fmt.Errorf("proxy.handler not set")
Expand All @@ -57,7 +57,7 @@ func ValidateConfig(config Config) error {
}

if _, err := url.ParseRequestURI(config.Proxy.Host); err != nil {
return errors.New("Could not parse proxy.host. Must include scheme (eg. https://example.com)")
return errors.New("could not parse proxy.host. Must include scheme (eg. https://example.com)")
}
if len(config.Limits) < 1 {
return fmt.Errorf("no limits definied")
Expand Down Expand Up @@ -96,6 +96,8 @@ func ValidateConfig(config Config) error {
return nil
}

// LoadAndValidateYaml turns a sequence of bytes into a Config and validates that all the necessary
// fields are set
// TODO (z): These should all be private, but right now tests depend on parsing bytes into yaml
func LoadAndValidateYaml(data []byte) (Config, error) {
config, err := LoadYaml(data)
Expand Down

0 comments on commit 1e01e55

Please sign in to comment.