1
0
mirror of https://github.com/goharbor/harbor.git synced 2025-04-01 01:05:48 +02:00

Merge pull request from reasonerjt/clair-integration

small refinement to clair client
This commit is contained in:
Daniel Jiang 2017-06-26 14:34:08 +08:00 committed by GitHub
commit 34871fe202
2 changed files with 5 additions and 6 deletions
src
common/utils/clair
jobservice/utils

View File

@ -56,8 +56,6 @@ func (c *Client) ScanLayer(l models.ClairLayer) error {
if err != nil {
return err
}
c.logger.Infof("endpoint: %s", c.endpoint)
c.logger.Infof("body: %s", string(data))
req, err := http.NewRequest("POST", c.endpoint+"/v1/layers", bytes.NewReader(data))
if err != nil {
return err
@ -68,13 +66,13 @@ func (c *Client) ScanLayer(l models.ClairLayer) error {
return err
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
c.logger.Infof("response code: %d", resp.StatusCode)
if resp.StatusCode != http.StatusCreated {
c.logger.Warningf("Unexpected status code: %d", resp.StatusCode)
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
return fmt.Errorf("Unexpected status code: %d, text: %s", resp.StatusCode, string(b))
}
c.logger.Infof("Returning.")

View File

@ -65,6 +65,7 @@ func BuildBlobURL(endpoint, repository, digest string) string {
}
//GetTokenForRepo is a temp solution for job handler to get a token for clair.
//TODO: Get rid of it when it can get a token from repository client.
func GetTokenForRepo(repository string) (string, error) {
u, err := url.Parse(config.InternalTokenServiceEndpoint())
if err != nil {