splitted app/imageoper/manififest.go
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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"
|
||||
)
|
||||
|
||||
type GetRefererParams struct {
|
||||
Name string
|
||||
Digest string
|
||||
}
|
||||
type GetRefererResult struct {
|
||||
Reference string
|
||||
}
|
||||
|
||||
func (oper *Operator) GetReferer(ctx context.Context, params *GetRefererParams) (*GetRefererResult, int, error) {
|
||||
var err error
|
||||
res := &GetRefererResult{}
|
||||
|
||||
if params.Name == "" {
|
||||
err = fmt.Errorf("Empty name")
|
||||
return res, http.StatusBadRequest, err
|
||||
}
|
||||
if params.Digest == "" {
|
||||
err = fmt.Errorf("Empty digest")
|
||||
return res, http.StatusBadRequest, err
|
||||
}
|
||||
manifests, err := oper.mdb.GetReferer(ctx, params.Name, params.Digest)
|
||||
if err != nil {
|
||||
return res, http.StatusInternalServerError, err
|
||||
}
|
||||
if len(manifests) == 0 {
|
||||
return res, http.StatusNotFound, err
|
||||
}
|
||||
res.Reference = manifests[0].Reference
|
||||
return res, http.StatusOK, err
|
||||
}
|
||||
Reference in New Issue
Block a user