github.com/blend/go-sdk@v1.20220411.3/selector/has_key.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package selector 9 10 // HasKey returns if a label set has a given key. 11 type HasKey string 12 13 // Matches returns the selector result. 14 func (hk HasKey) Matches(labels Labels) bool { 15 _, hasKey := labels[string(hk)] 16 return hasKey 17 } 18 19 // Validate validates the selector. 20 func (hk HasKey) Validate() (err error) { 21 err = CheckKey(string(hk)) 22 return 23 } 24 25 // String returns a string representation of the selector. 26 func (hk HasKey) String() string { 27 return string(hk) 28 }