Skip to content

Commit

Permalink
go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ear7h committed Apr 10, 2018
1 parent 47cd2e2 commit 84d502c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 26 deletions.
16 changes: 8 additions & 8 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"github.com/BurntSushi/toml"

"github.com/go-spatial/tegola"
"github.com/go-spatial/tegola/internal/log"
"github.com/go-spatial/tegola/config/env"
"github.com/go-spatial/tegola/internal/log"
)

// Config represents a tegola config file.
Expand All @@ -41,20 +41,20 @@ type Webserver struct {

// A Map represents a map in the Tegola Config file.
type Map struct {
Name env.String `toml:"name"`
Attribution env.String `toml:"attribution"`
Name env.String `toml:"name"`
Attribution env.String `toml:"attribution"`
Bounds []env.Float `toml:"bounds"`
Center [3]env.Float `toml:"center"`
Layers []MapLayer `toml:"layers"`
Layers []MapLayer `toml:"layers"`
}

type MapLayer struct {
// Name is optional. If it's not defined the name of the ProviderLayer will be used.
// Name can also be used to group multiple ProviderLayers under the same namespace.
Name env.String `toml:"name"`
ProviderLayer env.String `toml:"provider_layer"`
MinZoom *env.Uint `toml:"min_zoom"`
MaxZoom *env.Uint `toml:"max_zoom"`
Name env.String `toml:"name"`
ProviderLayer env.String `toml:"provider_layer"`
MinZoom *env.Uint `toml:"min_zoom"`
MaxZoom *env.Uint `toml:"max_zoom"`
DefaultTags interface{} `toml:"default_tags"`
// DontSimplify indicates wheather feature simplification should be applied.
// We use a negative in the name so the default is to simplify
Expand Down
17 changes: 8 additions & 9 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,21 @@ import (
)

const (
ENV_TEST_PORT = ":8888"
ENV_TEST_CENTER_X = -76.275329586789
ENV_TEST_CENTER_Y = 39.153492567373
ENV_TEST_CENTER_Z = 8.0
ENV_TEST_HOST_1 = "cdn"
ENV_TEST_HOST_2 = "tegola"
ENV_TEST_HOST_3 = "io"
ENV_TEST_HOST_CONCAT = ENV_TEST_HOST_1 + "." +ENV_TEST_HOST_2 + "." +ENV_TEST_HOST_3
ENV_TEST_PORT = ":8888"
ENV_TEST_CENTER_X = -76.275329586789
ENV_TEST_CENTER_Y = 39.153492567373
ENV_TEST_CENTER_Z = 8.0
ENV_TEST_HOST_1 = "cdn"
ENV_TEST_HOST_2 = "tegola"
ENV_TEST_HOST_3 = "io"
ENV_TEST_HOST_CONCAT = ENV_TEST_HOST_1 + "." + ENV_TEST_HOST_2 + "." + ENV_TEST_HOST_3
)

func setEnv() {
x := strconv.FormatFloat(ENV_TEST_CENTER_X, 'f', -1, 64)
y := strconv.FormatFloat(ENV_TEST_CENTER_Y, 'f', -1, 64)
z := strconv.FormatFloat(ENV_TEST_CENTER_Z, 'f', -1, 64)


os.Setenv("ENV_TEST_PORT", ENV_TEST_PORT)
os.Setenv("ENV_TEST_CENTER_X", x)
os.Setenv("ENV_TEST_CENTER_Y", y)
Expand Down
12 changes: 3 additions & 9 deletions config/env/types.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package env

import (
"fmt"
"os"
"regexp"
"strconv"
"strings"
"fmt"
)

// matches a variable surrounded by curly braces with leading dollar sign.
Expand All @@ -30,20 +30,16 @@ func (te *TypeError) Error() string {
return fmt.Sprintf("type %t could not be converted", te.v)
}


// replaceEnvVars replaces environment variable placeholders in reader stream with values
func replaceEnvVar(in string) (string, error) {
// loop through all environment variable matches
for
locs := regex.FindStringIndex(in);
locs != nil;
locs = regex.FindStringIndex(in) {
for locs := regex.FindStringIndex(in); locs != nil; locs = regex.FindStringIndex(in) {

// extract match from the input string
match := in[locs[0]:locs[1]]

// trim the leading '${' and trailing '}'
varName := match[2:len(match)-1]
varName := match[2 : len(match)-1]

// get env var
envVar, ok := os.LookupEnv(varName)
Expand Down Expand Up @@ -85,8 +81,6 @@ func (t *Bool) UnmarshalTOML(v interface{}) error {
return &TypeError{v}
}



*t = Bool(boolVal)
return nil
}
Expand Down

0 comments on commit 84d502c

Please sign in to comment.