Skip to content

Commit

Permalink
Patch/delete double whitespace (#118)
Browse files Browse the repository at this point in the history
* imple DeleteDoubleWhiteSpace

* fix blank check
  • Loading branch information
nnao45 authored and PrasadG193 committed Jul 8, 2019
1 parent f2f2188 commit 2ebc040
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/execute/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package execute
import (
"bytes"
"fmt"
"gopkg.in/yaml.v2"
"io/ioutil"
"os"
"os/exec"
Expand All @@ -13,9 +12,12 @@ import (
"text/tabwriter"
"unicode"

"gopkg.in/yaml.v2"

"github.com/infracloudio/botkube/pkg/config"
filterengine "github.com/infracloudio/botkube/pkg/filterengine"
log "github.com/infracloudio/botkube/pkg/logging"
"github.com/infracloudio/botkube/pkg/utils"
)

var validKubectlCommands = map[string]bool{
Expand Down Expand Up @@ -178,7 +180,7 @@ func trimQuotes(clusterValue string) string {

func runKubectlCommand(args []string, clusterName string, isAuthChannel bool) string {
// Use 'default' as a default namespace
args = append([]string{"-n", "default"}, args...)
args = append([]string{"-n", "default"}, utils.DeleteDoubleWhiteSpace(args)...)

// Remove unnecessary flags
finalArgs := []string{}
Expand Down
11 changes: 11 additions & 0 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,14 @@ func GetObjectTypeMetaData(obj interface{}) metaV1.TypeMeta {
}
return typeMeta
}

// DeleteDoubleWhiteSpace returns slice that removing whitespace from a arg slice
func DeleteDoubleWhiteSpace(slice []string) []string {
result := []string{}
for _, s := range slice {
if len(s) != 0 {
result = append(result, s)
}
}
return result
}

0 comments on commit 2ebc040

Please sign in to comment.