mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-05 18:20:37 +01:00
small refinement to clair client
This commit is contained in:
parent
e0f01cfd09
commit
ed296812f0
@ -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.")
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user