@@ -2,7 +2,6 @@ use super::*;
2
2
use crate :: {
3
3
sdk:: { api_url, SDK } ,
4
4
utils:: {
5
- auth:: get_token,
6
5
choice:: Choice ,
7
6
config:: Config ,
8
7
prompt:: prompt_text,
@@ -41,41 +40,27 @@ pub async fn command(args: Args) -> Result<()> {
41
40
42
41
let config = Config :: get ( ) ?;
43
42
let key = config. get_key_or_default ( args. key ) ?;
43
+ let password = config. primary_key_password ( ) ?;
44
+ let key = key. unlock ( & password) ;
44
45
45
- let uuid = key
46
- . uuid
47
- . context ( "Key does not have a UUID, try `envx upload`" ) ?;
48
- let ( _, public_key) = SDK :: get_user ( & key. fingerprint , & user_id)
49
- . await
50
- . context ( "Failed to get user, is the user ID correct?" ) ?;
46
+ let project_id = Choice :: try_project ( args. project_id , & key) . await ?;
51
47
52
- let project_id =
53
- Choice :: try_project ( args. project_id , & key. fingerprint ) . await ?;
48
+ let project_info = SDK :: get_project_info ( & project_id, & key) . await ?;
54
49
55
- let project_info =
56
- SDK :: get_project_info ( & project_id, & key. fingerprint ) . await ?;
57
-
58
- let variables = SDK :: get_variables ( & project_id, & key. fingerprint ) . await ?;
50
+ let variables = SDK :: get_variables ( & project_id, & key) . await ?;
59
51
let kvpairs = variables. to_kvpair ( ) ;
60
52
61
- let mut recipients = project_info
53
+ let recipients = project_info
62
54
. users
63
55
. iter ( )
64
56
. map ( |e| e. public_key . clone ( ) )
65
- . collect :: < Vec < String > > ( ) ;
66
-
67
- recipients. push ( public_key) ;
68
-
69
- let recipients = recipients
70
- . into_iter ( )
71
- . collect :: < HashSet < String > > ( )
72
- . into_iter ( )
73
- . collect :: < Vec < String > > ( ) ;
57
+ . collect :: < HashSet < String > > ( ) ;
74
58
75
- let pubkeys = recipients
59
+ let mut pubkeys = recipients
76
60
. iter ( )
77
61
. map ( |k| Ok ( SignedPublicKey :: from_string ( k) ?. 0 ) )
78
62
. collect :: < Result < Vec < SignedPublicKey > > > ( ) ?;
63
+ pubkeys. push ( pgp:: SignedPublicKey :: try_from ( & key. key ) ?) ;
79
64
80
65
let messages = kvpairs
81
66
. par_iter ( )
@@ -98,7 +83,7 @@ pub async fn command(args: Args) -> Result<()> {
98
83
} ) ;
99
84
100
85
let client = reqwest:: Client :: new ( ) ;
101
- let auth_token = get_token ( & key. fingerprint , & uuid ) . await ? ;
86
+ let auth_token = key. auth_token ( ) ? . bearer ( ) ;
102
87
103
88
let url = api_url ( ) . join ( "/variables/update-many" ) ?;
104
89
@@ -114,7 +99,7 @@ pub async fn command(args: Args) -> Result<()> {
114
99
println ! ( "Updated {} variables" , res. len( ) ) ;
115
100
println ! ( "IDs: {:?}" , res) ;
116
101
117
- SDK :: add_user_to_project ( & key. fingerprint , & user_id, & project_id) . await ?;
102
+ SDK :: add_user_to_project ( & key, & user_id, & project_id) . await ?;
118
103
119
104
Ok ( ( ) )
120
105
}
0 commit comments