diff --git a/cmd/climc/shell/k8s/fed_clusterrole.go b/cmd/climc/shell/k8s/fed_clusterrole.go index b042e46529..8b43ba56b1 100644 --- a/cmd/climc/shell/k8s/fed_clusterrole.go +++ b/cmd/climc/shell/k8s/fed_clusterrole.go @@ -28,6 +28,7 @@ func init() { AttachCluster(new(options.FedResourceJointClusterAttachOptions)). DetachCluster(new(options.FedResourceJointClusterDetachOptions)). SyncCluster(new(options.FedResourceJointClusterDetachOptions)). + Sync(new(options.FedResourceIdOptions)). ShowEvent() cmd.ClassShow(new(options.FedApiResourecesOptions)) diff --git a/cmd/climc/shell/k8s/fed_clusterrolebinding.go b/cmd/climc/shell/k8s/fed_clusterrolebinding.go index 586dd390f0..3f32b50345 100644 --- a/cmd/climc/shell/k8s/fed_clusterrolebinding.go +++ b/cmd/climc/shell/k8s/fed_clusterrolebinding.go @@ -27,5 +27,7 @@ func init() { Delete(new(options.IdentOptions)). AttachCluster(new(options.FedResourceJointClusterAttachOptions)). DetachCluster(new(options.FedResourceJointClusterDetachOptions)). - SyncCluster(new(options.FedResourceJointClusterDetachOptions)) + SyncCluster(new(options.FedResourceJointClusterDetachOptions)). + Sync(new(options.FedResourceIdOptions)). + ShowEvent() } diff --git a/cmd/climc/shell/k8s/fed_helper.go b/cmd/climc/shell/k8s/fed_helper.go index 1c2feaba4d..1cb0c53850 100644 --- a/cmd/climc/shell/k8s/fed_helper.go +++ b/cmd/climc/shell/k8s/fed_helper.go @@ -64,3 +64,8 @@ func (c *fedResourceCmd) SyncCluster(args shell.IPerformOpt) *fedResourceCmd { c.K8sResourceCmd.Perform("sync-cluster", args) return c } + +func (c *fedResourceCmd) Sync(args shell.IPerformOpt) *fedResourceCmd { + c.K8sResourceCmd.Perform("sync", args) + return c +} diff --git a/cmd/climc/shell/k8s/fed_namespace.go b/cmd/climc/shell/k8s/fed_namespace.go index bc1dc4a253..acbad73e83 100644 --- a/cmd/climc/shell/k8s/fed_namespace.go +++ b/cmd/climc/shell/k8s/fed_namespace.go @@ -29,5 +29,6 @@ func init() { AttachCluster(new(options.FedResourceJointClusterAttachOptions)). DetachCluster(new(options.FedResourceJointClusterDetachOptions)). SyncCluster(new(options.FedResourceJointClusterDetachOptions)). + Sync(new(options.IdentOptions)). ShowEvent() } diff --git a/cmd/climc/shell/k8s/fed_role.go b/cmd/climc/shell/k8s/fed_role.go index 66cb828800..a2ecd1cee1 100644 --- a/cmd/climc/shell/k8s/fed_role.go +++ b/cmd/climc/shell/k8s/fed_role.go @@ -28,6 +28,7 @@ func init() { AttachCluster(new(options.FedResourceJointClusterAttachOptions)). DetachCluster(new(options.FedResourceJointClusterDetachOptions)). SyncCluster(new(options.FedResourceJointClusterDetachOptions)). + Sync(new(options.IdentOptions)). ShowEvent() cmd.ClassShow(new(options.FedApiResourecesOptions)) diff --git a/cmd/climc/shell/k8s/fed_rolebinding.go b/cmd/climc/shell/k8s/fed_rolebinding.go index ad02c9df78..0bedcf6df0 100644 --- a/cmd/climc/shell/k8s/fed_rolebinding.go +++ b/cmd/climc/shell/k8s/fed_rolebinding.go @@ -29,5 +29,6 @@ func init() { AttachCluster(new(options.FedResourceJointClusterAttachOptions)). DetachCluster(new(options.FedResourceJointClusterDetachOptions)). SyncCluster(new(options.FedResourceJointClusterDetachOptions)). + Sync(new(options.IdentOptions)). ShowEvent() } diff --git a/cmd/climc/shell/k8s/rbac.go b/cmd/climc/shell/k8s/rbac.go index fd7fb664fe..dd20a4ac75 100644 --- a/cmd/climc/shell/k8s/rbac.go +++ b/cmd/climc/shell/k8s/rbac.go @@ -15,17 +15,12 @@ package k8s import ( - //"yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules/k8s" - //o "yunion.io/x/onecloud/pkg/mcclient/options/k8s" ) func initRbac() { - //cmdRole := initK8sNamespaceResource("rbacrole", k8s.RbacRoles) - initK8sNamespaceResource("rbac-role", k8s.RbacRoles) initK8sNamespaceResource("rbac-rolebinding", k8s.RbacRoleBindings) initK8sClusterResource("rbac-clusterrole", k8s.RbacClusterRoles) initK8sClusterResource("rbac-clusterrolebinding", k8s.RbacClusterRoleBindings) initK8sNamespaceResource("serviceaccount", k8s.ServiceAccounts) - //cmdRoleN := cmdRole.CommandNameFactory } diff --git a/cmd/climc/shell/k8s/role.go b/cmd/climc/shell/k8s/role.go index b7869f900b..587014ad68 100644 --- a/cmd/climc/shell/k8s/role.go +++ b/cmd/climc/shell/k8s/role.go @@ -22,6 +22,7 @@ import ( func init() { cmd := NewK8sResourceCmd(k8s.RbacRoles).SetKeyword("role") cmd.Create(new(options.RoleCreateOpt)) + cmd.Update(new(options.RoleUpdateOpt)) cmd.List(new(options.NamespaceResourceListOptions)) cmd.Show(new(options.NamespaceResourceGetOptions)) cmd.BatchDelete(new(options.ResourceIdsOptions)) diff --git a/pkg/mcclient/options/k8s/cluster_resource.go b/pkg/mcclient/options/k8s/cluster_resource.go index b285b96e0d..7083e623ca 100644 --- a/pkg/mcclient/options/k8s/cluster_resource.go +++ b/pkg/mcclient/options/k8s/cluster_resource.go @@ -44,3 +44,15 @@ func (o NamespaceResourceCreateOptions) Params() (jsonutils.JSONObject, error) { params.Add(jsonutils.NewString(o.NAMESPACE), "namespace_id") return params, nil } + +type ClusterResourceUpdateOptions struct { + ID string `help:"Id of resource"` +} + +func (o ClusterResourceUpdateOptions) GetId() string { + return o.ID +} + +type NamespaceResourceUpdateOptions struct { + ClusterResourceUpdateOptions +} diff --git a/pkg/mcclient/options/k8s/fed_joint_resource.go b/pkg/mcclient/options/k8s/fed_joint_resource.go index 313cc8530b..50b8c4c11f 100644 --- a/pkg/mcclient/options/k8s/fed_joint_resource.go +++ b/pkg/mcclient/options/k8s/fed_joint_resource.go @@ -66,6 +66,14 @@ type FedResourceIdOptions struct { FEDRESOURCE string `help:"ID or Name of federated resource"` } +func (o FedResourceIdOptions) GetId() string { + return o.FEDRESOURCE +} + +func (o FedResourceIdOptions) Params() (jsonutils.JSONObject, error) { + return nil, nil +} + type FedResourceJointClusterAttachOptions struct { FedResourceIdOptions FedResourceClusterJointOptions @@ -75,6 +83,10 @@ func (o *FedResourceJointClusterAttachOptions) GetId() string { return o.FEDRESOURCE } +func (o *FedResourceJointClusterAttachOptions) Params() (jsonutils.JSONObject, error) { + return o.FedResourceClusterJointOptions.Params() +} + type FedResourceJointClusterDetachOptions struct { FedResourceIdOptions FedResourceClusterJointOptions @@ -83,3 +95,7 @@ type FedResourceJointClusterDetachOptions struct { func (o *FedResourceJointClusterDetachOptions) GetId() string { return o.FEDRESOURCE } + +func (o *FedResourceJointClusterDetachOptions) Params() (jsonutils.JSONObject, error) { + return o.FedResourceClusterJointOptions.Params() +} diff --git a/pkg/mcclient/options/k8s/role.go b/pkg/mcclient/options/k8s/role.go index 69731756c3..fb8835af55 100644 --- a/pkg/mcclient/options/k8s/role.go +++ b/pkg/mcclient/options/k8s/role.go @@ -37,3 +37,19 @@ func (o *RoleCreateOpt) Params() (jsonutils.JSONObject, error) { params.Add(jsonutils.Marshal(rules), "rules") return params, nil } + +type RoleUpdateOpt struct { + NamespaceResourceUpdateOptions + + Rule []string `help:"role rule, e.g: 'apps/v1:deployments:get,watch,list'"` +} + +func (o *RoleUpdateOpt) Params() (jsonutils.JSONObject, error) { + params := jsonutils.NewDict() + rules, err := parsePolicyRules(o.Rule) + if err != nil { + return nil, err + } + params.Add(jsonutils.Marshal(rules), "rules") + return params, nil +}