@@ -39,11 +39,27 @@ func (c Commands) NewDurablePipelineCmds(
3939 Short : "Durable Pipeline commands" ,
4040 }
4141
42+ addressBookCmd := & cobra.Command {
43+ Use : "address-book" ,
44+ Short : "Address book operations" ,
45+ }
46+ addressBookCmd .AddCommand (c .newDurablePipelineAddressBookMerge (domain ))
47+ addressBookCmd .AddCommand (c .newDurablePipelineAddressBookMigrate (domain ))
48+
49+ datastoreCmd := & cobra.Command {
50+ Use : "datastore" ,
51+ Short : "Datastore operations" ,
52+ }
53+ datastoreCmd .AddCommand (c .newDurablePipelineDataStoreMerge (domain ))
54+
4255 evmCmd .AddCommand (
4356 c .newDurablePipelineRun (domain , loadMigration , decodeProposalCtxProvider , loadConfigResolvers ),
4457 c .newDurablePipelineInputGenerate (domain , loadMigration , loadConfigResolvers ),
4558 c .newDurablePipelineListBuild (domain , loadMigration , loadConfigResolvers ),
46- c .newDurablePipelineTemplateInput (domain , loadMigration , loadConfigResolvers ))
59+ c .newDurablePipelineTemplateInput (domain , loadMigration , loadConfigResolvers ),
60+ addressBookCmd ,
61+ datastoreCmd ,
62+ )
4763
4864 evmCmd .PersistentFlags ().StringP ("environment" , "e" , "" , "Deployment environment (required)" )
4965 _ = evmCmd .MarkPersistentFlagRequired ("environment" )
@@ -677,3 +693,153 @@ func (c Commands) newDurablePipelineTemplateInput(
677693
678694 return & cmd
679695}
696+
697+ var (
698+ durablePipelineMergeAddressBookLong = `
699+ Merges the address book artifact of a specific durable pipeline changeset to the main address book within a
700+ given Domain Environment. This is to ensure that the address book is up-to-date with the
701+ latest changeset changes.
702+ `
703+
704+ durablePipelineMergeAddressBookExample = `
705+ # Merge the address book for the 0001_deploy_cap changeset in the staging environment
706+ ccip durable-pipeline address-book merge --environment staging --name 0001_deploy_cap
707+
708+ # Merge with a specific timestamp
709+ ccip durable-pipeline address-book merge --environment staging --name 0001_deploy_cap --timestamp 1234567890
710+ `
711+ )
712+
713+ // newDurablePipelineAddressBookMerge creates a command to merge the address books for a durable pipeline changeset to
714+ // the main address book within a given domain environment.
715+ func (Commands ) newDurablePipelineAddressBookMerge (domain dom.Domain ) * cobra.Command {
716+ var (
717+ changesetName string
718+ timestamp string
719+ )
720+
721+ cmd := cobra.Command {
722+ Use : "merge" ,
723+ Short : "Merge the address book for a changeset to the main address book" ,
724+ Long : durablePipelineMergeAddressBookLong ,
725+ Example : durablePipelineMergeAddressBookExample ,
726+ RunE : func (cmd * cobra.Command , args []string ) error {
727+ envKey , _ := cmd .Flags ().GetString ("environment" )
728+ envDir := domain .EnvDir (envKey )
729+
730+ if err := envDir .MergeMigrationAddressBook (changesetName , timestamp ); err != nil {
731+ return fmt .Errorf ("error during address book merge for %s %s %s: %w" ,
732+ domain , envKey , changesetName , err ,
733+ )
734+ }
735+
736+ cmd .Printf ("Merged address books for %s %s %s" ,
737+ domain , envKey , changesetName ,
738+ )
739+
740+ return nil
741+ },
742+ }
743+
744+ cmd .Flags ().StringVarP (& changesetName , "name" , "n" , "" , "name (required)" )
745+ cmd .Flags ().StringVarP (& timestamp , "timestamp" , "t" , "" , "Durable Pipeline timestamp (optional)" )
746+
747+ err := cmd .MarkFlagRequired ("name" )
748+ if err != nil {
749+ return nil
750+ }
751+
752+ return & cmd
753+ }
754+
755+ var (
756+ durablePipelineMigrateAddressBookLong = `
757+ Converts the address book artifact format to the new datastore schema within a
758+ given Domain Environment. This updates your on-chain address book to the latest storage format.
759+ `
760+
761+ durablePipelineMigrateAddressBookExample = `
762+ # Migrate the address book for the staging domain to the new datastore format
763+ ccip durable-pipeline address-book migrate --environment staging
764+ `
765+ )
766+
767+ // newDurablePipelineAddressBookMigrate creates a command to convert the address book
768+ // artifact to the new datastore format within a given domain environment.
769+ func (Commands ) newDurablePipelineAddressBookMigrate (domain dom.Domain ) * cobra.Command {
770+ cmd := cobra.Command {
771+ Use : "migrate" ,
772+ Short : "Migrate address book to the new datastore format" ,
773+ Long : durablePipelineMigrateAddressBookLong ,
774+ Example : durablePipelineMigrateAddressBookExample ,
775+ RunE : func (cmd * cobra.Command , args []string ) error {
776+ envKey , _ := cmd .Flags ().GetString ("environment" )
777+ envDir := domain .EnvDir (envKey )
778+
779+ if err := envDir .MigrateAddressBook (); err != nil {
780+ return fmt .Errorf ("error during address book conversion for %s %s: %w" ,
781+ domain , envKey , err ,
782+ )
783+ }
784+
785+ cmd .Printf ("Address book for %s %s successfully migrated to the new datastore format" ,
786+ domain , envKey ,
787+ )
788+
789+ return nil
790+ },
791+ }
792+
793+ return & cmd
794+ }
795+
796+ var (
797+ durablePipelineDataStoreMergeExample = `
798+ # Merge the data store for the 0001_deploy_cap changeset in the staging domain
799+ ccip durable-pipeline datastore merge --environment staging --name 0001_deploy_cap
800+
801+ # Merge with a specific timestamp
802+ ccip durable-pipeline datastore merge --environment staging --name 0001_deploy_cap --timestamp 1234567890
803+ `
804+ )
805+
806+ // newDurablePipelineDataStoreMerge creates a command to merge the data store for a durable pipeline changeset
807+ func (Commands ) newDurablePipelineDataStoreMerge (domain dom.Domain ) * cobra.Command {
808+ var (
809+ changesetName string
810+ timestamp string
811+ )
812+
813+ cmd := cobra.Command {
814+ Use : "merge" ,
815+ Short : "Merge data stores" ,
816+ Long : "Merge the data store for a changeset to the main data store" ,
817+ Example : durablePipelineDataStoreMergeExample ,
818+ RunE : func (cmd * cobra.Command , args []string ) error {
819+ envKey , _ := cmd .Flags ().GetString ("environment" )
820+ envDir := domain .EnvDir (envKey )
821+
822+ if err := envDir .MergeMigrationDataStore (changesetName , timestamp ); err != nil {
823+ return fmt .Errorf ("error during data store merge for %s %s %s: %w" ,
824+ domain , envKey , changesetName , err ,
825+ )
826+ }
827+
828+ cmd .Printf ("Merged data stores for %s %s %s" ,
829+ domain , envKey , changesetName ,
830+ )
831+
832+ return nil
833+ },
834+ }
835+
836+ cmd .Flags ().StringVarP (& changesetName , "name" , "n" , "" , "name (required)" )
837+ cmd .Flags ().StringVarP (& timestamp , "timestamp" , "t" , "" , "Durable Pipeline timestamp (optional)" )
838+
839+ err := cmd .MarkFlagRequired ("name" )
840+ if err != nil {
841+ return nil
842+ }
843+
844+ return & cmd
845+ }
0 commit comments