@@ -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,147 @@ 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" ,
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+ _ = cmd .MarkFlagRequired ("name" )
748+
749+ return & cmd
750+ }
751+
752+ var (
753+ durablePipelineMigrateAddressBookLong = `
754+ Converts the address book artifact format to the new datastore schema within a
755+ given Domain Environment. This updates your on-chain address book to the latest storage format.
756+ `
757+
758+ durablePipelineMigrateAddressBookExample = `
759+ # Migrate the address book for the staging domain to the new datastore format
760+ ccip durable-pipeline address-book migrate --environment staging
761+ `
762+ )
763+
764+ // newDurablePipelineAddressBookMigrate creates a command to convert the address book
765+ // artifact to the new datastore format within a given domain environment.
766+ func (Commands ) newDurablePipelineAddressBookMigrate (domain dom.Domain ) * cobra.Command {
767+ cmd := cobra.Command {
768+ Use : "migrate" ,
769+ Short : "Migrate address book to the new datastore format" ,
770+ Long : durablePipelineMigrateAddressBookLong ,
771+ Example : durablePipelineMigrateAddressBookExample ,
772+ RunE : func (cmd * cobra.Command , args []string ) error {
773+ envKey , _ := cmd .Flags ().GetString ("environment" )
774+ envDir := domain .EnvDir (envKey )
775+
776+ if err := envDir .MigrateAddressBook (); err != nil {
777+ return fmt .Errorf ("error during address book conversion for %s %s: %w" ,
778+ domain , envKey , err ,
779+ )
780+ }
781+
782+ cmd .Printf ("Address book for %s %s successfully migrated to the new datastore format" ,
783+ domain , envKey ,
784+ )
785+
786+ return nil
787+ },
788+ }
789+
790+ return & cmd
791+ }
792+
793+ var (
794+ durablePipelineDataStoreMergeExample = `
795+ # Merge the data store for the 0001_deploy_cap changeset in the staging domain
796+ ccip durable-pipeline datastore merge --environment staging --name 0001_deploy_cap
797+
798+ # Merge with a specific timestamp
799+ ccip durable-pipeline datastore merge --environment staging --name 0001_deploy_cap --timestamp 1234567890
800+ `
801+ )
802+
803+ // newDurablePipelineDataStoreMerge creates a command to merge the data store for a durable pipeline changeset
804+ func (Commands ) newDurablePipelineDataStoreMerge (domain dom.Domain ) * cobra.Command {
805+ var (
806+ changesetName string
807+ timestamp string
808+ )
809+
810+ cmd := cobra.Command {
811+ Use : "merge" ,
812+ Short : "Merge data stores" ,
813+ Long : "Merge the data store for a changeset to the main data store" ,
814+ Example : durablePipelineDataStoreMergeExample ,
815+ RunE : func (cmd * cobra.Command , args []string ) error {
816+ envKey , _ := cmd .Flags ().GetString ("environment" )
817+ envDir := domain .EnvDir (envKey )
818+
819+ if err := envDir .MergeMigrationDataStore (changesetName , timestamp ); err != nil {
820+ return fmt .Errorf ("error during data store merge for %s %s %s: %w" ,
821+ domain , envKey , changesetName , err ,
822+ )
823+ }
824+
825+ cmd .Printf ("Merged data stores for %s %s %s" ,
826+ domain , envKey , changesetName ,
827+ )
828+
829+ return nil
830+ },
831+ }
832+
833+ cmd .Flags ().StringVarP (& changesetName , "name" , "n" , "" , "name (required)" )
834+ cmd .Flags ().StringVarP (& timestamp , "timestamp" , "t" , "" , "Durable Pipeline timestamp (optional)" )
835+
836+ _ = cmd .MarkFlagRequired ("name" )
837+
838+ return & cmd
839+ }
0 commit comments