Skip to content

Commit

Permalink
make geoserver/datastore/source public structs
Browse files Browse the repository at this point in the history
  • Loading branch information
hisham waleed karam committed Oct 14, 2018
1 parent b8707dc commit 6a6c95b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package gismanager

import "fmt"

type datastore struct {
type DatastoreConfig struct {
Host string `yaml:"host"`
Port uint `yaml:"port"`
DBName string `yaml:"database"`
Expand All @@ -12,11 +12,11 @@ type datastore struct {
}

//BuildConnectionString return gdal postgres connection as string
func (ds *datastore) BuildConnectionString() string {
func (ds *DatastoreConfig) BuildConnectionString() string {
return fmt.Sprintf("PG: host=%s port=%d dbname=%s user=%s password=%s", ds.Host, ds.Port, ds.DBName, ds.DBUser, ds.DBPass)
}

//PostgresConnectionString return postgres connection as string
func (ds *datastore) PostgresConnectionString() string {
func (ds *DatastoreConfig) PostgresConnectionString() string {
return fmt.Sprintf("postgresql://%s:%s@%s:%d/%s?sslmode=disable", ds.DBUser, ds.DBPass, ds.Host, ds.Port, ds.DBName)
}
2 changes: 1 addition & 1 deletion datastore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func TestBuildConnectionString(t *testing.T) {
ds := datastore{
ds := DatastoreConfig{
Host: "localhost",
Port: 5432,
DBName: "gis",
Expand Down
12 changes: 7 additions & 5 deletions manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@ import (
"github.com/sirupsen/logrus"
)

type geoserver struct {
//GeoserverConfig geoserver configuration
type GeoserverConfig struct {
WorkspaceName string `yaml:"workspace"`
ServerURL string `yaml:"url"`
Username string `yaml:"username"`
Password string `yaml:"password"`
}

type source struct {
//SourceConfig Data Source/Dir configuration
type SourceConfig struct {
Path string `yaml:"path"`
}

//ManagerConfig is the configuration Object
type ManagerConfig struct {
Geoserver geoserver `yaml:"geoserver"`
Datastore datastore `yaml:"datastore"`
Source source `yaml:"source"`
Geoserver GeoserverConfig `yaml:"geoserver"`
Datastore DatastoreConfig `yaml:"datastore"`
Source SourceConfig `yaml:"source"`
logger *logrus.Logger
}

Expand Down
6 changes: 3 additions & 3 deletions manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ func TestFromConfig(t *testing.T) {
assert.Nil(t, confErr)
assert.NotNil(t, manager)
expected := ManagerConfig{
Geoserver: geoserver{WorkspaceName: "golang", Username: "admin", Password: "geoserver", ServerURL: "http://localhost:8080/geoserver"},
Datastore: datastore{Host: "localhost", Port: 5432, DBName: "gis", DBUser: "golang", DBPass: "golang", Name: "gismanager_data"},
Source: source{Path: "./testdata"},
Geoserver: GeoserverConfig{WorkspaceName: "golang", Username: "admin", Password: "geoserver", ServerURL: "http://localhost:8080/geoserver"},
Datastore: DatastoreConfig{Host: "localhost", Port: 5432, DBName: "gis", DBUser: "golang", DBPass: "golang", Name: "gismanager_data"},
Source: SourceConfig{Path: "./testdata"},
logger: manager.logger,
}
assert.Equal(t, expected.Geoserver, manager.Geoserver)
Expand Down

0 comments on commit 6a6c95b

Please sign in to comment.