reorder some source files
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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 imagecmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"mstore/pkg/gcrcli"
|
||||
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
// ImageConfig
|
||||
type ImageConfigParams struct {
|
||||
Imagepath string
|
||||
}
|
||||
|
||||
type ImageConfigResult struct {
|
||||
ImageConfig *ocispec.Image `json:"imageConfig"`
|
||||
}
|
||||
|
||||
func (util *ImageUtil) ImageConfig(cmd *cobra.Command, args []string) {
|
||||
util.imageConfigParams.Imagepath = args[0]
|
||||
res, err := util.imageConfig(&util.commonImageParams, &util.imageConfigParams)
|
||||
printResponse(res, err)
|
||||
}
|
||||
|
||||
func (util *ImageUtil) imageConfig(common *CommonImageParams, params *ImageConfigParams) (*ImageConfigResult, error) {
|
||||
var err error
|
||||
res := &ImageConfigResult{
|
||||
ImageConfig: &ocispec.Image{},
|
||||
}
|
||||
ctx := context.Background()
|
||||
|
||||
cli := gcrcli.NewClient(common.SkipTLSVerify)
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
|
||||
params.Imagepath, err = packUserinfo(params.Imagepath, common.Username, common.Password)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
ctx, _ = context.WithTimeout(ctx, timeout)
|
||||
opres, err := cli.ImageConfig(ctx, params.Imagepath)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
res.ImageConfig = opres
|
||||
return res, err
|
||||
}
|
||||
Reference in New Issue
Block a user