Merge pull request #421 from GLYASAI/imageinfo

[FIX] wrong domain
This commit is contained in:
barnettZQG 2019-09-03 02:46:58 -05:00 committed by GitHub
commit 80afb9f40f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 15 deletions

View File

@ -29,10 +29,10 @@ import (
"github.com/Sirupsen/logrus"
"github.com/coreos/etcd/clientv3"
"github.com/docker/distribution/reference"
api_model "github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/api/proxy"
"github.com/goodrain/rainbond/api/util"
"github.com/goodrain/rainbond/builder/parser"
"github.com/goodrain/rainbond/cmd/api/option"
"github.com/goodrain/rainbond/db"
core_model "github.com/goodrain/rainbond/db/model"
@ -1925,20 +1925,10 @@ func (s *ServiceAction) ListVersionInfo(serviceID string) (*api_model.BuildListR
for idx := range bversions {
bv := bversions[idx]
if bv.Kind == "build_from_image" || bv.Kind == "build_from_market_image" {
repo, err := reference.Parse(bv.RepoURL)
if err != nil {
logrus.Warningf("repo url: %s; error paring image repo url: %v", bv.RepoURL, err)
continue
}
if named, ok := repo.(reference.Named); ok {
bv.ImageRepo = named.Name()
domain, _ := reference.SplitHostname(named)
bv.ImageDomain = domain
}
tagged, ok := repo.(reference.Tagged)
if ok {
bv.ImageTag = tagged.Tag()
}
image := parser.ParseImageName(bv.RepoURL)
bv.ImageDomain = image.GetDomain()
bv.ImageRepo = image.GetRepostory()
bv.ImageTag = image.GetTag()
}
}
result := &api_model.BuildListRespVO{

View File

@ -42,6 +42,12 @@ func TestParseImageName(t *testing.T) {
t.Logf("repostory %s", image3.GetRepostory())
t.Logf("name %s", image3.GetSimpleName())
t.Logf("tag %s", image3.GetTag())
image4 := ParseImageName("abewang/foobar")
t.Logf("string %s", image4.String())
t.Logf("domain %s", image4.GetDomain())
t.Logf("repostory %s", image4.GetRepostory())
t.Logf("name %s", image4.GetSimpleName())
t.Logf("tag %s", image4.GetTag())
}
func TestDetermineDeployType(t *testing.T) {
t.Log(DetermineDeployType(ParseImageName("barnett/zookeeper:3.2")))