github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/kubernetes/manifest/selector.go (about)

     1  /*
     2  Copyright 2019 The Skaffold Authors
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package manifest
    18  
    19  import "regexp"
    20  
    21  type GroupKindSelector interface {
    22  	Matches(group, kind string) bool
    23  }
    24  
    25  type wildcardGroupKind struct {
    26  	Group *regexp.Regexp
    27  	Kind  *regexp.Regexp
    28  }
    29  
    30  func (w *wildcardGroupKind) Matches(group, kind string) bool {
    31  	return (w.Group == nil || w.Group.Match([]byte(group))) && (w.Kind == nil || w.Kind.Match([]byte(kind)))
    32  }
    33  
    34  // ConfigConnectorResourceSelector provides a resource selector for Google Cloud Config Connector resources
    35  // See https://cloud.google.com/config-connector/docs/overview
    36  var ConfigConnectorResourceSelector = []GroupKindSelector{
    37  	// add preliminary support for config connector services; group name is currently in flux
    38  	&wildcardGroupKind{Group: regexp.MustCompile(`([[:alpha:]]+\.)+cnrm\.cloud\.google\.com`)},
    39  }