github.com/containerd/containerd@v22.0.0-20200918172823-438c87b8e050+incompatible/filters/adaptor.go (about)

     1  /*
     2     Copyright The containerd 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 filters
    18  
    19  // Adaptor specifies the mapping of fieldpaths to a type. For the given field
    20  // path, the value and whether it is present should be returned. The mapping of
    21  // the fieldpath to a field is deferred to the adaptor implementation, but
    22  // should generally follow protobuf field path/mask semantics.
    23  type Adaptor interface {
    24  	Field(fieldpath []string) (value string, present bool)
    25  }
    26  
    27  // AdapterFunc allows implementation specific matching of fieldpaths
    28  type AdapterFunc func(fieldpath []string) (string, bool)
    29  
    30  // Field returns the field name and true if it exists
    31  func (fn AdapterFunc) Field(fieldpath []string) (string, bool) {
    32  	return fn(fieldpath)
    33  }