Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Henry Zhang 2016-03-24 15:50:53 +08:00
commit 440e949519
8 changed files with 25 additions and 12 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ Deploy/config/registry/config.yml
Deploy/config/ui/env
Deploy/config/ui/app.conf
Deploy/config/db/env
Deploy/harbor.cfg

View File

@ -72,7 +72,17 @@ Administrator can add "SysAdmin" role to an ordinary user by toggling the switch
![browse project](img/set_admin_remove_user.png)
##Pulling and pushing images using Docker client
**NOTE: Harbor only supports Registry V2 API. You need to use Docker client 1.6.0 or higher.**
Harbor supports HTTP by default and Docker client trys to connect to Harbor using HTTPS first, so if you encounter an error as below when you pull or push images, you need to add '--insecure-registry' option to /etc/default/docker (ubuntu) or /etc/sysconfig/docker (centos):
*FATA[0000] Error response from daemon: v1 ping attempt failed with error:
Get https://myregistrydomain.com:5000/v1/_ping: tls: oversized record received with length 20527.
If this private registry supports only HTTP or HTTPS with an unknown CA certificate,please add
`--insecure-registry myregistrydomain.com:5000` to the daemon's arguments.
In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag;
simply place the CA certificate at /etc/docker/certs.d/myregistrydomain.com:5000/ca.crt*
###Pulling images
If the project that the image belongs to is private, you should sign in first:

26
main.go
View File

@ -17,7 +17,8 @@ package main
import (
"fmt"
"log"
log "github.com/vmware/harbor/utils/log"
_ "github.com/vmware/harbor/auth/db"
_ "github.com/vmware/harbor/auth/ldap"
@ -38,28 +39,27 @@ func updateInitPassword(userID int, password string) error {
queryUser := models.User{UserID: userID}
user, err := dao.GetUser(queryUser)
if err != nil {
log.Println("Failed to get user, userID:", userID)
return err
return fmt.Errorf("Failed to get user, userID: %d %v", userID, err)
}
if user == nil {
log.Printf("User id: %d does not exist.", userID)
return fmt.Errorf("User id: %d does not exist.", userID)
} else if user.Salt == "" {
}
if user.Salt == "" {
salt, err := dao.GenerateRandomString()
if err != nil {
log.Printf("Failed to generate salt for encrypting password, %v", err)
return err
return fmt.Errorf("Failed to generate salt for encrypting password, %v", err)
}
user.Salt = salt
user.Password = password
err = dao.ChangeUserPassword(*user)
if err != nil {
log.Printf("Failed to update user encrypted password, userID: %d, err: %v", userID, err)
return err
return fmt.Errorf("Failed to update user encrypted password, userID: %d, err: %v", userID, err)
}
log.Printf("User id: %d updated its encypted password successfully.", userID)
log.Infof("User id: %d updated its encypted password successfully.", userID)
} else {
log.Printf("User id: %d already has its encrypted password.", userID)
log.Infof("User id: %d already has its encrypted password.", userID)
}
return nil
}
@ -68,6 +68,8 @@ func main() {
beego.BConfig.WebConfig.Session.SessionOn = true
dao.InitDB()
updateInitPassword(adminUserID, os.Getenv("HARBOR_ADMIN_PASSWORD"))
if err := updateInitPassword(adminUserID, os.Getenv("HARBOR_ADMIN_PASSWORD")); err != nil {
log.Error(err)
}
beego.Run()
}