From 10fcffeca31ab029f97e6a5c26112726e1ccd660 Mon Sep 17 00:00:00 2001
From: lijianguo <lijianguo@zhumengyuan.com>
Date: Wed, 4 Nov 2020 16:41:59 +0800
Subject: [PATCH] chore(workflow-cli):replace whitelist with allowlist

---
 README.md                |  8 +++---
 cmd/cmd.go               |  6 ++---
 cmd/whitelist.go         | 28 +++++++++----------
 cmd/whitelist_test.go    | 28 +++++++++----------
 codecov.yml              |  2 +-
 drycc.go                 |  6 ++---
 parser/whitelist.go      | 58 ++++++++++++++++++++--------------------
 parser/whitelist_test.go | 26 +++++++++---------
 8 files changed, 81 insertions(+), 81 deletions(-)

diff --git a/README.md b/README.md
index 111905828..e5b239f36 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,9 @@
 # Drycc Client
 
-[![Build Status](https://travis-ci.org/drycc/workflow-cli.svg?branch=master)](https://travis-ci.org/drycc/workflow-cli)
+[![Build Status](https://travis-ci.org/drycc/workflow-cli.svg?branch=main)](https://travis-ci.org/drycc/workflow-cli)
 [![Go Report Card](https://goreportcard.com/badge/github.com/drycc/workflow-cli)](https://goreportcard.com/report/github.com/drycc/workflow-cli)
-[![codebeat badge](https://codebeat.co/badges/826a57a3-c9a8-4263-ae57-f249d5a3bb79)](https://codebeat.co/projects/github-com-drycc-workflow-cli-master)
-[![codecov](https://codecov.io/gh/drycc/workflow-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/drycc/workflow-cli)
+[![codebeat badge](https://codebeat.co/badges/b609cb7f-7b42-4214-8787-09298f553176)](https://codebeat.co/projects/github-com-drycc-workflow-cli-main)
+[![codecov](https://codecov.io/gh/drycc/workflow-cli/branch/main/graph/badge.svg)](https://codecov.io/gh/drycc/workflow-cli)
 
 Download Links: https://github.com/drycc/workflow-cli/releases
 
@@ -58,7 +58,7 @@ To learn more about a command run `drycc help <command>`.
 
 ## License
 
-see [LICENSE](https://github.com/drycc/workflow-cli/blob/master/LICENSE)
+see [LICENSE](https://github.com/drycc/workflow-cli/blob/main/LICENSE)
 
 [k8s-home]: http://kubernetes.io
 [install-k8s]: http://kubernetes.io/gettingstarted/
diff --git a/cmd/cmd.go b/cmd/cmd.go
index 6485f59da..f0fb0e3ac 100644
--- a/cmd/cmd.go
+++ b/cmd/cmd.go
@@ -93,9 +93,9 @@ type Commander interface {
 	UsersList(results int) error
 	UsersEnable(string) error
 	UsersDisable(string) error
-	WhitelistAdd(string, string) error
-	WhitelistList(string) error
-	WhitelistRemove(string, string) error
+	AllowlistAdd(string, string) error
+	AllowlistList(string) error
+	AllowlistRemove(string, string) error
 	Println(...interface{}) (int, error)
 	Print(...interface{}) (int, error)
 	Printf(string, ...interface{}) (int, error)
diff --git a/cmd/whitelist.go b/cmd/whitelist.go
index f12f38006..3165a745d 100644
--- a/cmd/whitelist.go
+++ b/cmd/whitelist.go
@@ -3,42 +3,42 @@ package cmd
 import (
 	"strings"
 
-	"github.com/drycc/controller-sdk-go/whitelist"
+	"github.com/drycc/controller-sdk-go/allowlist"
 )
 
-// WhitelistList lists the addresses whitelisted for app
-func (d *DryccCmd) WhitelistList(appID string) error {
+// Allowlistlist lists the addresses allowlisted for app
+func (d *DryccCmd) AllowlistList(appID string) error {
 	s, appID, err := load(d.ConfigFile, appID)
 
 	if err != nil {
 		return err
 	}
 
-	whitelist, err := whitelist.List(s.Client, appID)
+	allowlist, err := allowlist.List(s.Client, appID)
 	if d.checkAPICompatibility(s.Client, err) != nil {
 		return err
 	}
 
-	d.Printf("=== %s Whitelisted Addresses\n", appID)
+	d.Printf("=== %s Allowlisted Addresses\n", appID)
 
-	for _, ip := range whitelist.Addresses {
+	for _, ip := range allowlist.Addresses {
 		d.Println(ip)
 	}
 	return nil
 }
 
-// WhitelistAdd adds the addresses to the app's Whitelist.
-func (d *DryccCmd) WhitelistAdd(appID, IPs string) error {
+// AllowlistAdd adds the addresses to the app's allowlist.
+func (d *DryccCmd) AllowlistAdd(appID, IPs string) error {
 	s, appID, err := load(d.ConfigFile, appID)
 
 	if err != nil {
 		return err
 	}
 
-	d.Printf("Adding %s to %s whitelist...\n", IPs, appID)
+	d.Printf("Adding %s to %s allowlist...\n", IPs, appID)
 
 	quit := progress(d.WOut)
-	_, err = whitelist.Add(s.Client, appID, strings.Split(IPs, ","))
+	_, err = allowlist.Add(s.Client, appID, strings.Split(IPs, ","))
 	quit <- true
 	<-quit
 	if d.checkAPICompatibility(s.Client, err) != nil {
@@ -49,18 +49,18 @@ func (d *DryccCmd) WhitelistAdd(appID, IPs string) error {
 	return nil
 }
 
-// WhitelistRemove deletes the addresses from the app's Whitelist.
-func (d *DryccCmd) WhitelistRemove(appID, IPs string) error {
+// AllowlistRemove deletes the addresses from the app's Allowlist.
+func (d *DryccCmd) AllowlistRemove(appID, IPs string) error {
 	s, appID, err := load(d.ConfigFile, appID)
 
 	if err != nil {
 		return err
 	}
 
-	d.Printf("Removing %s from %s whitelist...\n", IPs, appID)
+	d.Printf("Removing %s from %s allowlist...\n", IPs, appID)
 
 	quit := progress(d.WOut)
-	err = whitelist.Delete(s.Client, appID, strings.Split(IPs, ","))
+	err = allowlist.Delete(s.Client, appID, strings.Split(IPs, ","))
 	quit <- true
 	<-quit
 	if d.checkAPICompatibility(s.Client, err) != nil {
diff --git a/cmd/whitelist_test.go b/cmd/whitelist_test.go
index ceda89061..7f0c4b942 100644
--- a/cmd/whitelist_test.go
+++ b/cmd/whitelist_test.go
@@ -11,7 +11,7 @@ import (
 	"github.com/drycc/workflow-cli/pkg/testutil"
 )
 
-func TestWhitelistList(t *testing.T) {
+func TestAllowlistList(t *testing.T) {
 	t.Parallel()
 	cf, server, err := testutil.NewTestServerAndClient()
 	if err != nil {
@@ -21,20 +21,20 @@ func TestWhitelistList(t *testing.T) {
 	var b bytes.Buffer
 	cmdr := DryccCmd{WOut: &b, ConfigFile: cf}
 
-	server.Mux.HandleFunc("/v2/apps/foo/whitelist/", func(w http.ResponseWriter, r *http.Request) {
+	server.Mux.HandleFunc("/v2/apps/foo/allowlist/", func(w http.ResponseWriter, r *http.Request) {
 		testutil.SetHeaders(w)
 		fmt.Fprintf(w, `{
     "addresses": ["1.2.3.4", "0.0.0.0/0"]
 }`)
 	})
 
-	err = cmdr.WhitelistList("foo")
+	err = cmdr.AllowlistList("foo")
 	assert.NoErr(t, err)
 
-	assert.Equal(t, b.String(), "=== foo Whitelisted Addresses\n1.2.3.4\n0.0.0.0/0\n", "output")
+	assert.Equal(t, b.String(), "=== foo Allowlisted Addresses\n1.2.3.4\n0.0.0.0/0\n", "output")
 }
 
-func TestWhitelistAdd(t *testing.T) {
+func TestAllowlistAdd(t *testing.T) {
 	t.Parallel()
 	cf, server, err := testutil.NewTestServerAndClient()
 	if err != nil {
@@ -44,21 +44,21 @@ func TestWhitelistAdd(t *testing.T) {
 	var b bytes.Buffer
 	cmdr := DryccCmd{WOut: &b, ConfigFile: cf}
 
-	server.Mux.HandleFunc("/v2/apps/foo/whitelist/", func(w http.ResponseWriter, r *http.Request) {
-		testutil.AssertBody(t, api.Whitelist{Addresses: []string{"1.2.3.4", "0.0.0.0/0"}}, r)
+	server.Mux.HandleFunc("/v2/apps/foo/allowlist/", func(w http.ResponseWriter, r *http.Request) {
+		testutil.AssertBody(t, api.Allowlist{Addresses: []string{"1.2.3.4", "0.0.0.0/0"}}, r)
 		testutil.SetHeaders(w)
 		w.WriteHeader(http.StatusCreated)
 		// Body isn't used by CLI, so it isn't set.
 		w.Write([]byte("{}"))
 	})
 
-	err = cmdr.WhitelistAdd("foo", "1.2.3.4,0.0.0.0/0")
+	err = cmdr.AllowlistAdd("foo", "1.2.3.4,0.0.0.0/0")
 	assert.NoErr(t, err)
 
-	assert.Equal(t, testutil.StripProgress(b.String()), "Adding 1.2.3.4,0.0.0.0/0 to foo whitelist...\ndone\n", "output")
+	assert.Equal(t, testutil.StripProgress(b.String()), "Adding 1.2.3.4,0.0.0.0/0 to foo allowlist...\ndone\n", "output")
 }
 
-func TestWhitelistRemove(t *testing.T) {
+func TestAllowlistRemove(t *testing.T) {
 	t.Parallel()
 	cf, server, err := testutil.NewTestServerAndClient()
 	if err != nil {
@@ -68,16 +68,16 @@ func TestWhitelistRemove(t *testing.T) {
 	var b bytes.Buffer
 	cmdr := DryccCmd{WOut: &b, ConfigFile: cf}
 
-	server.Mux.HandleFunc("/v2/apps/foo/whitelist/", func(w http.ResponseWriter, r *http.Request) {
-		testutil.AssertBody(t, api.Whitelist{Addresses: []string{"1.2.3.4"}}, r)
+	server.Mux.HandleFunc("/v2/apps/foo/allowlist/", func(w http.ResponseWriter, r *http.Request) {
+		testutil.AssertBody(t, api.Allowlist{Addresses: []string{"1.2.3.4"}}, r)
 		testutil.SetHeaders(w)
 		w.WriteHeader(http.StatusCreated)
 		// Body isn't used by CLI, so it isn't set.
 		w.Write([]byte("{}"))
 	})
 
-	err = cmdr.WhitelistRemove("foo", "1.2.3.4")
+	err = cmdr.AllowlistRemove("foo", "1.2.3.4")
 	assert.NoErr(t, err)
 
-	assert.Equal(t, testutil.StripProgress(b.String()), "Removing 1.2.3.4 from foo whitelist...\ndone\n", "output")
+	assert.Equal(t, testutil.StripProgress(b.String()), "Removing 1.2.3.4 from foo allowlist...\ndone\n", "output")
 }
diff --git a/codecov.yml b/codecov.yml
index e82645410..663e65970 100644
--- a/codecov.yml
+++ b/codecov.yml
@@ -1,3 +1,3 @@
 codecov:
-  branch: master
+  branch: main
   slug: "drycc/workflow-cli"
diff --git a/drycc.go b/drycc.go
index 4ee522163..69958fccb 100644
--- a/drycc.go
+++ b/drycc.go
@@ -67,7 +67,7 @@ Subcommands, use 'drycc help [subcommand]' to learn more::
   tls           manage TLS settings for applications
   users         manage users
   version       display client version
-  whitelist     manage whitelisted addresses of an application
+  Allowlist     manage allowlisted addresses of an application
   services      manage services for your applications
   timeouts      manage pods termination grace period
   volumes       manage volumes for your applications
@@ -160,8 +160,8 @@ Use 'git push drycc master' to deploy to an application.
 		err = parser.Users(argv, &cmdr)
 	case "version":
 		err = parser.Version(argv, &cmdr)
-	case "whitelist":
-		err = parser.Whitelist(argv, &cmdr)
+	case "allowlist":
+		err = parser.Allowlist(argv, &cmdr)
 	case "volumes":
 		err = parser.Volumes(argv, &cmdr)
 	case "resources":
diff --git a/parser/whitelist.go b/parser/whitelist.go
index 308d0c985..a9735fc19 100644
--- a/parser/whitelist.go
+++ b/parser/whitelist.go
@@ -5,33 +5,33 @@ import (
 	"github.com/drycc/workflow-cli/cmd"
 )
 
-// Whitelist displays all relevant commands for `drycc whitelist`.
-func Whitelist(argv []string, cmdr cmd.Commander) error {
+// Allowlist displays all relevant commands for `drycc allowlist`.
+func Allowlist(argv []string, cmdr cmd.Commander) error {
 	usage := `
-Valid commands for whitelist:
+Valid commands for allowlist:
 
-whitelist:add           adds addresses to the application's whitelist
-whitelist:list          list addresses in the application's whitelist
-whitelist:remove        remove addresses from the application's whitelist
+allowlist:add           adds addresses to the application's allowlist
+allowlist:list          list addresses in the application's allowlist
+allowlist:remove        remove addresses from the application's allowlist
 
 Use 'drycc help [command]' to learn more.
 `
 
 	switch argv[0] {
-	case "whitelist:add":
-		return whitelistAdd(argv, cmdr)
-	case "whitelist:list":
-		return whitelistList(argv, cmdr)
-	case "whitelist:remove":
-		return whitelistRemove(argv, cmdr)
+	case "allowlist:add":
+		return allowlistAdd(argv, cmdr)
+	case "allowlist:list":
+		return allowlistList(argv, cmdr)
+	case "allowlist:remove":
+		return allowlistRemove(argv, cmdr)
 	default:
 		if printHelp(argv, usage) {
 			return nil
 		}
 
-		if argv[0] == "whitelist" {
-			argv[0] = "whitelist:list"
-			return whitelistList(argv, cmdr)
+		if argv[0] == "allowlist" {
+			argv[0] = "allowlist:list"
+			return allowlistList(argv, cmdr)
 		}
 
 		PrintUsage(cmdr)
@@ -39,15 +39,15 @@ Use 'drycc help [command]' to learn more.
 	}
 }
 
-func whitelistAdd(argv []string, cmdr cmd.Commander) error {
+func allowlistAdd(argv []string, cmdr cmd.Commander) error {
 	usage := `
-Adds addresses to an application whitelist.
+Adds addresses to an application allowlist.
 
-Usage: drycc whitelist:add <addresses> [options]
+Usage: drycc allowlist:add <addresses> [options]
 
 Arguments:
   <addresses>
-    comma-delimited list of addresses(using IP or CIDR notation) to be whitelisted for the application, such as '1.2.3.4' or '1.2.3.4,0.0.0.0/0'.
+    comma-delimited list of addresses(using IP or CIDR notation) to be allowlisted for the application, such as '1.2.3.4' or '1.2.3.4,0.0.0.0/0'.
 
 Options:
   -a --app=<app>
@@ -63,14 +63,14 @@ Options:
 	app := safeGetValue(args, "--app")
 	addresses := safeGetValue(args, "<addresses>")
 
-	return cmdr.WhitelistAdd(app, addresses)
+	return cmdr.AllowlistAdd(app, addresses)
 }
 
-func whitelistList(argv []string, cmdr cmd.Commander) error {
+func allowlistList(argv []string, cmdr cmd.Commander) error {
 	usage := `
-Lists whitelisted addresses for an application.
+Lists allowlisted addresses for an application.
 
-Usage: drycc whitelist:list [options]
+Usage: drycc allowlist:list [options]
 
 Options:
   -a --app=<app>
@@ -85,18 +85,18 @@ Options:
 
 	app := safeGetValue(args, "--app")
 
-	return cmdr.WhitelistList(app)
+	return cmdr.AllowlistList(app)
 }
 
-func whitelistRemove(argv []string, cmdr cmd.Commander) error {
+func allowlistRemove(argv []string, cmdr cmd.Commander) error {
 	usage := `
-Removes addresses from an application whitelist.
+Removes addresses from an application allowlist.
 
-Usage: drycc whitelist:remove <addresses> [options]
+Usage: drycc allowlist:remove <addresses> [options]
 
 Arguments:
   <addresses>
-    comma-delimited list of addresses(using IP or CIDR notation) to be whitelisted for the application, such as '1.2.3.4' or "1.2.3.4,0.0.0.0/0".
+    comma-delimited list of addresses(using IP or CIDR notation) to be allowlisted for the application, such as '1.2.3.4' or "1.2.3.4,0.0.0.0/0".
 
 Options:
   -a --app=<app>
@@ -112,5 +112,5 @@ Options:
 	app := safeGetValue(args, "--app")
 	addresses := safeGetValue(args, "<addresses>")
 
-	return cmdr.WhitelistRemove(app, addresses)
+	return cmdr.AllowlistRemove(app, addresses)
 }
diff --git a/parser/whitelist_test.go b/parser/whitelist_test.go
index f807bd724..b74fa28dc 100644
--- a/parser/whitelist_test.go
+++ b/parser/whitelist_test.go
@@ -12,19 +12,19 @@ import (
 // Create fake implementations of each method that return the argument
 // we expect to have called the function (as an error to satisfy the interface).
 
-func (d FakeDryccCmd) WhitelistAdd(string, string) error {
-	return errors.New("whitelist:add")
+func (d FakeDryccCmd) AllowlistAdd(string, string) error {
+	return errors.New("allowlist:add")
 }
 
-func (d FakeDryccCmd) WhitelistList(string) error {
-	return errors.New("whitelist:list")
+func (d FakeDryccCmd) AllowlistList(string) error {
+	return errors.New("allowlist:list")
 }
 
-func (d FakeDryccCmd) WhitelistRemove(string, string) error {
-	return errors.New("whitelist:remove")
+func (d FakeDryccCmd) AllowlistRemove(string, string) error {
+	return errors.New("allowlist:remove")
 }
 
-func TestWhitelist(t *testing.T) {
+func TestAllowlist(t *testing.T) {
 	t.Parallel()
 
 	cf, server, err := testutil.NewTestServerAndClient()
@@ -42,20 +42,20 @@ func TestWhitelist(t *testing.T) {
 		expected string
 	}{
 		{
-			args:     []string{"whitelist:add", "1.2.3.4"},
+			args:     []string{"allowlist:add", "1.2.3.4"},
 			expected: "",
 		},
 		{
-			args:     []string{"whitelist:list"},
+			args:     []string{"allowlist:list"},
 			expected: "",
 		},
 		{
-			args:     []string{"whitelist:remove", "1.2.3.4"},
+			args:     []string{"allowlist:remove", "1.2.3.4"},
 			expected: "",
 		},
 		{
-			args:     []string{"whitelist"},
-			expected: "whitelist:list",
+			args:     []string{"allowlist"},
+			expected: "allowlist:list",
 		},
 	}
 
@@ -68,7 +68,7 @@ func TestWhitelist(t *testing.T) {
 		} else {
 			expected = c.expected
 		}
-		err = Whitelist(c.args, cmdr)
+		err = Allowlist(c.args, cmdr)
 		assert.Err(t, errors.New(expected), err)
 	}
 }
