Added owners to glide.yaml file
diff --git a/cfg/config.go b/cfg/config.go
index 3718e93..1a2d696 100644
--- a/cfg/config.go
+++ b/cfg/config.go
@@ -18,7 +18,13 @@
// 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.
- License string `yaml:"license,omitempty"`
+ License string `yaml:"license,omitempty"`
+
+ // 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"`
+
Ignore []string `yaml:"ignore,omitempty"`
Imports Dependencies `yaml:"import"`
DevImports Dependencies `yaml:"devimport,omitempty"`
@@ -28,6 +34,7 @@
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"`
@@ -57,6 +64,7 @@
}
c.Name = newConfig.Name
c.License = newConfig.License
+ c.Owners = newConfig.Owners
c.Ignore = newConfig.Ignore
c.Imports = newConfig.Imports
c.DevImports = newConfig.DevImports
@@ -72,6 +80,7 @@
newConfig := &cf{
Name: c.Name,
License: c.License,
+ Owners: c.Owners,
Ignore: c.Ignore,
}
i, err := c.Imports.Clone().DeDupe()
@@ -121,6 +130,7 @@
n := &Config{}
n.Name = c.Name
n.License = c.License
+ n.Owners = c.Owners.Clone()
n.Ignore = c.Ignore
n.Imports = c.Imports.Clone()
n.DevImports = c.DevImports.Clone()
@@ -377,6 +387,42 @@
}
}
+// Owners is a list of owners for a project.
+type Owners []*Owner
+
+// Clone performs a deep clone of Owners
+func (o Owners) Clone() Owners {
+ n := make(Owners, 0, 1)
+ for _, v := range o {
+ n = append(n, v.Clone())
+ }
+ return n
+}
+
+// Owner describes an owner of a package. This can be a person, company, or
+// other organization. This is useful if someone needs to contact the
+// owner of a package to address things like a security issue.
+type Owner struct {
+
+ // Name describes the name of an organization.
+ Name string `yaml:"name,omitempty"`
+
+ // Email is an email address to reach the owner at.
+ Email string `yaml:"email,omitempty"`
+
+ // Home is a url to a website for the owner.
+ Home string `yaml:"homepage,omitempty"`
+}
+
+// Clone creates a clone of a Dependency
+func (o *Owner) Clone() *Owner {
+ return &Owner{
+ Name: o.Name,
+ Email: o.Email,
+ Home: o.Home,
+ }
+}
+
func stringArrayDeDupe(s []string, items ...string) []string {
for _, item := range items {
exists := false
diff --git a/cfg/config_test.go b/cfg/config_test.go
index 93b7876..dc5bd35 100644
--- a/cfg/config_test.go
+++ b/cfg/config_test.go
@@ -9,6 +9,10 @@
var yml = `
package: fake/testing
license: MIT
+owners:
+- name: foo
+ email: bar@example.com
+ homepage: https://example.com
import:
- package: github.com/kylelemons/go-gypsy
subpackages:
@@ -122,3 +126,43 @@
t.Error("HasDependency picking up dependency it shouldn't")
}
}
+
+func TestOwners(t *testing.T) {
+ o := new(Owner)
+ o.Name = "foo"
+ o.Email = "foo@example.com"
+ o.Home = "https://foo.example.com"
+
+ o2 := o.Clone()
+ if o2.Name != o.Name || o2.Email != o.Email || o2.Home != o.Home {
+ t.Error("Unable to clone Owner")
+ }
+
+ o.Name = "Bar"
+ if o.Name == o2.Name {
+ t.Error("Owner clone is a pointer instead of a clone")
+ }
+
+ s := make(Owners, 0, 1)
+ s = append(s, o)
+ s2 := s.Clone()
+ o3 := s2[0]
+
+ o3.Name = "Qux"
+
+ if o3.Name == o.Name {
+ t.Error("Owners cloning isn't deep")
+ }
+
+ cfg := &Config{}
+ err := yaml.Unmarshal([]byte(yml), &cfg)
+ if err != nil {
+ t.Errorf("Unable to Unmarshal config yaml")
+ }
+
+ if cfg.Owners[0].Name != "foo" ||
+ cfg.Owners[0].Email != "bar@example.com" ||
+ cfg.Owners[0].Home != "https://example.com" {
+ t.Error("Unable to parse owners from yaml")
+ }
+}