image: fixed tags, catalog, push operation
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
const (
|
const (
|
||||||
confdir = "/usr/local/etc/mstore"
|
confdir = "/home/ziggi/Projects/mstore/etc/mstore"
|
||||||
rundir = "/var/run/mstore"
|
rundir = "/home/ziggi/Projects/mstore/tmp/run"
|
||||||
logdir = "/var/log/mstore"
|
logdir = "/home/ziggi/Projects/mstore/tmp/log"
|
||||||
datadir = "/var/data/mstore"
|
datadir = "/home/ziggi/Projects/mstore/tmp/data"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
srvname = "mstored"
|
srvname = "mstored"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -237,5 +237,6 @@ func (hand *Handler) ListManifests(rctx *router.Context) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("ListManifests error: %v", err)
|
hand.logg.Errorf("ListManifests error: %v", err)
|
||||||
}
|
}
|
||||||
rctx.SendJSON(code, res)
|
|
||||||
|
rctx.SendJSON(code, res.Repositories)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ func (oper *Operator) PutManifest(ctx context.Context, params *PutManifestParams
|
|||||||
return res, code, err
|
return res, code, err
|
||||||
}
|
}
|
||||||
inMan := &ocispec.Manifest{}
|
inMan := &ocispec.Manifest{}
|
||||||
|
inMan.Subject = &ocispec.Descriptor{}
|
||||||
|
inMan.Subject.Platform = &ocispec.Platform{}
|
||||||
|
|
||||||
err = json.Unmarshal(inManData, inMan)
|
err = json.Unmarshal(inManData, inMan)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("Manifest parsing error: %v", err)
|
err = fmt.Errorf("Manifest parsing error: %v", err)
|
||||||
@@ -107,9 +110,6 @@ func (oper *Operator) PutManifest(ctx context.Context, params *PutManifestParams
|
|||||||
name := params.Name
|
name := params.Name
|
||||||
reference := params.Reference
|
reference := params.Reference
|
||||||
|
|
||||||
if inMan.Subject == nil {
|
|
||||||
}
|
|
||||||
|
|
||||||
arch := inMan.Subject.Platform.Architecture
|
arch := inMan.Subject.Platform.Architecture
|
||||||
os := inMan.Subject.Platform.OS
|
os := inMan.Subject.Platform.OS
|
||||||
variant := inMan.Subject.Platform.Variant
|
variant := inMan.Subject.Platform.Variant
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ func (svc *Service) Build() error {
|
|||||||
svc.rout.Post(`/v2/{name}/blobs/uploads/`, svc.hand.PostUpload)
|
svc.rout.Post(`/v2/{name}/blobs/uploads/`, svc.hand.PostUpload)
|
||||||
svc.rout.Patch(`/v2/{name}/blobs/uploads/{reference}`, svc.hand.PatchUpload)
|
svc.rout.Patch(`/v2/{name}/blobs/uploads/{reference}`, svc.hand.PatchUpload)
|
||||||
svc.rout.Put(`/v2/{name}/blobs/uploads/{reference}`, svc.hand.PutUpload)
|
svc.rout.Put(`/v2/{name}/blobs/uploads/{reference}`, svc.hand.PutUpload)
|
||||||
|
svc.rout.Put(`/v2/{name}/uploads/{reference}`, svc.hand.PutUpload)
|
||||||
|
|
||||||
svc.rout.Get(`/v2/{name}/blobs/{digest}`, svc.hand.GetBlob)
|
svc.rout.Get(`/v2/{name}/blobs/{digest}`, svc.hand.GetBlob)
|
||||||
svc.rout.Delete(`/v2/{name}/blobs/{digest}`, svc.hand.DeleteBlob)
|
svc.rout.Delete(`/v2/{name}/blobs/{digest}`, svc.hand.DeleteBlob)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import (
|
|||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"mstore/pkg/descr"
|
||||||
"mstore/pkg/repocli"
|
"mstore/pkg/repocli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ type ImageTagsParams struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ImageTagsResult struct {
|
type ImageTagsResult struct {
|
||||||
ImageTags []string `json:"imageTags"`
|
Tags *descr.Tags `json:"imageTags"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (util *ImageUtil) ImageTags(cmd *cobra.Command, args []string) {
|
func (util *ImageUtil) ImageTags(cmd *cobra.Command, args []string) {
|
||||||
@@ -36,7 +37,7 @@ func (util *ImageUtil) ImageTags(cmd *cobra.Command, args []string) {
|
|||||||
func (util *ImageUtil) imageTags(common *CommonImageParams, params *ImageTagsParams) (*ImageTagsResult, error) {
|
func (util *ImageUtil) imageTags(common *CommonImageParams, params *ImageTagsParams) (*ImageTagsResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &ImageTagsResult{
|
res := &ImageTagsResult{
|
||||||
ImageTags: make([]string, 0),
|
Tags: &descr.Tags{},
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
@@ -52,6 +53,6 @@ func (util *ImageUtil) imageTags(common *CommonImageParams, params *ImageTagsPar
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
res.ImageTags = opres
|
res.Tags = opres
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func (cli *Client) CreateAccount(ctx context.Context, host, user, pass string) (
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
respdata, err := cli.doHTTPCall(ctx, host, "accont", "create", reqdata)
|
respdata, err := cli.doHTTPCall(ctx, host, "account", "create", reqdata)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -105,11 +105,11 @@ func Unarchive(filename, dstdir string) error {
|
|||||||
target = filepath.Clean(target)
|
target = filepath.Clean(target)
|
||||||
|
|
||||||
fileInfo := header.FileInfo()
|
fileInfo := header.FileInfo()
|
||||||
|
|
||||||
switch header.Typeflag {
|
switch header.Typeflag {
|
||||||
case tar.TypeDir:
|
case tar.TypeDir:
|
||||||
_, err := os.Stat(target)
|
_, err := os.Stat(target)
|
||||||
if err != nil && err == os.ErrNotExist {
|
if os.IsNotExist(err) {
|
||||||
|
err = nil
|
||||||
err := os.MkdirAll(target, fileInfo.Mode())
|
err := os.MkdirAll(target, fileInfo.Mode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -122,7 +122,7 @@ func Unarchive(filename, dstdir string) error {
|
|||||||
wrapfunc := func() error {
|
wrapfunc := func() error {
|
||||||
dir := filepath.Dir(target)
|
dir := filepath.Dir(target)
|
||||||
_, err := os.Stat(dir)
|
_, err := os.Stat(dir)
|
||||||
if err != nil && err == os.ErrNotExist {
|
if os.IsNotExist(err) {
|
||||||
err := os.MkdirAll(dir, 0750)
|
err := os.MkdirAll(dir, 0750)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ func (cli *Client) PushImage(ctx context.Context, filepath, imagepath string) er
|
|||||||
dstdir := auxtool.MakeTmpFilename(filepath)
|
dstdir := auxtool.MakeTmpFilename(filepath)
|
||||||
err = auxutar.Unarchive(filepath, dstdir)
|
err = auxutar.Unarchive(filepath, dstdir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.RemoveAll(dstdir)
|
//os.RemoveAll(dstdir)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
image, err := imageLoader(dstdir)
|
image, err := imageLoader(dstdir)
|
||||||
|
|||||||
@@ -18,11 +18,15 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"mstore/pkg/descr"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (cli *Client) GetTags(ctx context.Context, rawrepo string) ([]string, error) {
|
func (cli *Client) GetTags(ctx context.Context, rawrepo string) (*descr.Tags, error) {
|
||||||
var err error
|
var err error
|
||||||
list := make([]string, 0)
|
list := &descr.Tags{
|
||||||
|
Tags: make([]string, 0),
|
||||||
|
}
|
||||||
tagdata, err := cli.GetRawTags(ctx, rawrepo)
|
tagdata, err := cli.GetRawTags(ctx, rawrepo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return list, err
|
return list, err
|
||||||
|
|||||||
Reference in New Issue
Block a user