@@ -21,6 +21,7 @@ package cmd
2121import (
2222 "fmt"
2323 "os"
24+ "time"
2425
2526 "github.com/Masterminds/semver"
2627 "github.com/fatih/color"
@@ -349,7 +350,18 @@ func componentsToTable() [][]string {
349350 return out
350351}
351352
352- func runComponentsInstall (_ * cobra.Command , args []string ) (err error ) {
353+ func runComponentsInstall (cmd * cobra.Command , args []string ) (err error ) {
354+ var (
355+ componentName string = args [0 ]
356+ version string = versionArg
357+ params map [string ]interface {} = make (map [string ]interface {})
358+ start time.Time
359+ )
360+
361+ cli .Event .Component = componentName
362+ cli .Event .Feature = "install_component"
363+ defer cli .SendHoneyvent ()
364+
353365 cli .StartProgress ("Loading components state..." )
354366 // @afiune maybe move the state to the cache and fetch if it if has expired
355367 cli .LwComponents , err = lwcomponent .LoadState (cli .LwApi )
@@ -359,21 +371,45 @@ func runComponentsInstall(_ *cobra.Command, args []string) (err error) {
359371 return
360372 }
361373
362- component , found := cli .LwComponents .GetComponent (args [ 0 ] )
374+ component , found := cli .LwComponents .GetComponent (componentName )
363375 if ! found {
364- err = errors .New ("component not found. Try running 'lacework component list'" )
376+ err = errors .New (fmt . Sprintf ( "component %s not found. Try running 'lacework component list'" , componentName ) )
365377 return
366378 }
367379
380+ cli .OutputChecklist (successIcon , fmt .Sprintf ("Component %s found\n " , componentName ))
381+
382+ if version == "" {
383+ version = component .LatestVersion .String ()
384+ }
385+
386+ start = time .Now ()
387+
368388 cli .StartProgress (fmt .Sprintf ("Installing component %s..." , component .Name ))
369- err = cli .LwComponents .Install (args [ 0 ], versionArg )
389+ err = cli .LwComponents .Install (component , version )
370390 cli .StopProgress ()
371391 if err != nil {
372392 err = errors .Wrap (err , "unable to install component" )
373393 return
374394 }
375395 cli .OutputChecklist (successIcon , "Component %s installed\n " , color .HiYellowString (component .Name ))
376- cli .OutputChecklist (successIcon , "Signature verified\n " )
396+
397+ params ["install_duration_ms" ] = time .Since (start ).Milliseconds ()
398+
399+ start = time .Now ()
400+
401+ cli .StartProgress ("Verifing component signature..." )
402+ err = cli .LwComponents .Verify (component , version )
403+ cli .StopProgress ()
404+ if err != nil {
405+ err = errors .Wrap (err , "verification of component signature failed" )
406+ return
407+ }
408+ cli .OutputChecklist (successIcon , "Component signature verified\n " )
409+
410+ params ["verify_duration_ms" ] = time .Since (start ).Milliseconds ()
411+
412+ start = time .Now ()
377413
378414 cli .StartProgress (fmt .Sprintf ("Configuring component %s..." , component .Name ))
379415 // component life cycle: initialize
@@ -389,6 +425,10 @@ func runComponentsInstall(_ *cobra.Command, args []string) (err error) {
389425 cli .OutputChecklist (successIcon , "Component configured\n " )
390426 cli .OutputHuman ("\n Installation completed.\n " )
391427
428+ params ["configure_duration_ms" ] = time .Since (start ).Milliseconds ()
429+
430+ cli .Event .FeatureData = params
431+
392432 if component .Breadcrumbs .InstallationMessage != "" {
393433 cli .OutputHuman ("\n " )
394434 cli .OutputHuman (component .Breadcrumbs .InstallationMessage )
@@ -407,13 +447,17 @@ func runComponentsUpdate(_ *cobra.Command, args []string) (err error) {
407447 return
408448 }
409449
450+ component_name := args [0 ]
451+
410452 component , found := cli .LwComponents .GetComponent (args [0 ])
411453 if ! found {
412- err = errors .New ("component not found. Try running 'lacework component list'" )
454+ err = errors .New (fmt . Sprintf ( "component %s not found. Try running 'lacework component list'" , component_name ) )
413455 return
414456 }
415457 // @afiune end boilerplate load components
416458
459+ cli .OutputChecklist (successIcon , fmt .Sprintf ("Component %s found\n " , component_name ))
460+
417461 updateTo := component .LatestVersion
418462 if versionArg != "" {
419463 parsedVersion , err := semver .NewVersion (versionArg )
@@ -434,8 +478,8 @@ func runComponentsUpdate(_ *cobra.Command, args []string) (err error) {
434478 return nil
435479 }
436480
437- cli .StartProgress (fmt .Sprintf ("Updating component %s..." , component .Name ))
438- err = cli .LwComponents .Install (args [ 0 ] , updateTo .String ())
481+ cli .StartProgress (fmt .Sprintf ("Updating component %s to version %s ..." , component .Name , & updateTo ))
482+ err = cli .LwComponents .Install (component , updateTo .String ())
439483 cli .StopProgress ()
440484 if err != nil {
441485 err = errors .Wrap (err , "unable to update component" )
@@ -444,7 +488,15 @@ func runComponentsUpdate(_ *cobra.Command, args []string) (err error) {
444488 cli .OutputChecklist (successIcon , "Component %s updated to %s\n " ,
445489 color .HiYellowString (component .Name ),
446490 color .HiCyanString (fmt .Sprintf ("v%s" , updateTo .String ())))
447- cli .OutputChecklist (successIcon , "Signature verified\n " )
491+
492+ cli .StartProgress ("Verifing component signature..." )
493+ err = cli .LwComponents .Verify (component , updateTo .String ())
494+ cli .StopProgress ()
495+ if err != nil {
496+ err = errors .Wrap (err , "verification of component signature failed" )
497+ return
498+ }
499+ cli .OutputChecklist (successIcon , "Component signature verified\n " )
448500
449501 cli .StartProgress (fmt .Sprintf ("Reconfiguring %s component..." , component .Name ))
450502 // component life cycle: reconfigure
0 commit comments