mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-17 23:59:21 +00:00
fix: add --no-install for activate command (#536)
to fix #534 Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>
This commit is contained in:
@@ -21,6 +21,10 @@ import (
|
|||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
skipInstall bool
|
||||||
|
)
|
||||||
|
|
||||||
// activateCmd represents the activate command
|
// activateCmd represents the activate command
|
||||||
var activateCmd = &cobra.Command{
|
var activateCmd = &cobra.Command{
|
||||||
Use: "activate [integration]",
|
Use: "activate [integration]",
|
||||||
@@ -39,7 +43,7 @@ var activateCmd = &cobra.Command{
|
|||||||
|
|
||||||
integration := integration.NewIntegration()
|
integration := integration.NewIntegration()
|
||||||
// Check if the integation exists
|
// Check if the integation exists
|
||||||
err := integration.Activate(integrationName, namespace, activeFilters)
|
err := integration.Activate(integrationName, namespace, activeFilters, skipInstall)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
color.Red("Error: %v", err)
|
color.Red("Error: %v", err)
|
||||||
return
|
return
|
||||||
@@ -51,5 +55,6 @@ var activateCmd = &cobra.Command{
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
IntegrationCmd.AddCommand(activateCmd)
|
IntegrationCmd.AddCommand(activateCmd)
|
||||||
|
activateCmd.Flags().BoolVarP(&skipInstall, "no-install", "s", false, "Only activate the integration filter without installing the filter (for example, if that filter plugin is already deployed in cluster, we do not need to re-install it again)")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -66,7 +66,7 @@ func (*Integration) Get(name string) (IIntegration, error) {
|
|||||||
return integrations[name], nil
|
return integrations[name], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Integration) Activate(name string, namespace string, activeFilters []string) error {
|
func (*Integration) Activate(name string, namespace string, activeFilters []string, skipInstall bool) error {
|
||||||
if _, ok := integrations[name]; !ok {
|
if _, ok := integrations[name]; !ok {
|
||||||
return errors.New("integration not found")
|
return errors.New("integration not found")
|
||||||
}
|
}
|
||||||
@@ -83,8 +83,10 @@ func (*Integration) Activate(name string, namespace string, activeFilters []stri
|
|||||||
|
|
||||||
viper.Set("active_filters", uniqueFilters)
|
viper.Set("active_filters", uniqueFilters)
|
||||||
|
|
||||||
if err := integrations[name].Deploy(namespace); err != nil {
|
if !skipInstall {
|
||||||
return err
|
if err := integrations[name].Deploy(namespace); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := viper.WriteConfig(); err != nil {
|
if err := viper.WriteConfig(); err != nil {
|
||||||
|
Reference in New Issue
Block a user