2018-03-02 23:22:57 -08:00
|
|
|
package pm
|
|
|
|
|
2018-03-02 23:23:11 -08:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"net/url"
|
|
|
|
)
|
2018-03-02 23:22:57 -08:00
|
|
|
|
2018-03-02 23:23:08 -08:00
|
|
|
// Meta tracks metadata for a package
|
2018-03-02 23:22:57 -08:00
|
|
|
type Meta struct {
|
2018-03-02 23:23:06 -08:00
|
|
|
Name Name `json:"name"`
|
|
|
|
Version Version `json:"version"`
|
|
|
|
Description string `json:"description"`
|
2018-03-02 23:23:11 -08:00
|
|
|
|
|
|
|
Remote url.URL `json:"remote"`
|
2018-03-02 23:22:57 -08:00
|
|
|
}
|
|
|
|
|
2018-03-02 23:23:08 -08:00
|
|
|
// Valid validates the contents of a Meta for requires fields.
|
2018-03-02 23:22:57 -08:00
|
|
|
func (m *Meta) Valid() (bool, error) {
|
|
|
|
if m.Name == "" {
|
|
|
|
return false, errors.New("name cannot be empty")
|
|
|
|
}
|
|
|
|
if m.Version == "" {
|
|
|
|
return false, errors.New("version cannot be empty")
|
|
|
|
}
|
|
|
|
if m.Description == "" {
|
|
|
|
return false, errors.New("description cannot be empty")
|
|
|
|
}
|
|
|
|
return true, nil
|
|
|
|
}
|