Skip to content

Commit

Permalink
remove ManifestV2
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyng committed Jul 1, 2024
1 parent e70610e commit 3f0b309
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
17 changes: 5 additions & 12 deletions server/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,6 @@ type Message struct {
Content string `json:"content"`
}

type ManifestV2 struct {
SchemaVersion int `json:"schemaVersion"`
MediaType string `json:"mediaType"`
Config *Layer `json:"config"`
Layers []*Layer `json:"layers"`
}

type ConfigV2 struct {
ModelFormat string `json:"model_format"`
ModelFamily string `json:"model_family"`
Expand All @@ -160,7 +153,7 @@ type RootFS struct {
DiffIDs []string `json:"diff_ids"`
}

func GetManifest(mp ModelPath) (*ManifestV2, string, error) {
func GetManifest(mp ModelPath) (*Manifest, string, error) {
fp, err := mp.GetManifestPath()
if err != nil {
return nil, "", err
Expand All @@ -170,7 +163,7 @@ func GetManifest(mp ModelPath) (*ManifestV2, string, error) {
return nil, "", err
}

var manifest *ManifestV2
var manifest *Manifest

bts, err := os.ReadFile(fp)
if err != nil {
Expand Down Expand Up @@ -822,7 +815,7 @@ func PushModel(ctx context.Context, name string, regOpts *registryOptions, fn fu
func PullModel(ctx context.Context, name string, regOpts *registryOptions, fn func(api.ProgressResponse)) error {
mp := ParseModelPath(name)

var manifest *ManifestV2
var manifest *Manifest
var err error
var noprune string

Expand Down Expand Up @@ -929,7 +922,7 @@ func PullModel(ctx context.Context, name string, regOpts *registryOptions, fn fu
return nil
}

func pullModelManifest(ctx context.Context, mp ModelPath, regOpts *registryOptions) (*ManifestV2, error) {
func pullModelManifest(ctx context.Context, mp ModelPath, regOpts *registryOptions) (*Manifest, error) {
requestURL := mp.BaseURL().JoinPath("v2", mp.GetNamespaceRepository(), "manifests", mp.Tag)

headers := make(http.Header)
Expand All @@ -940,7 +933,7 @@ func pullModelManifest(ctx context.Context, mp ModelPath, regOpts *registryOptio
}
defer resp.Body.Close()

var m *ManifestV2
var m *Manifest
if err := json.NewDecoder(resp.Body).Decode(&m); err != nil {
return nil, err
}
Expand Down
20 changes: 11 additions & 9 deletions server/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import (
)

type Manifest struct {
ManifestV2
SchemaVersion int `json:"schemaVersion"`
MediaType string `json:"mediaType"`
Config *Layer `json:"config"`
Layers []*Layer `json:"layers"`

filepath string
fi os.FileInfo
Expand Down Expand Up @@ -66,7 +69,7 @@ func ParseNamedManifest(n model.Name) (*Manifest, error) {

p := filepath.Join(manifests, n.Filepath())

var m ManifestV2
var m Manifest
f, err := os.Open(p)
if err != nil {
return nil, err
Expand All @@ -83,12 +86,11 @@ func ParseNamedManifest(n model.Name) (*Manifest, error) {
return nil, err
}

return &Manifest{
ManifestV2: m,
filepath: p,
fi: fi,
digest: fmt.Sprintf("%x", sha256sum.Sum(nil)),
}, nil
m.filepath = p
m.fi = fi
m.digest = fmt.Sprintf("%x", sha256sum.Sum(nil))

return &m, nil
}

func WriteManifest(name model.Name, config *Layer, layers []*Layer) error {
Expand All @@ -108,7 +110,7 @@ func WriteManifest(name model.Name, config *Layer, layers []*Layer) error {
}
defer f.Close()

m := ManifestV2{
m := Manifest{
SchemaVersion: 2,
MediaType: "application/vnd.docker.distribution.manifest.v2+json",
Config: config,
Expand Down
2 changes: 1 addition & 1 deletion server/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func createManifest(t *testing.T, path, name string) {
}
defer f.Close()

if err := json.NewEncoder(f).Encode(ManifestV2{}); err != nil {
if err := json.NewEncoder(f).Encode(Manifest{}); err != nil {
t.Fatal(err)
}
}
Expand Down

0 comments on commit 3f0b309

Please sign in to comment.