github.com/openconfig/goyang@v1.4.5/pkg/yang/options.go (about) 1 // Copyright 2017 Google Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package yang 16 17 // Options defines the options that should be used when parsing YANG modules, 18 // including specific overrides for potentially problematic YANG constructs. 19 type Options struct { 20 // IgnoreSubmoduleCircularDependencies specifies whether circular dependencies 21 // between submodules. Setting this value to true will ensure that this 22 // package will explicitly ignore the case where a submodule will include 23 // itself through a circular reference. 24 IgnoreSubmoduleCircularDependencies bool 25 // StoreUses controls whether the Uses field of each YANG entry should be 26 // populated. Setting this value to true will cause each Entry which is 27 // generated within the schema to store the logical grouping from which it 28 // is derived. 29 StoreUses bool 30 // DeviateOptions contains options for how deviations are handled. 31 DeviateOptions DeviateOptions 32 } 33 34 // DeviateOptions contains options for how deviations are handled. 35 type DeviateOptions struct { 36 // IgnoreDeviateNotSupported indicates to the parser to retain nodes 37 // that are marked with "deviate not-supported". An example use case is 38 // where the user wants to interact with different targets that have 39 // different support for a leaf without having to use a second instance 40 // of an AST. 41 IgnoreDeviateNotSupported bool 42 } 43 44 // IsDeviateOpt ensures that DeviateOptions satisfies the DeviateOpt interface. 45 func (DeviateOptions) IsDeviateOpt() {} 46 47 // DeviateOpt is an interface that can be used in function arguments. 48 type DeviateOpt interface { 49 IsDeviateOpt() 50 } 51 52 func hasIgnoreDeviateNotSupported(opts []DeviateOpt) bool { 53 for _, o := range opts { 54 if opt, ok := o.(DeviateOptions); ok { 55 return opt.IgnoreDeviateNotSupported 56 } 57 } 58 return false 59 }