From e5304137008c8afddef71169470142b0415d9408 Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Fri, 25 Mar 2016 00:08:32 -0700 Subject: [PATCH 1/3] update logger for autoenticator.go, passed on docker-compose build --- auth/authenticator.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/auth/authenticator.go b/auth/authenticator.go index 14f881cde..78770eb8a 100644 --- a/auth/authenticator.go +++ b/auth/authenticator.go @@ -17,12 +17,11 @@ package auth import ( "fmt" - "log" "os" - "github.com/vmware/harbor/models" + log "github.com/vmware/harbor/utils/log" - "github.com/astaxie/beego" + "github.com/vmware/harbor/models" ) // Authenticator provides interface to authenticate user credentials. @@ -37,7 +36,7 @@ var registry = make(map[string]Authenticator) // Register add different authenticators to registry map. func Register(name string, authenticator Authenticator) { if _, dup := registry[name]; dup { - log.Printf("authenticator: %s has been registered", name) + log.Infof("authenticator: %s has been registered", name) return } registry[name] = authenticator @@ -50,7 +49,7 @@ func Login(m models.AuthModel) (*models.User, error) { if authMode == "" || m.Principal == "admin" { authMode = "db_auth" } - beego.Debug("Current AUTH_MODE is ", authMode) + log.Debug("Current AUTH_MODE is ", authMode) authenticator, ok := registry[authMode] if !ok { From d2eaf6a14857017ab23dfd2b1015d0f3834a6634 Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Fri, 25 Mar 2016 03:17:42 -0700 Subject: [PATCH 2/3] update logger for ldap.go --- auth/ldap/ldap.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/auth/ldap/ldap.go b/auth/ldap/ldap.go index bc24cb8fe..43b317721 100644 --- a/auth/ldap/ldap.go +++ b/auth/ldap/ldap.go @@ -18,15 +18,15 @@ package ldap import ( "errors" "fmt" - "log" "os" "strings" + log "github.com/vmware/harbor/utils/log" + "github.com/vmware/harbor/auth" "github.com/vmware/harbor/dao" "github.com/vmware/harbor/models" - "github.com/astaxie/beego" "github.com/mqu/openldap" ) @@ -44,7 +44,7 @@ func (l *Auth) Authenticate(m models.AuthModel) (*models.User, error) { if ldapURL == "" { return nil, errors.New("Can not get any available LDAP_URL.") } - beego.Debug("ldapURL:", ldapURL) + log.Debug("ldapURL:", ldapURL) p := m.Principal for _, c := range metaChars { @@ -66,7 +66,7 @@ func (l *Auth) Authenticate(m models.AuthModel) (*models.User, error) { } baseDn := fmt.Sprintf(ldapBaseDn, m.Principal) - beego.Debug("baseDn:", baseDn) + log.Debug("baseDn:", baseDn) err = ldap.Bind(baseDn, m.Password) if err != nil { @@ -83,7 +83,7 @@ func (l *Auth) Authenticate(m models.AuthModel) (*models.User, error) { return nil, err } if len(result.Entries()) != 1 { - log.Printf("Found more than one entry.") + log.Infof("Found more than one entry.") return nil, nil } en := result.Entries()[0] @@ -100,7 +100,7 @@ func (l *Auth) Authenticate(m models.AuthModel) (*models.User, error) { } } - beego.Debug("username:", u.Username, ",email:", u.Email, ",realname:", u.Realname) + log.Debug("username:", u.Username, ",email:", u.Email, ",realname:", u.Realname) exist, err := dao.UserExists(u, "username") if err != nil { From 317de6ee88c77ba6b07c5017f049e0a5e8650b92 Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Fri, 25 Mar 2016 03:41:10 -0700 Subject: [PATCH 3/3] update logger per comments --- auth/authenticator.go | 2 +- auth/ldap/ldap.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/auth/authenticator.go b/auth/authenticator.go index 78770eb8a..1640a842e 100644 --- a/auth/authenticator.go +++ b/auth/authenticator.go @@ -19,7 +19,7 @@ import ( "fmt" "os" - log "github.com/vmware/harbor/utils/log" + "github.com/vmware/harbor/utils/log" "github.com/vmware/harbor/models" ) diff --git a/auth/ldap/ldap.go b/auth/ldap/ldap.go index 43b317721..53d17a174 100644 --- a/auth/ldap/ldap.go +++ b/auth/ldap/ldap.go @@ -21,7 +21,7 @@ import ( "os" "strings" - log "github.com/vmware/harbor/utils/log" + "github.com/vmware/harbor/utils/log" "github.com/vmware/harbor/auth" "github.com/vmware/harbor/dao" @@ -83,7 +83,7 @@ func (l *Auth) Authenticate(m models.AuthModel) (*models.User, error) { return nil, err } if len(result.Entries()) != 1 { - log.Infof("Found more than one entry.") + log.Warningf("Found more than one entry.") return nil, nil } en := result.Entries()[0]