mirror of
https://github.com/rancher/cli.git
synced 2026-02-05 09:48:36 +01:00
Namespace
This commit is contained in:
committed by
Craig Jellick
parent
85e58f2df7
commit
baf6d6074e
@@ -372,7 +372,7 @@ func appRollback(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
rr := &projectClient.RollbackRevision{
|
||||
RevisionId: revision.Name,
|
||||
RevisionID: revision.Name,
|
||||
}
|
||||
|
||||
return c.ProjectClient.App.ActionRollback(app, rr)
|
||||
@@ -722,7 +722,7 @@ func outputRevisions(ctx *cli.Context, c *cliclient.MasterClient) error {
|
||||
defer writer.Close()
|
||||
|
||||
for _, rev := range sorted {
|
||||
if rev.Name == app.AppRevisionId {
|
||||
if rev.Name == app.AppRevisionID {
|
||||
rev.Current = "*"
|
||||
}
|
||||
rev.Human = rev.Created.Format("02 Jan 2006 15:04:05 MST")
|
||||
|
||||
@@ -274,7 +274,7 @@ func clusterCreate(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
if ctx.String("psp-default-policy") != "" {
|
||||
clusterConfig.DefaultPodSecurityPolicyTemplateId = ctx.String("psp-default-policy")
|
||||
clusterConfig.DefaultPodSecurityPolicyTemplateID = ctx.String("psp-default-policy")
|
||||
}
|
||||
|
||||
createdCluster, err := c.ManagementClient.Cluster.Create(clusterConfig)
|
||||
@@ -504,14 +504,14 @@ func addClusterMemberRoles(ctx *cli.Context) error {
|
||||
|
||||
for _, role := range roles {
|
||||
rtb := managementClient.ClusterRoleTemplateBinding{
|
||||
ClusterId: clusterID,
|
||||
RoleTemplateId: role,
|
||||
UserPrincipalId: member.ID,
|
||||
ClusterID: clusterID,
|
||||
RoleTemplateID: role,
|
||||
UserPrincipalID: member.ID,
|
||||
}
|
||||
if member.PrincipalType == "user" {
|
||||
rtb.UserPrincipalId = member.ID
|
||||
rtb.UserPrincipalID = member.ID
|
||||
} else {
|
||||
rtb.GroupPrincipalId = member.ID
|
||||
rtb.GroupPrincipalID = member.ID
|
||||
}
|
||||
_, err = c.ManagementClient.ClusterRoleTemplateBinding.Create(&rtb)
|
||||
if nil != err {
|
||||
@@ -611,8 +611,8 @@ func listClusterMembers(ctx *cli.Context) error {
|
||||
|
||||
b = append(b, RoleTemplateBinding{
|
||||
ID: binding.ID,
|
||||
User: userMap[binding.UserId],
|
||||
Role: binding.RoleTemplateId,
|
||||
User: userMap[binding.UserID],
|
||||
Role: binding.RoleTemplateID,
|
||||
Created: parsedTime,
|
||||
})
|
||||
}
|
||||
@@ -636,7 +636,7 @@ func getClusterRegToken(
|
||||
|
||||
if len(clusterTokenCollection.Data) == 0 {
|
||||
crt := &managementClient.ClusterRegistrationToken{
|
||||
ClusterId: clusterID,
|
||||
ClusterID: clusterID,
|
||||
}
|
||||
clusterToken, err := c.ManagementClient.ClusterRegistrationToken.Create(crt)
|
||||
if nil != err {
|
||||
|
||||
@@ -192,7 +192,7 @@ func getProjectContext(ctx *cli.Context, c *cliclient.MasterClient) (string, err
|
||||
writer.Write(&LoginData{
|
||||
Project: item,
|
||||
Index: i + 1,
|
||||
ClusterName: clusterNames[item.ClusterId],
|
||||
ClusterName: clusterNames[item.ClusterID],
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rancher/cli/cliclient"
|
||||
clusterClient "github.com/rancher/types/client/cluster/v3"
|
||||
"github.com/urfave/cli"
|
||||
@@ -62,12 +63,10 @@ func NamespaceCommand() cli.Command {
|
||||
Action: namespaceDelete,
|
||||
},
|
||||
{
|
||||
Name: "associate",
|
||||
Usage: "Associate a namespace with a project",
|
||||
Description: "\nAssociates a namespace with a project. If no " +
|
||||
"[PROJECTID] is provided the namespace will be unassociated from all projects",
|
||||
Name: "move",
|
||||
Usage: "Move a namespace to a different project",
|
||||
ArgsUsage: "[NAMESPACEID/NAMESPACENAME PROJECTID]",
|
||||
Action: namespaceAssociate,
|
||||
Action: namespaceMove,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -170,8 +169,8 @@ func namespaceDelete(ctx *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func namespaceAssociate(ctx *cli.Context) error {
|
||||
if ctx.NArg() == 0 {
|
||||
func namespaceMove(ctx *cli.Context) error {
|
||||
if ctx.NArg() < 2 {
|
||||
return cli.ShowSubcommandHelp(ctx)
|
||||
}
|
||||
|
||||
@@ -190,8 +189,29 @@ func namespaceAssociate(ctx *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
projResource, err := Lookup(c, ctx.Args().Get(1), "project")
|
||||
if nil != err {
|
||||
return err
|
||||
}
|
||||
|
||||
proj, err := getProjectByID(c, projResource.ID)
|
||||
if nil != err {
|
||||
return err
|
||||
}
|
||||
|
||||
if anno, ok := namespace.Annotations["cattle.io/appIds"]; ok && anno != "" {
|
||||
return errors.Errorf("Namespace %v cannot be moved", namespace.Name)
|
||||
}
|
||||
|
||||
if _, ok := namespace.Actions["move"]; ok {
|
||||
move := &clusterClient.NamespaceMove{
|
||||
ProjectID: proj.ID,
|
||||
}
|
||||
return c.ClusterClient.Namespace.ActionMove(namespace, move)
|
||||
}
|
||||
|
||||
update := make(map[string]string)
|
||||
update["projectId"] = ctx.Args().Get(1)
|
||||
update["projectId"] = proj.ID
|
||||
|
||||
_, err = c.ClusterClient.Namespace.Update(namespace, update)
|
||||
if nil != err {
|
||||
|
||||
@@ -184,7 +184,7 @@ func getNodePools(
|
||||
|
||||
func getNodePoolName(node managementClient.Node, pools *managementClient.NodePoolCollection) string {
|
||||
for _, pool := range pools.Data {
|
||||
if node.NodePoolId == pool.ID {
|
||||
if node.NodePoolID == pool.ID {
|
||||
return pool.HostnamePrefix
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ func projectCreate(ctx *cli.Context) error {
|
||||
|
||||
newProj := &managementClient.Project{
|
||||
Name: ctx.Args().First(),
|
||||
ClusterId: clusterID,
|
||||
ClusterID: clusterID,
|
||||
Description: ctx.String("description"),
|
||||
}
|
||||
|
||||
@@ -222,14 +222,14 @@ func addProjectMemberRoles(ctx *cli.Context) error {
|
||||
|
||||
for _, role := range roles {
|
||||
rtb := managementClient.ProjectRoleTemplateBinding{
|
||||
ProjectId: projectID,
|
||||
RoleTemplateId: role,
|
||||
UserPrincipalId: member.ID,
|
||||
ProjectID: projectID,
|
||||
RoleTemplateID: role,
|
||||
UserPrincipalID: member.ID,
|
||||
}
|
||||
if member.PrincipalType == "user" {
|
||||
rtb.UserPrincipalId = member.ID
|
||||
rtb.UserPrincipalID = member.ID
|
||||
} else {
|
||||
rtb.GroupPrincipalId = member.ID
|
||||
rtb.GroupPrincipalID = member.ID
|
||||
}
|
||||
_, err = c.ManagementClient.ProjectRoleTemplateBinding.Create(&rtb)
|
||||
if nil != err {
|
||||
@@ -329,8 +329,8 @@ func listProjectMembers(ctx *cli.Context) error {
|
||||
|
||||
b = append(b, RoleTemplateBinding{
|
||||
ID: binding.ID,
|
||||
User: userMap[binding.UserId],
|
||||
Role: binding.RoleTemplateId,
|
||||
User: userMap[binding.UserID],
|
||||
Role: binding.RoleTemplateID,
|
||||
Created: parsedTime,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user