@@ -3,6 +3,7 @@ package cli
33import (
44 "context"
55
6+ "github.com/google/uuid"
67 "github.com/spf13/cobra"
78 "golang.org/x/xerrors"
89
@@ -20,42 +21,45 @@ func parameters() *cobra.Command {
2021 return cmd
2122}
2223
23- func parseScopeAndID (ctx context.Context , client * codersdk.Client , organization codersdk.Organization , rawScope string , name string ) (codersdk.ParameterScope , string , error ) {
24+ func parseScopeAndID (ctx context.Context , client * codersdk.Client , organization codersdk.Organization , rawScope string , name string ) (codersdk.ParameterScope , uuid. UUID , error ) {
2425 scope , err := parseParameterScope (rawScope )
2526 if err != nil {
26- return scope , "" , err
27+ return scope , uuid . Nil , err
2728 }
28- var scopeID string
29+
30+ var scopeID uuid.UUID
2931 switch scope {
3032 case codersdk .ParameterOrganization :
3133 if name == "" {
3234 scopeID = organization .ID
3335 } else {
34- org , err := client .OrganizationByName (ctx , "" , name )
36+ org , err := client .OrganizationByName (ctx , codersdk . Me , name )
3537 if err != nil {
36- return scope , "" , err
38+ return scope , uuid . Nil , err
3739 }
3840 scopeID = org .ID
3941 }
4042 case codersdk .ParameterProject :
4143 project , err := client .ProjectByName (ctx , organization .ID , name )
4244 if err != nil {
43- return scope , "" , err
45+ return scope , uuid . Nil , err
4446 }
45- scopeID = project .ID . String ()
47+ scopeID = project .ID
4648 case codersdk .ParameterUser :
47- user , err := client .User (ctx , name )
49+ uid , _ := uuid .Parse (name )
50+ user , err := client .User (ctx , uid )
4851 if err != nil {
49- return scope , "" , err
52+ return scope , uuid . Nil , err
5053 }
5154 scopeID = user .ID
5255 case codersdk .ParameterWorkspace :
53- workspace , err := client .WorkspaceByName (ctx , "" , name )
56+ workspace , err := client .WorkspaceByName (ctx , codersdk . Me , name )
5457 if err != nil {
55- return scope , "" , err
58+ return scope , uuid . Nil , err
5659 }
57- scopeID = workspace .ID . String ()
60+ scopeID = workspace .ID
5861 }
62+
5963 return scope , scopeID , nil
6064}
6165
0 commit comments