@@ -347,7 +347,7 @@ func listComponents() error {
347347 cli .StartProgress ("Loading component Catalog..." )
348348
349349 catalog , err := lwcomponent .NewCatalog (cli .LwApi , lwcomponent .NewStageTarGz )
350- defer catalog .Cache ()
350+ defer catalog .Persist ()
351351
352352 cli .StopProgress ()
353353 if err != nil {
@@ -414,7 +414,7 @@ func installComponent(cmd *cobra.Command, args []string) (err error) {
414414 cli .StartProgress ("Loading component Catalog..." )
415415
416416 catalog , err := lwcomponent .NewCatalog (cli .LwApi , lwcomponent .NewStageTarGz )
417- defer catalog .Cache ()
417+ defer catalog .Persist ()
418418
419419 cli .StopProgress ()
420420 if err != nil {
@@ -470,9 +470,25 @@ func installComponent(cmd *cobra.Command, args []string) (err error) {
470470 }
471471 cli .OutputChecklist (successIcon , "Component version %s installed\n " , component .InstalledVersion ())
472472
473- // @jon-stewart: TODO: Component lifecycle `cdk-init` command
473+ cli . StartProgress ( "Configuring component..." )
474474
475- // @jon-stewart: TODO: print install message
475+ stdout , stderr , errCmd := component .Exec .Execute ([]string {"cdk-init" }, cli .envs ()... )
476+ if errCmd != nil {
477+ if errCmd != lwcomponent .ErrNonExecutable {
478+ cli .Log .Warnw ("component life cycle" ,
479+ "error" , errCmd .Error (), "stdout" , stdout , "stderr" , stderr )
480+ }
481+ } else {
482+ cli .Log .Infow ("component life cycle" , "stdout" , stdout , "stderr" , stderr )
483+ }
484+ cli .StopProgress ()
485+
486+ cli .OutputChecklist (successIcon , "Component configured\n " )
487+ cli .OutputHuman ("\n Installation completed.\n " )
488+
489+ if component .InstallMessage != "" {
490+ cli .OutputHuman (fmt .Sprintf ("\n %s\n " , component .InstallMessage ))
491+ }
476492
477493 return
478494}
@@ -493,7 +509,7 @@ func showComponent(args []string) error {
493509 cli .StartProgress ("Loading components Catalog..." )
494510
495511 catalog , err := lwcomponent .NewCatalog (cli .LwApi , lwcomponent .NewStageTarGz )
496- defer catalog .Cache ()
512+ defer catalog .Persist ()
497513
498514 cli .StopProgress ()
499515 if err != nil {
@@ -561,7 +577,7 @@ func updateComponent(args []string) (err error) {
561577 cli .StartProgress ("Loading components Catalog..." )
562578
563579 catalog , err := lwcomponent .NewCatalog (cli .LwApi , lwcomponent .NewStageTarGz )
564- defer catalog .Cache ()
580+ defer catalog .Persist ()
565581
566582 cli .StopProgress ()
567583 if err != nil {
@@ -643,9 +659,24 @@ func updateComponent(args []string) (err error) {
643659 color .HiYellowString (component .Name ),
644660 color .HiCyanString (targetVersion .String ()))
645661
646- // @jon-stewart: TODO: component lifecycle event
662+ cli . StartProgress ( "Configuring component..." )
647663
648- // @jon-stewart: TODO: component update message
664+ stdout , stderr , errCmd := component .Exec .Execute ([]string {"cdk-reconfigure" }, cli .envs ()... )
665+ if errCmd != nil {
666+ if errCmd != lwcomponent .ErrNonExecutable {
667+ cli .Log .Warnw ("component life cycle" ,
668+ "error" , errCmd .Error (), "stdout" , stdout , "stderr" , stderr )
669+ }
670+ } else {
671+ cli .Log .Infow ("component life cycle" , "stdout" , stdout , "stderr" , stderr )
672+ }
673+ cli .StopProgress ()
674+
675+ cli .OutputChecklist (successIcon , "Component reconfigured\n " )
676+
677+ if component .UpdateMessage != "" {
678+ cli .OutputHuman (fmt .Sprintf ("\n %s\n " , component .UpdateMessage ))
679+ }
649680
650681 return
651682}
@@ -666,7 +697,7 @@ func deleteComponent(args []string) (err error) {
666697 cli .StartProgress ("Loading components Catalog..." )
667698
668699 catalog , err := lwcomponent .NewCatalog (cli .LwApi , lwcomponent .NewStageTarGz )
669- defer catalog .Cache ()
700+ defer catalog .Persist ()
670701
671702 cli .StopProgress ()
672703 if err != nil {
@@ -680,7 +711,20 @@ func deleteComponent(args []string) (err error) {
680711
681712 cli .OutputChecklist (successIcon , fmt .Sprintf ("Component %s found\n " , component .Name ))
682713
683- // @jon-stewart: TODO: component life cycle: cleanup
714+ cli .StartProgress ("Cleaning component data..." )
715+
716+ stdout , stderr , errCmd := component .Exec .Execute ([]string {"cdk-cleanup" }, cli .envs ()... )
717+ if errCmd != nil {
718+ if errCmd != lwcomponent .ErrNonExecutable {
719+ cli .Log .Warnw ("component life cycle" ,
720+ "error" , errCmd .Error (), "stdout" , stdout , "stderr" , stderr )
721+ }
722+ } else {
723+ cli .Log .Infow ("component life cycle" , "stdout" , stdout , "stderr" , stderr )
724+ }
725+ cli .StopProgress ()
726+
727+ cli .OutputChecklist (successIcon , "Component data removed\n " )
684728
685729 cli .StartProgress ("Deleting component..." )
686730 defer cli .StopProgress ()
0 commit comments