github.com/alex123012/deckhouse-controller-tools@v0.0.0-20230510090815-d594daf1af8c/pkg/markers/regutil.go (about) 1 /* 2 Copyright 2019 The Kubernetes 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 markers 18 19 // Must panics on errors creating definitions. 20 func Must(def *Definition, err error) *Definition { 21 if err != nil { 22 panic(err) 23 } 24 return def 25 } 26 27 // RegisterAll attempts to register all definitions against the given registry, 28 // stopping and returning if an error occurs. 29 func RegisterAll(reg *Registry, defs ...*Definition) error { 30 for _, def := range defs { 31 if err := reg.Register(def); err != nil { 32 return err 33 } 34 } 35 return nil 36 }