working commit
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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/client"
|
||||
)
|
||||
|
||||
// CatalogImages
|
||||
type CatalogImagesParams struct {
|
||||
Source string
|
||||
}
|
||||
|
||||
type CatalogImagesResult struct {
|
||||
Repositories []string `json:"repositories"`
|
||||
}
|
||||
|
||||
func (util *ImageUtil) CatalogImages(cmd *cobra.Command, args []string) {
|
||||
util.catalogImagesParams.Source = args[0]
|
||||
res, err := util.catalogImages(&util.commonImageParams, &util.catalogImagesParams)
|
||||
printResponse(res, err)
|
||||
}
|
||||
|
||||
func (util *ImageUtil) catalogImages(common *CommonImageParams, params *CatalogImagesParams) (*CatalogImagesResult, error) {
|
||||
var err error
|
||||
res := &CatalogImagesResult{
|
||||
Repositories: make([]string, 0),
|
||||
}
|
||||
ctx := context.Background()
|
||||
|
||||
cli := client.NewClient(common.SkipTLSVerify)
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
|
||||
params.Source, err = packUserinfo(params.Source, common.Username, common.Password)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
ctx, _ = context.WithTimeout(ctx, timeout)
|
||||
opres, err := cli.CatalogImages(ctx, params.Source)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
res.Repositories = opres
|
||||
return res, err
|
||||
}
|
||||
Reference in New Issue
Block a user