climc: make k8s repo sharable

This commit is contained in:
Zexi Li
2018-11-21 17:54:32 +08:00
parent b63d5bbb93
commit 4098440c8f
2 changed files with 23 additions and 1 deletions
+18
View File
@@ -67,4 +67,22 @@ func initRepo() {
printObject(repo)
return nil
})
R(&o.RepoGetOptions{}, cmdN("public"), "Make repository public", func(s *mcclient.ClientSession, args *o.RepoGetOptions) error {
repo, err := k8s.Repos.PerformAction(s, args.NAME, "public", nil)
if err != nil {
return err
}
printObject(repo)
return nil
})
R(&o.RepoGetOptions{}, cmdN("private"), "Make repository private", func(s *mcclient.ClientSession, args *o.RepoGetOptions) error {
repo, err := k8s.Repos.PerformAction(s, args.NAME, "private", nil)
if err != nil {
return err
}
printObject(repo)
return nil
})
}
+5 -1
View File
@@ -16,13 +16,17 @@ type RepoGetOptions struct {
type RepoCreateOptions struct {
RepoGetOptions
URL string `help:"Repository url"`
URL string `help:"Repository url"`
Public bool `help:"Make repostitory public"`
}
func (o RepoCreateOptions) Params() *jsonutils.JSONDict {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(o.NAME), "name")
params.Add(jsonutils.NewString(o.URL), "url")
if o.Public {
params.Add(jsonutils.JSONTrue, "is_public")
}
return params
}