diff --git a/cmd/validator.go b/cmd/validator.go index 1c718867..b46bfbc3 100644 --- a/cmd/validator.go +++ b/cmd/validator.go @@ -47,7 +47,7 @@ For more information about validator, see: https://github.com/validator-labs/val SilenceErrors: true, SilenceUsage: false, PersistentPreRunE: func(_ *cobra.Command, _ []string) error { - if err := exec.CheckBinaries(exec.AllBins); err != nil { + if err := exec.CheckBinaries([]exec.Binary{exec.HelmBin, exec.KubectlBin}); err != nil { return err } return validator.InitWorkspace(c, cfg.Validator, cfg.ValidatorSubdirs, true) @@ -268,7 +268,7 @@ func NewUndeployValidatorCmd() *cobra.Command { SilenceErrors: true, SilenceUsage: false, PersistentPreRunE: func(_ *cobra.Command, _ []string) error { - if err := exec.CheckBinaries([]exec.Binary{exec.HelmBin, exec.KindBin}); err != nil { + if err := exec.CheckBinaries([]exec.Binary{exec.HelmBin}); err != nil { return err } return validator.InitWorkspace(c, cfg.Validator, cfg.ValidatorSubdirs, true) diff --git a/pkg/cmd/validator/validator.go b/pkg/cmd/validator/validator.go index 43b2b1e0..a690d906 100644 --- a/pkg/cmd/validator/validator.go +++ b/pkg/cmd/validator/validator.go @@ -49,6 +49,7 @@ import ( log "github.com/validator-labs/validatorctl/pkg/logging" "github.com/validator-labs/validatorctl/pkg/services/validator" "github.com/validator-labs/validatorctl/pkg/utils/embed" + "github.com/validator-labs/validatorctl/pkg/utils/exec" exec_utils "github.com/validator-labs/validatorctl/pkg/utils/exec" "github.com/validator-labs/validatorctl/pkg/utils/kind" "github.com/validator-labs/validatorctl/pkg/utils/kube" @@ -90,6 +91,11 @@ func InstallValidatorCommand(c *cfg.Config, tc *cfg.TaskConfig) error { if err != nil { return errors.Wrap(err, "failed to load validator configuration file") } + if vc.KindConfig.UseKindCluster { + if err := exec.CheckBinaries([]exec.Binary{exec.DockerBin, exec.KindBin}); err != nil { + return err + } + } if tc.UpdatePasswords { log.Header("Updating credentials in validator configuration file") if err := validator.UpdateValidatorCredentials(vc); err != nil { @@ -272,6 +278,11 @@ func UndeployValidatorCommand(tc *cfg.TaskConfig) error { if err != nil { return errors.Wrap(err, "failed to load validator configuration file") } + if vc.KindConfig.UseKindCluster && tc.DeleteCluster { + if err := exec.CheckBinaries([]exec.Binary{exec.KindBin}); err != nil { + return err + } + } log.Header("Uninstalling validator") helmClient, err := getHelmClient(vc) diff --git a/pkg/services/validator/validator_service.go b/pkg/services/validator/validator_service.go index b7ab29e9..cfbf9a7f 100644 --- a/pkg/services/validator/validator_service.go +++ b/pkg/services/validator/validator_service.go @@ -86,6 +86,9 @@ func ReadValidatorConfig(c *cfg.Config, tc *cfg.TaskConfig, vc *components.Valid return err } if vc.KindConfig.UseKindCluster { + if err := exec.CheckBinaries([]exec.Binary{exec.DockerBin, exec.KindBin}); err != nil { + return err + } if err := kind.ValidateClusters("Validator installation"); err != nil { return err } diff --git a/pkg/utils/exec/exec.go b/pkg/utils/exec/exec.go index d5c2c19f..32f57882 100644 --- a/pkg/utils/exec/exec.go +++ b/pkg/utils/exec/exec.go @@ -50,9 +50,6 @@ var ( Ping string // PingBin is a Binary struct that references the ping binary. PingBin = Binary{"ping", &Ping} - - // AllBins is a list of all binaries used by the CLI. - AllBins = []Binary{DockerBin, HelmBin, KindBin, KubectlBin} ) // CheckBinaries checks if the required binaries are installed and available on the PATH and returns an error if any are missing.