Added homepage and description to config type
diff --git a/cfg/config.go b/cfg/config.go
index 1a2d696..2233374 100644
--- a/cfg/config.go
+++ b/cfg/config.go
@@ -15,6 +15,14 @@
type Config struct {
Name string `yaml:"package"`
+ // Description is a short description for a package. This description is
+ // similar but different to a Go package description as it is for
+ // marketing and presentation purposes rather than technical ones.
+ Description string `json:"description,omitempty"`
+
+ // Home is a url to a website for the package.
+ Home string `yaml:"homepage,omitempty"`
+
// License provides either a SPDX license or a path to a file containing
// the license. For more information on SPDX see http://spdx.org/licenses/.
// When more than one license an SPDX expression can be used.
@@ -23,7 +31,7 @@
// Owners is an array of owners for a project. See the Owner type for
// more detail. These can be one or more people, companies, or other
// organizations.
- Owners Owners `json:"owners,omitempty"`
+ Owners Owners `yaml:"owners,omitempty"`
Ignore []string `yaml:"ignore,omitempty"`
Imports Dependencies `yaml:"import"`
@@ -32,12 +40,14 @@
// A transitive representation of a dependency for importing and exploting to yaml.
type cf struct {
- Name string `yaml:"package"`
- License string `yaml:"license,omitempty"`
- Owners Owners `json:"owners,omitempty"`
- Ignore []string `yaml:"ignore,omitempty"`
- Imports Dependencies `yaml:"import"`
- DevImports Dependencies `yaml:"devimport,omitempty"`
+ Name string `yaml:"package"`
+ Description string `yaml:"description,omitempty"`
+ Home string `yaml:"homepage,omitempty"`
+ License string `yaml:"license,omitempty"`
+ Owners Owners `yaml:"owners,omitempty"`
+ Ignore []string `yaml:"ignore,omitempty"`
+ Imports Dependencies `yaml:"import"`
+ DevImports Dependencies `yaml:"devimport,omitempty"`
}
// ConfigFromYaml returns an instance of Config from YAML
@@ -63,6 +73,8 @@
return err
}
c.Name = newConfig.Name
+ c.Description = newConfig.Description
+ c.Home = newConfig.Home
c.License = newConfig.License
c.Owners = newConfig.Owners
c.Ignore = newConfig.Ignore
@@ -78,10 +90,12 @@
// MarshalYAML is a hook for gopkg.in/yaml.v2 in the marshaling process
func (c *Config) MarshalYAML() (interface{}, error) {
newConfig := &cf{
- Name: c.Name,
- License: c.License,
- Owners: c.Owners,
- Ignore: c.Ignore,
+ Name: c.Name,
+ Description: c.Description,
+ Home: c.Home,
+ License: c.License,
+ Owners: c.Owners,
+ Ignore: c.Ignore,
}
i, err := c.Imports.Clone().DeDupe()
if err != nil {
@@ -129,6 +143,8 @@
func (c *Config) Clone() *Config {
n := &Config{}
n.Name = c.Name
+ n.Description = c.Description
+ n.Home = c.Home
n.License = c.License
n.Owners = c.Owners.Clone()
n.Ignore = c.Ignore
diff --git a/cfg/config_test.go b/cfg/config_test.go
index dc5bd35..06ade6d 100644
--- a/cfg/config_test.go
+++ b/cfg/config_test.go
@@ -8,6 +8,8 @@
var yml = `
package: fake/testing
+description: foo bar baz
+homepage: https://example.com
license: MIT
owners:
- name: foo
@@ -50,6 +52,14 @@
t.Errorf("Inaccurate name found %s", cfg.Name)
}
+ if cfg.Description != "foo bar baz" {
+ t.Errorf("Inaccurate description found %s", cfg.Description)
+ }
+
+ if cfg.Home != "https://example.com" {
+ t.Errorf("Inaccurate homepage found %s", cfg.Home)
+ }
+
if cfg.License != "MIT" {
t.Errorf("Inaccurate license found %s", cfg.License)
}