Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration option for debug mode #86

Merged
merged 1 commit into from
Dec 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
)

const (
varDebugMode = "debug"
varPostgresHost = "postgres.host"
varPostgresPort = "postgres.port"
varPostgresUser = "postgres.user"
Expand Down Expand Up @@ -248,3 +249,8 @@ func (c *Data) GetMaxRequestretry() int {
func (c *Data) GetLocalDevEnv() bool {
return c.v.GetBool(varLocalDevEnv)
}

// GetDebugMode returns if debug mode should be enabled as set via default, config file, or environment variable
func (c *Data) GetDebugMode() bool {
return c.v.GetBool(varDebugMode)
}
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ func main() {
log.Fatal(err)
}

if config.GetDebugMode() {
log.SetLevel(log.DebugLevel)
}

//Run mock services if this is local dev env
if config.GetLocalDevEnv() {
testutils.Run()
Expand Down
2 changes: 2 additions & 0 deletions openshift/jenkins-proxy.app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ objects:
secretKeyRef:
name: jenkins-proxy
key: postgres.password
- name: JC_DEBUG
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does JC stand for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I started to write idler I called it Jenkins Controller, so I used prefix JC...would be probably a good thing to refactor in the future so that it makes more sense..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created issue #87

value: true
- name: GODEBUG
value: gctrace=1
image: ${IMAGE}:${IMAGE_TAG}
Expand Down
2 changes: 1 addition & 1 deletion proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ func (p *Proxy) RecordStatistics(ns string, la int64, lbf int64) (err error) {
}
}
if notFound {
log.Info("New user %s", ns)
log.Infof("New user %s", ns)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

s = storage.NewStatistics(ns, la, lbf)
}
if la != 0 {
Expand Down
3 changes: 3 additions & 0 deletions storage/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ func Connect(config *configuration.Data) *gorm.DB {
db.DB().SetMaxOpenConns(config.GetPostgresConnectionMaxOpen())
}

if config.GetDebugMode() {
db = db.Debug()
}
db.CreateTable(&Request{})
db.CreateTable(&Statistics{})

Expand Down
2 changes: 1 addition & 1 deletion testutils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func TenantData1(url string) []byte {
{
"cluster-url":"%s",
"created-at":"2017-10-11T18:47:28.491233Z",
"name":"vpavlin-jenkins",
"name":"vpavlin-osiotest1-jenkins",
"state":"created",
"type":"jenkins",
"updated-at":"2017-10-11T18:47:28.491233Z",
Expand Down