Files
node-problem-detector/vendor/github.com/go-openapi/swag/loading/yaml.go
T
Bruno ChauvetandCiprian Hacman ddfb2c48d6 Fix Grype CVEs: update logrus and prometheus/prometheus
- Update github.com/sirupsen/logrus v1.9.0 -> v1.9.3 in test/go.mod
  to fix GHSA-4f99-4q7p-p3gh (High)
- Update github.com/prometheus/prometheus v0.35.0 -> v0.311.3
  to fix GHSA-vffh-x6r8-xx99 (Medium)
- Run go mod tidy and go mod vendor to update vendor directory
2026-05-04 08:30:29 +03:00

38 lines
891 B
Go

// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers
// SPDX-License-Identifier: Apache-2.0
package loading
import (
"encoding/json"
"path/filepath"
"github.com/go-openapi/swag/yamlutils"
)
// YAMLMatcher matches yaml for a file loader.
func YAMLMatcher(path string) bool {
ext := filepath.Ext(path)
return ext == ".yaml" || ext == ".yml"
}
// YAMLDoc loads a yaml document from either http or a file and converts it to json.
func YAMLDoc(path string, opts ...Option) (json.RawMessage, error) {
yamlDoc, err := YAMLData(path, opts...)
if err != nil {
return nil, err
}
return yamlutils.YAMLToJSON(yamlDoc)
}
// YAMLData loads a yaml document from either http or a file.
func YAMLData(path string, opts ...Option) (any, error) {
data, err := LoadFromFileOrHTTP(path, opts...)
if err != nil {
return nil, err
}
return yamlutils.BytesToYAMLDoc(data)
}