From f1e6622d94896338f7f069dcc4a4d60aee07cf1d Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Fri, 13 Sep 2024 14:34:38 +0800 Subject: [PATCH] feat(climc): add public/private command for k8s-container-registry (#21228) --- cmd/climc/shell/k8s/container_registry.go | 2 ++ pkg/mcclient/options/k8s/container_registry.go | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/cmd/climc/shell/k8s/container_registry.go b/cmd/climc/shell/k8s/container_registry.go index d8cc0af641..f59a8e8f0c 100644 --- a/cmd/climc/shell/k8s/container_registry.go +++ b/cmd/climc/shell/k8s/container_registry.go @@ -37,6 +37,8 @@ func initContainerRegistry() { cmd.Create(new(o.RegistryCreateOptions)) cmd.Get("images", new(o.RegistryGetImagesOptions)) cmd.Get("image-tags", new(o.RegistryGetImageTagsOptions)) + cmd.BatchPerform("public", new(o.RegistryPublicOptions)) + cmd.Perform("private", new(o.RegistryGetOptions)) type UploadOptions struct { REGISTRY string `help:"The name or id of registry" json:"-"` diff --git a/pkg/mcclient/options/k8s/container_registry.go b/pkg/mcclient/options/k8s/container_registry.go index e44f0b981e..0c4bd12340 100644 --- a/pkg/mcclient/options/k8s/container_registry.go +++ b/pkg/mcclient/options/k8s/container_registry.go @@ -91,3 +91,18 @@ func (o RegistryGetImageTagsOptions) Params() (jsonutils.JSONObject, error) { "repository": o.REPOSITORY, }), nil } + +type RegistryPublicOptions struct { + ID []string `help:"ID or name of image" json:"-"` + Scope string `help:"sharing scope" choices:"system|domain|project" json:"scope"` + SharedProjects []string `help:"Share to projects" json:"shared_projects"` + SharedDomains []string `help:"Share to domains" json:"shared_domains"` +} + +func (o RegistryPublicOptions) Params() (jsonutils.JSONObject, error) { + return jsonutils.Marshal(o), nil +} + +func (o RegistryPublicOptions) GetIds() []string { + return o.ID +}