func()

in pkg/config/config.go [124:155]


func (cp *configProviderImpl) loadSchema() (any, error) {
	schemaPath := cp.schema

	var reader io.Reader
	var err error

	if isUrl(schemaPath) {
		resp, err := http.Get(schemaPath)
		if err != nil {
			return nil, fmt.Errorf("failed to get schema file: %v", err)
		}
		if resp.StatusCode != http.StatusOK {
			return nil, fmt.Errorf("faild to get schema file, statuscode %v", resp.StatusCode)
		}
		reader = resp.Body
	} else {
		if !filepath.IsAbs(schemaPath) {
			schemaPath = filepath.Join(filepath.Dir(cp.config), schemaPath)
		}
		reader, err = os.Open(schemaPath)
		if err != nil {
			return nil, fmt.Errorf("failed to open schema file: %v", err)
		}
	}

	schema, err := jsonschema.UnmarshalJSON(reader)
	if err != nil {
		return nil, fmt.Errorf("failed to unmarshal schema: %v", err)
	}

	return schema, nil
}