Skip to content

Commit 9be15c7

Browse files
fperot74harture
authored andcommitted
Remove dependencies
1 parent 8df1902 commit 9be15c7

25 files changed

+548
-411
lines changed

.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ before_install:
77
- go get github.com/mattn/goveralls
88
- go get golang.org/x/tools/cmd/cover
99
- go get github.com/golang/dep/cmd/dep
10+
- go get github.com/golang/mock/gomock
11+
- go install github.com/golang/mock/mockgen
1012
install:
1113
- $GOPATH/bin/dep ensure -v
12-
- $GOPATH/bin/go generate ./...
14+
- go generate ./...
1315
script:
1416
- go list -f '{{if or (.XTestGoFiles | len) (.TestGoFiles | len) }}"go test -coverprofile={{.Dir}}/.coverprofile {{.ImportPath}}"{{end}}' ./... | xargs -L 1 sh -c
1517
- gover

Gopkg.lock

+4-153
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+1-13
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
[[constraint]]
4545
name = "github.com/golang/mock"
46-
version = "1.2.0"
46+
version = "1.3.0"
4747

4848
[[constraint]]
4949
name = "github.com/gorilla/mux"
@@ -61,14 +61,6 @@
6161
name = "github.com/pkg/errors"
6262
version = "0.8.1"
6363

64-
[[constraint]]
65-
name = "github.com/rs/cors"
66-
version = "1.6.0"
67-
68-
[[constraint]]
69-
name = "github.com/spf13/viper"
70-
version = "1.3.2"
71-
7264
[[constraint]]
7365
name = "github.com/stretchr/testify"
7466
version = "1.3.0"
@@ -77,10 +69,6 @@
7769
name = "github.com/uber/jaeger-client-go"
7870
version = "2.16.0"
7971

80-
[[constraint]]
81-
branch = "master"
82-
name = "golang.org/x/time"
83-
8472
[prune]
8573
go-tests = true
8674
unused-packages = true

README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
# common-service
1+
# common-service
2+
3+
common-service is a library which provides tools to Cloudtrust components designed as a web-based service
4+
5+
* database: tools used to automatically retrieve configuration and open a database connexion (can provide Noop "connection")
6+
* http: provides tools to handle decoding of HTTP requests and encoding of responses/errors. Also provides a handler for "Version" requests
7+
* idgenerator: generator of identifiers
8+
* metrics: Influx client management
9+
* middleware: provides tools to check authentication, ensure a correlationID exists
10+
* security: authorization manager
11+
* tracing: Jaeger client management
12+
* tracking: Sentry client management

database/dbase.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"time"
77

8-
"github.com/spf13/viper"
8+
cs "github.com/cloudtrust/common-service"
99
)
1010

1111
// CloudtrustDB interface
@@ -32,7 +32,11 @@ type DbConfig struct {
3232
}
3333

3434
// ConfigureDbDefault configure default database parameters for a given prefix
35-
func ConfigureDbDefault(v *viper.Viper, prefix, envUser, envPasswd string) {
35+
// Parameters are built with the given prefix, then a dash symbol, then one of these suffixes:
36+
// host-port, username, password, database, protocol, max-open-conns, max-idle-conns, conn-max-lifetime
37+
// If a parameter exists only named with the given prefix and if its value if false, the database connection
38+
// will be a Noop one
39+
func ConfigureDbDefault(v cs.Configuration, prefix, envUser, envPasswd string) {
3640
v.SetDefault(prefix+"-host-port", "")
3741
v.SetDefault(prefix+"-username", "")
3842
v.SetDefault(prefix+"-password", "")
@@ -46,8 +50,8 @@ func ConfigureDbDefault(v *viper.Viper, prefix, envUser, envPasswd string) {
4650
v.BindEnv(prefix+"-password", envPasswd)
4751
}
4852

49-
// GetDbConfig reads db configuration parameters from Viper
50-
func GetDbConfig(v *viper.Viper, prefix string, noop bool) *DbConfig {
53+
// GetDbConfig reads db configuration parameters
54+
func GetDbConfig(v cs.Configuration, prefix string, noop bool) *DbConfig {
5155
var cfg DbConfig
5256

5357
cfg.Noop = noop
@@ -66,6 +70,7 @@ func GetDbConfig(v *viper.Viper, prefix string, noop bool) *DbConfig {
6670
}
6771

6872
// OpenDatabase gets an access to a database
73+
// If cfg.Noop is true, a Noop access will be provided
6974
func (cfg *DbConfig) OpenDatabase() (CloudtrustDB, error) {
7075
if cfg.Noop {
7176
return NoopDB{}, nil

0 commit comments

Comments
 (0)