mirror of
https://github.com/genuinetools/reg.git
synced 2024-05-12 09:28:32 -04:00
confirm the requested schema version matches the returned (#148)
This commit is contained in:
parent
cbabe28c68
commit
478c4dadc6
|
@ -3,6 +3,7 @@ package registry
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
@ -13,6 +14,11 @@ import (
|
|||
"github.com/docker/distribution/manifest/schema2"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrUnexpectedSchemaVersion a specific schema version was requested, but was not returned
|
||||
ErrUnexpectedSchemaVersion = errors.New("recieved a different schema version than expected")
|
||||
)
|
||||
|
||||
// Manifest returns the manifest for a specific repository:tag.
|
||||
func (r *Registry) Manifest(repository, ref string) (distribution.Manifest, error) {
|
||||
uri := r.url("/v2/%s/manifests/%s", repository, ref)
|
||||
|
@ -70,6 +76,10 @@ func (r *Registry) ManifestV2(repository, ref string) (schema2.Manifest, error)
|
|||
return m, err
|
||||
}
|
||||
|
||||
if m.Versioned.SchemaVersion != 2 {
|
||||
return m, ErrUnexpectedSchemaVersion
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
|
@ -84,6 +94,10 @@ func (r *Registry) ManifestV1(repository, ref string) (schema1.SignedManifest, e
|
|||
return m, err
|
||||
}
|
||||
|
||||
if m.Versioned.SchemaVersion != 1 {
|
||||
return m, ErrUnexpectedSchemaVersion
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue