func NewFileSource()

in pkg/utils/file.go [24:47]


func NewFileSource(project, path, uri string) (*Source, error) {
	if path == "" {
		return nil, types.ErrMissingPath
	}

	c, err := gabs.ParseJSONFile(path)
	if err != nil {
		return nil, errors.Wrapf(err, "unable to parse file: %s", path)
	}

	f := discoverFormat(c)
	if f == types.SourceFormatUnknown {
		return nil, types.ErrInvalidFormat
	}

	s := &Source{
		Project: project,
		URI:     uri,
		Data:    c,
		Format:  f,
	}

	return s, nil
}