1
// Copyright Istio Authors
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
7
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
21
"istio.io/istio/pkg/log"
24
func MatchesMap(selection, cluster map[string]string) bool {
25
if len(selection) == 0 {
28
if len(cluster) == 0 {
32
for ks, vs := range selection {
37
if !MatchesGlob(vc, vs) {
44
func MatchesGlobs(matchString string, patterns []string) bool {
45
if len(patterns) == 0 {
48
if len(patterns) == 1 {
49
p := strings.TrimSpace(patterns[0])
50
if p == "" || p == "*" {
55
for _, p := range patterns {
56
if MatchesGlob(matchString, p) {
63
func MatchesGlob(matchString, pattern string) bool {
64
match, err := filepath.Match(pattern, matchString)
66
// Shouldn't be here as prior validation is assumed.
67
log.Errorf("Unexpected filepath error for %s match %s: %s", pattern, matchString, err)