Merge pull request #446 from ywk253100/insecure_env

pass insecure env to ui
This commit is contained in:
Daniel Jiang 2016-06-29 19:39:08 +08:00 committed by GitHub
commit 34a93348a7
5 changed files with 18 additions and 8 deletions

View File

@ -98,7 +98,8 @@ render(os.path.join(templates_dir, "ui", "env"),
ldap_url=ldap_url,
ldap_basedn=ldap_basedn,
self_registration=self_registration,
ui_secret=ui_secret)
ui_secret=ui_secret,
verify_remote_cert=verify_remote_cert)
render(os.path.join(templates_dir, "ui", "app.conf"),
ui_conf,

View File

@ -17,3 +17,4 @@ LOG_LEVEL=debug
GODEBUG=netdns=cgo
EXT_ENDPOINT=$ui_url
TOKEN_URL=http://ui
VERIFY_REMOTE_CERT=$verify_remote_cert

View File

@ -19,6 +19,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"os"
"strconv"
"github.com/astaxie/beego/validation"
@ -136,3 +137,14 @@ func (b *BaseAPI) GetIDFromURL() int64 {
return id
}
func getIsInsecure() bool {
insecure := false
verifyRemoteCert := os.Getenv("VERIFY_REMOTE_CERT")
if verifyRemoteCert == "off" {
insecure = true
}
return insecure
}

View File

@ -271,12 +271,10 @@ func (ra *RepositoryAPI) GetManifests() {
func (ra *RepositoryAPI) initRepositoryClient(repoName string) (r *registry.Repository, err error) {
endpoint := os.Getenv("REGISTRY_URL")
// TODO read variable from config file
insecure := true
username, password, ok := ra.Ctx.Request.BasicAuth()
if ok {
return newRepositoryClient(endpoint, insecure, username, password,
return newRepositoryClient(endpoint, getIsInsecure(), username, password,
repoName, "repository", repoName, "pull", "push", "*")
}
@ -285,7 +283,7 @@ func (ra *RepositoryAPI) initRepositoryClient(repoName string) (r *registry.Repo
return nil, err
}
return cache.NewRepositoryClient(endpoint, insecure, username, repoName,
return cache.NewRepositoryClient(endpoint, getIsInsecure(), username, repoName,
"repository", repoName, "pull", "push", "*")
}

View File

@ -92,9 +92,7 @@ func (t *TargetAPI) Ping() {
password = t.GetString("password")
}
// TODO read variable from config file
insecure := true
registry, err := newRegistryClient(endpoint, insecure, username, password,
registry, err := newRegistryClient(endpoint, getIsInsecure(), username, password,
"", "", "")
if err != nil {
// timeout, dns resolve error, connection refused, etc.