Read image author from label 'maintainer' if author is null

This commit is contained in:
Wenkai Yin 2017-12-13 23:28:01 +08:00
parent 5caf31c57d
commit 745d83e393

View File

@ -20,6 +20,7 @@ import (
"io/ioutil"
"net/http"
"strconv"
"strings"
"time"
"github.com/docker/distribution/manifest/schema1"
@ -63,6 +64,11 @@ type tagDetail struct {
DockerVersion string `json:"docker_version"`
Author string `json:"author"`
Created time.Time `json:"created"`
Config *cfg `json:"config"`
}
type cfg struct {
Labels map[string]string `json:"labels"`
}
type tagResp struct {
@ -460,6 +466,14 @@ func getTagDetail(client *registry.Repository, tag string) (*tagDetail, error) {
return detail, err
}
if len(detail.Author) == 0 && detail.Config != nil {
for k, v := range detail.Config.Labels {
if strings.ToLower(k) == "maintainer" {
detail.Author = v
}
}
}
return detail, nil
}