(v interface{})
| 147 | } |
| 148 | |
| 149 | func NewStrictDecoder(v interface{}) (*yaml.Decoder, error) { |
| 150 | b, err := yaml.Marshal(v) |
| 151 | if err != nil { |
| 152 | return nil, fmt.Errorf("fail to marshal %q: %w", v, err) |
| 153 | } |
| 154 | |
| 155 | dec := yaml.NewDecoder( |
| 156 | bytes.NewReader(b), |
| 157 | yaml.Strict(), |
| 158 | yaml.Validator(validator.New()), |
| 159 | ) |
| 160 | return dec, nil |
| 161 | } |
| 162 | |
| 163 | // loggerKey is the key used to store logger within context |
| 164 | const loggerKey contextKey = "logger" |
no outgoing calls
no test coverage detected