@@ -15,9 +15,12 @@ import {
15
15
createR2Bucket ,
16
16
deleteR2Bucket ,
17
17
deleteR2Object ,
18
+ deleteR2Sippy ,
18
19
getR2Object ,
20
+ getR2Sippy ,
19
21
listR2Buckets ,
20
22
putR2Object ,
23
+ putR2Sippy ,
21
24
usingLocalBucket ,
22
25
} from "./helpers" ;
23
26
@@ -503,6 +506,139 @@ export function r2(r2Yargs: CommonYargsArgv) {
503
506
} ) ;
504
507
}
505
508
) ;
509
+
510
+ r2BucketYargs . command (
511
+ "sippy" ,
512
+ "Manage Sippy incremental migration on an R2 bucket" ,
513
+ ( sippyYargs ) => {
514
+ return sippyYargs
515
+ . command (
516
+ "enable <name>" ,
517
+ "Enable Sippy on an R2 bucket" ,
518
+ ( yargs ) =>
519
+ yargs
520
+ . positional ( "name" , {
521
+ describe : "The name of the bucket" ,
522
+ type : "string" ,
523
+ demandOption : true ,
524
+ } )
525
+ . option ( "jurisdiction" , {
526
+ describe : "The jurisdiction where the bucket exists" ,
527
+ alias : "J" ,
528
+ requiresArg : true ,
529
+ type : "string" ,
530
+ } )
531
+ . option ( "provider" , {
532
+ choices : [ "AWS" ] ,
533
+ default : "AWS" ,
534
+ implies : [
535
+ "bucket" ,
536
+ "key-id" ,
537
+ "secret-access-key" ,
538
+ "r2-key-id" ,
539
+ "r2-secret-access-key" ,
540
+ ] ,
541
+ } )
542
+ . option ( "bucket" , {
543
+ description : "The name of the upstream bucket" ,
544
+ string : true ,
545
+ } )
546
+ . option ( "region" , {
547
+ description : "The region of the upstream bucket" ,
548
+ string : true ,
549
+ } )
550
+ . option ( "key-id" , {
551
+ description :
552
+ "The secret access key id for the upstream bucket" ,
553
+ string : true ,
554
+ } )
555
+ . option ( "secret-access-key" , {
556
+ description :
557
+ "The secret access key for the upstream bucket" ,
558
+ string : true ,
559
+ } )
560
+ . option ( "r2-key-id" , {
561
+ description : "The secret access key id for this R2 bucket" ,
562
+ string : true ,
563
+ } )
564
+ . option ( "r2-secret-access-key" , {
565
+ description : "The secret access key for this R2 bucket" ,
566
+ string : true ,
567
+ } ) ,
568
+
569
+ async ( args ) => {
570
+ const config = readConfig ( args . config , args ) ;
571
+ const accountId = await requireAuth ( config ) ;
572
+
573
+ await putR2Sippy (
574
+ accountId ,
575
+ args . name ,
576
+ {
577
+ provider : "AWS" ,
578
+ zone : args [ "region" ] ,
579
+ bucket : args . bucket ?? "" ,
580
+ key_id : args [ "key-id" ] ?? "" ,
581
+ access_key : args [ "secret-access-key" ] ?? "" ,
582
+ r2_key_id : args [ "r2-key-id" ] ?? "" ,
583
+ r2_access_key : args [ "r2-secret-access-key" ] ?? "" ,
584
+ } ,
585
+ args . jurisdiction
586
+ ) ;
587
+ }
588
+ )
589
+ . command (
590
+ "disable <name>" ,
591
+ "Disable Sippy on an R2 bucket" ,
592
+ ( yargs ) =>
593
+ yargs
594
+ . positional ( "name" , {
595
+ describe : "The name of the bucket" ,
596
+ type : "string" ,
597
+ demandOption : true ,
598
+ } )
599
+ . option ( "jurisdiction" , {
600
+ describe : "The jurisdiction where the bucket exists" ,
601
+ alias : "J" ,
602
+ requiresArg : true ,
603
+ type : "string" ,
604
+ } ) ,
605
+ async ( args ) => {
606
+ const config = readConfig ( args . config , args ) ;
607
+ const accountId = await requireAuth ( config ) ;
608
+
609
+ await deleteR2Sippy ( accountId , args . name , args . jurisdiction ) ;
610
+ }
611
+ )
612
+ . command (
613
+ "get <name>" ,
614
+ "Check the status of Sippy on an R2 bucket" ,
615
+ ( yargs ) =>
616
+ yargs
617
+ . positional ( "name" , {
618
+ describe : "The name of the bucket" ,
619
+ type : "string" ,
620
+ demandOption : true ,
621
+ } )
622
+ . option ( "jurisdiction" , {
623
+ describe : "The jurisdiction where the bucket exists" ,
624
+ alias : "J" ,
625
+ requiresArg : true ,
626
+ type : "string" ,
627
+ } ) ,
628
+ async ( args ) => {
629
+ const config = readConfig ( args . config , args ) ;
630
+ const accountId = await requireAuth ( config ) ;
631
+
632
+ const sippyBucket = await getR2Sippy (
633
+ accountId ,
634
+ args . name ,
635
+ args . jurisdiction
636
+ ) ;
637
+ logger . log ( `Sippy upstream bucket: ${ sippyBucket } .` ) ;
638
+ }
639
+ ) ;
640
+ }
641
+ ) ;
506
642
return r2BucketYargs ;
507
643
} ) ;
508
644
}
0 commit comments