diff --git a/.wwhrd.yml b/.wwhrd.yml index 611b586..47ee588 100644 --- a/.wwhrd.yml +++ b/.wwhrd.yml @@ -1,8 +1,8 @@ --- -blacklist: +denylist: - GPL-2.0 -whitelist: +allowlist: - Apache-2.0 - MIT - ISC diff --git a/README.md b/README.md index e5ce0d9..27fb7a6 100644 --- a/README.md +++ b/README.md @@ -22,14 +22,14 @@ brew install frapposelli/tap/wwhrd Configuration for `wwhrd` is stored in `.wwhrd.yml` at the root of the repo you want to check. -The format is borrowed from [Anderson](https://github.com/xoebus/anderson) and it's 1:1 compatible (just run `wwhrd check -f .anderson.yml`). +The format is compatible with [Anderson](https://github.com/xoebus/anderson), just run `wwhrd check -f .anderson.yml`. ```yaml --- -blacklist: +denylist: - GPL-2.0 -whitelist: +allowlist: - Apache-2.0 - MIT diff --git a/cli.go b/cli.go index b8e2f22..9667cc1 100644 --- a/cli.go +++ b/cli.go @@ -204,13 +204,13 @@ func (c *Check) Execute(args []string) error { // Make a map out of the blacklist blacklist := make(map[string]bool) - for _, v := range t.Blacklist { + for _, v := range t.Denylist { blacklist[v] = true } // Make a map out of the whitelist whitelist := make(map[string]bool) - for _, v := range t.Whitelist { + for _, v := range t.Allowlist { whitelist[v] = true } diff --git a/config.go b/config.go index c814381..dab68d7 100644 --- a/config.go +++ b/config.go @@ -5,19 +5,36 @@ import ( "gopkg.in/yaml.v2" ) +type OldConfig struct { + Allowlist []string `yaml:"whitelist"` + Denylist []string `yaml:"blacklist"` + Exceptions []string `yaml:"exceptions"` +} + type Config struct { - Whitelist []string `yaml:"whitelist"` - Blacklist []string `yaml:"blacklist"` + Allowlist []string `yaml:"allowlist"` + Denylist []string `yaml:"denylist"` Exceptions []string `yaml:"exceptions"` } func ReadConfig(config []byte) (*Config, error) { t := Config{} - var err error - if err = yaml.NewDecoder(bytes.NewReader(config)).Decode(&t); err != nil { + old := OldConfig{} + + // Parse new format + if err := yaml.NewDecoder(bytes.NewReader(config)).Decode(&t); err != nil { return nil, err } + // Parse old format + if err := yaml.NewDecoder(bytes.NewReader(config)).Decode(&old); err != nil { + return nil, err + } + + t.Allowlist = append(t.Allowlist, old.Allowlist...) + t.Denylist = append(t.Denylist, old.Denylist...) + t.Exceptions = append(t.Exceptions, old.Exceptions...) + return &t, nil } diff --git a/wwhrd_test.go b/wwhrd_test.go index 14d1d88..a4dec38 100644 --- a/wwhrd_test.go +++ b/wwhrd_test.go @@ -86,12 +86,12 @@ func TestCliCommandsErrors(t *testing.T) { } var mockConf = `--- -whitelist: +allowlist: - BSD-3-Clause ` var mockConfBL = `--- -blacklist: +denylist: - BSD-3-Clause `