@@ -64,25 +64,34 @@ pub async fn run(args: Args) {
6464 team_user_id,
6565 user_id,
6666 } => {
67- client
67+ let res = client
6868 . add_team_member ( & team_user_id, user_id)
6969 . await
7070 . unwrap ( ) ;
71- println ! ( "added " ) ;
71+ println ! ( "{res} " ) ;
7272 }
7373 Command :: RenewCerts => {
7474 let certs = client. get_old_certificates ( ) . await . unwrap ( ) ;
7575 eprintln ! ( "Starting renewals of {} certs in 5 seconds..." , certs. len( ) ) ;
7676 tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 5000 ) ) . await ;
77+ let mut any_error = false ;
7778 for ( cert_id, subject, acm) in certs {
7879 println ! (
79- "--> {cert_id} {subject} {}" ,
80+ "{cert_id} {subject} {}" ,
8081 if acm. is_some( ) { "(ACM)" } else { "" }
8182 ) ;
82- println ! ( "{:?}" , client. renew_certificate( & cert_id) . await ) ;
83+ println ! (
84+ " {:?}" ,
85+ client. renew_certificate( & cert_id) . await . inspect_err( |_| {
86+ any_error = true ;
87+ } )
88+ ) ;
8389 // prevent api rate limiting
8490 tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 1000 ) ) . await ;
8591 }
92+ if any_error {
93+ panic ! ( "Error in loop occured" ) ;
94+ }
8695 }
8796 Command :: UpdateProjectConfig { project_id, json } => {
8897 let res = client
@@ -120,21 +129,22 @@ pub async fn run(args: Args) {
120129 client. feature_flag ( & entity, & flag, false ) . await . unwrap ( ) ;
121130 println ! ( "Removed flag {flag} for {entity}" ) ;
122131 }
123- Command :: Gc {
132+ Command :: GcCommunity {
124133 days,
125134 stop_deployments,
135+ send_emails,
126136 limit,
127137 } => {
128138 let project_ids = client. gc_free_tier ( days) . await . unwrap ( ) ;
129- gc ( client, project_ids, stop_deployments, limit) . await ;
139+ gc ( client, project_ids, stop_deployments, send_emails , limit) . await ;
130140 }
131141 Command :: GcShuttlings {
132142 minutes,
133143 stop_deployments,
134144 limit,
135145 } => {
136146 let project_ids = client. gc_shuttlings ( minutes) . await . unwrap ( ) ;
137- gc ( client, project_ids, stop_deployments, limit) . await ;
147+ gc ( client, project_ids, stop_deployments, false , limit) . await ;
138148 }
139149 Command :: DeleteUser { user_id } => {
140150 eprintln ! ( "Deleting user {} in 3 seconds..." , user_id) ;
@@ -157,27 +167,51 @@ pub async fn run(args: Args) {
157167 users. len( )
158168 ) ;
159169 tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 5000 ) ) . await ;
170+ let mut any_error = false ;
160171 for user_id in users {
161172 println ! ( "{user_id}" ) ;
162- println ! ( " {:?}" , client. downgrade_protrial( & user_id) . await ) ;
173+ println ! (
174+ " {:?}" ,
175+ client. downgrade_protrial( & user_id) . await . inspect_err( |_| {
176+ any_error = true ;
177+ } )
178+ ) ;
163179 // prevent api rate limiting
164180 tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 1000 ) ) . await ;
165181 }
182+ if any_error {
183+ panic ! ( "Error in loop occured" ) ;
184+ }
166185 }
167186 Command :: FixRetentionPolicies => {
168187 let projects = client. get_projects_for_retention_policy ( ) . await . unwrap ( ) ;
169188 eprintln ! ( "Starting fix of {} log retention policies" , projects. len( ) ) ;
189+ let mut any_error = false ;
170190 for pid in projects {
171191 println ! ( "{pid}" ) ;
172- println ! ( " {:?}" , client. fix_retention_policy( & pid) . await ) ;
192+ println ! (
193+ " {:?}" ,
194+ client. fix_retention_policy( & pid) . await . inspect_err( |_| {
195+ any_error = true ;
196+ } )
197+ ) ;
173198 // prevent api rate limiting
174199 tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 1000 ) ) . await ;
175200 }
201+ if any_error {
202+ panic ! ( "Error in loop occured" ) ;
203+ }
176204 }
177205 } ;
178206}
179207
180- async fn gc ( client : Client , mut project_ids : Vec < String > , stop_deployments : bool , limit : u32 ) {
208+ async fn gc (
209+ client : Client ,
210+ mut project_ids : Vec < String > ,
211+ stop_deployments : bool ,
212+ send_email : bool ,
213+ limit : u32 ,
214+ ) {
181215 if !stop_deployments {
182216 for pid in & project_ids {
183217 println ! ( "{pid}" ) ;
@@ -192,9 +226,24 @@ async fn gc(client: Client, mut project_ids: Vec<String>, stop_deployments: bool
192226 project_ids. len( )
193227 ) ;
194228 tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 5000 ) ) . await ;
229+ let mut any_error = false ;
195230 for pid in project_ids {
196- println ! ( "{}" , client. inner. stop_service( & pid) . await . unwrap( ) ) ;
231+ println ! ( "{pid}" ) ;
232+ let call = if send_email {
233+ client. stop_gc_inactive_project ( & pid) . await
234+ } else {
235+ client. inner . stop_service ( & pid) . await
236+ } ;
237+ println ! (
238+ " {:?}" ,
239+ call. inspect_err( |_| {
240+ any_error = true ;
241+ } )
242+ ) ;
197243 // prevent api rate limiting
198244 tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 1000 ) ) . await ;
199245 }
246+ if any_error {
247+ panic ! ( "Error in loop occured" ) ;
248+ }
200249}
0 commit comments