Use HasSuffixI utility function

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
pull/2951/head
Brad Davidson 2021-02-12 17:06:23 -08:00 committed by Brad Davidson
parent ec661c67d7
commit ae5b93a264
1 changed files with 3 additions and 10 deletions

View File

@ -15,6 +15,7 @@ import (
"time" "time"
errors2 "github.com/pkg/errors" errors2 "github.com/pkg/errors"
"github.com/rancher/k3s/pkg/agent/util"
v12 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1" v12 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
v1 "github.com/rancher/k3s/pkg/generated/controllers/k3s.cattle.io/v1" v1 "github.com/rancher/k3s/pkg/generated/controllers/k3s.cattle.io/v1"
"github.com/rancher/wrangler/pkg/apply" "github.com/rancher/wrangler/pkg/apply"
@ -309,11 +310,7 @@ func skipFile(fileName string, skips map[string]bool) bool {
return true return true
case skips[fileName]: case skips[fileName]:
return true return true
case strings.HasSuffix(fileName, ".json"): case util.HasSuffixI(fileName, ".yaml", ".yml", ".json"):
return false
case strings.HasSuffix(fileName, ".yml"):
return false
case strings.HasSuffix(fileName, ".yaml"):
return false return false
default: default:
return true return true
@ -329,11 +326,7 @@ func shouldDisableService(base, fileName string, disables map[string]bool) bool
return true return true
} }
} }
switch { if !util.HasSuffixI(fileName, ".yaml", ".yml", ".json") {
case strings.HasSuffix(fileName, ".json"):
case strings.HasSuffix(fileName, ".yml"):
case strings.HasSuffix(fileName, ".yaml"):
default:
return false return false
} }
baseFile := filepath.Base(fileName) baseFile := filepath.Base(fileName)