alittle splitted mstorectl code; etc
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
||||
*
|
||||
* This work is published and licensed under a Creative Commons
|
||||
* Attribution-NonCommercial-NoDerivatives 4.0 International License.
|
||||
*
|
||||
* Distribution of this work is permitted, but commercial use and
|
||||
* modifications are strictly prohibited.
|
||||
*/
|
||||
package imageoper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"mstore/pkg/auxuuid"
|
||||
)
|
||||
|
||||
type PostUploadParams struct {
|
||||
Name string
|
||||
Digest string
|
||||
Mount string
|
||||
From string
|
||||
}
|
||||
type PostUploadResult struct {
|
||||
DockerUploadUUID string
|
||||
Location string
|
||||
ContentLength string
|
||||
}
|
||||
|
||||
func (oper *Operator) PostUpload(ctx context.Context, operatorID string, params *PostUploadParams) (*PostUploadResult, int, error) {
|
||||
var err error
|
||||
res := &PostUploadResult{}
|
||||
|
||||
if params.Digest == "" {
|
||||
uuid := auxuuid.NewUUID()
|
||||
location := fmt.Sprintf("/v2/%s/blobs/uploads/%s", params.Name, uuid)
|
||||
res.DockerUploadUUID = uuid
|
||||
res.Location = location
|
||||
res.ContentLength = strconv.FormatInt(0, 10)
|
||||
return res, http.StatusAccepted, err
|
||||
} else {
|
||||
err = fmt.Errorf("PostUpload: Not empty digest header")
|
||||
return res, http.StatusInternalServerError, err
|
||||
}
|
||||
return res, http.StatusOK, err
|
||||
}
|
||||
Reference in New Issue
Block a user