Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

Commit

Permalink
Merge pull request #605 from 3ofcoins/unbreak-validator
Browse files Browse the repository at this point in the history
ace/validator.go: small fixes
  • Loading branch information
jonboulle committed May 17, 2016
2 parents 5a62e1c + e4af9ae commit ef05e2b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions ace/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ func metadataRequest(req *http.Request, expectedContentType string) ([]byte, err
}

if respContentType := resp.Header.Get("Content-Type"); respContentType != expectedContentType {
return nil, fmt.Errorf("`%s` did not respond with expected Content-Type header. Expected %s, received %s",
req.RequestURI, expectedContentType, respContentType)
return nil, fmt.Errorf("`%v` did not respond with expected Content-Type header. Expected %s, received %s",
req.URL, expectedContentType, respContentType)
}

body, err := ioutil.ReadAll(resp.Body)
Expand Down Expand Up @@ -292,12 +292,12 @@ func validatePodAnnotations(metadataURL string, pm *schema.PodManifest) results

var actualAnnots types.Annotations

annotJson, err := metadataGet(metadataURL, "/pod/annotations/", "application/json")
annotJson, err := metadataGet(metadataURL, "/pod/annotations", "application/json")
if err != nil {
return append(r, err)
}

err = json.Unmarshal(annotJson, actualAnnots)
err = json.Unmarshal(annotJson, &actualAnnots)
if err != nil {
return append(r, err)
}
Expand Down Expand Up @@ -338,6 +338,9 @@ func validateAppAnnotations(metadataURL string, pm *schema.PodManifest, app *sch
for _, annot := range a.Annotations {
expectedAnnots.Set(annot.Name, annot.Value)
}
if len(expectedAnnots) == 0 {
expectedAnnots = nil
}

var actualAnnots types.Annotations

Expand All @@ -346,10 +349,13 @@ func validateAppAnnotations(metadataURL string, pm *schema.PodManifest, app *sch
return append(r, err)
}

err = json.Unmarshal(annotJson, actualAnnots)
err = json.Unmarshal(annotJson, &actualAnnots)
if err != nil {
return append(r, err)
}
if len(actualAnnots) == 0 {
actualAnnots = nil
}

if !reflect.DeepEqual(actualAnnots, expectedAnnots) {
err := fmt.Errorf("%v annotations mismatch: %v vs %v", app.Name, actualAnnots, expectedAnnots)
Expand Down

0 comments on commit ef05e2b

Please sign in to comment.