go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/selector/check_labels.go (about) 1 /* 2 3 Copyright (c) 2023 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package selector 9 10 import ( 11 "fmt" 12 ) 13 14 // CheckLabels validates all the keys and values for the label set. 15 func CheckLabels(labels Labels) (err error) { 16 for key, value := range labels { 17 err = CheckKey(key) 18 if err != nil { 19 err = fmt.Errorf("invalid label key %s; %w", key, err) 20 return 21 } 22 err = CheckValue(value) 23 if err != nil { 24 err = fmt.Errorf("invalid label key %s and value %s; %w", key, value, err) 25 return 26 } 27 } 28 return 29 }