Skip to content

Commit 10fcffe

Browse files
author
lijianguo
committed
chore(workflow-cli):replace whitelist with allowlist
1 parent 85f5635 commit 10fcffe

8 files changed

Lines changed: 81 additions & 81 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Drycc Client
22

3-
[![Build Status](https://travis-ci.org/drycc/workflow-cli.svg?branch=master)](https://travis-ci.org/drycc/workflow-cli)
3+
[![Build Status](https://travis-ci.org/drycc/workflow-cli.svg?branch=main)](https://travis-ci.org/drycc/workflow-cli)
44
[![Go Report Card](https://goreportcard.com/badge/github.com/drycc/workflow-cli)](https://goreportcard.com/report/github.com/drycc/workflow-cli)
5-
[![codebeat badge](https://codebeat.co/badges/826a57a3-c9a8-4263-ae57-f249d5a3bb79)](https://codebeat.co/projects/github-com-drycc-workflow-cli-master)
6-
[![codecov](https://codecov.io/gh/drycc/workflow-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/drycc/workflow-cli)
5+
[![codebeat badge](https://codebeat.co/badges/b609cb7f-7b42-4214-8787-09298f553176)](https://codebeat.co/projects/github-com-drycc-workflow-cli-main)
6+
[![codecov](https://codecov.io/gh/drycc/workflow-cli/branch/main/graph/badge.svg)](https://codecov.io/gh/drycc/workflow-cli)
77

88
Download Links: https://github.com/drycc/workflow-cli/releases
99

@@ -58,7 +58,7 @@ To learn more about a command run `drycc help <command>`.
5858

5959
## License
6060

61-
see [LICENSE](https://github.com/drycc/workflow-cli/blob/master/LICENSE)
61+
see [LICENSE](https://github.com/drycc/workflow-cli/blob/main/LICENSE)
6262

6363
[k8s-home]: http://kubernetes.io
6464
[install-k8s]: http://kubernetes.io/gettingstarted/

cmd/cmd.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ type Commander interface {
9393
UsersList(results int) error
9494
UsersEnable(string) error
9595
UsersDisable(string) error
96-
WhitelistAdd(string, string) error
97-
WhitelistList(string) error
98-
WhitelistRemove(string, string) error
96+
AllowlistAdd(string, string) error
97+
AllowlistList(string) error
98+
AllowlistRemove(string, string) error
9999
Println(...interface{}) (int, error)
100100
Print(...interface{}) (int, error)
101101
Printf(string, ...interface{}) (int, error)

cmd/whitelist.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,42 @@ package cmd
33
import (
44
"strings"
55

6-
"github.com/drycc/controller-sdk-go/whitelist"
6+
"github.com/drycc/controller-sdk-go/allowlist"
77
)
88

9-
// WhitelistList lists the addresses whitelisted for app
10-
func (d *DryccCmd) WhitelistList(appID string) error {
9+
// Allowlistlist lists the addresses allowlisted for app
10+
func (d *DryccCmd) AllowlistList(appID string) error {
1111
s, appID, err := load(d.ConfigFile, appID)
1212

1313
if err != nil {
1414
return err
1515
}
1616

17-
whitelist, err := whitelist.List(s.Client, appID)
17+
allowlist, err := allowlist.List(s.Client, appID)
1818
if d.checkAPICompatibility(s.Client, err) != nil {
1919
return err
2020
}
2121

22-
d.Printf("=== %s Whitelisted Addresses\n", appID)
22+
d.Printf("=== %s Allowlisted Addresses\n", appID)
2323

24-
for _, ip := range whitelist.Addresses {
24+
for _, ip := range allowlist.Addresses {
2525
d.Println(ip)
2626
}
2727
return nil
2828
}
2929

30-
// WhitelistAdd adds the addresses to the app's Whitelist.
31-
func (d *DryccCmd) WhitelistAdd(appID, IPs string) error {
30+
// AllowlistAdd adds the addresses to the app's allowlist.
31+
func (d *DryccCmd) AllowlistAdd(appID, IPs string) error {
3232
s, appID, err := load(d.ConfigFile, appID)
3333

3434
if err != nil {
3535
return err
3636
}
3737

38-
d.Printf("Adding %s to %s whitelist...\n", IPs, appID)
38+
d.Printf("Adding %s to %s allowlist...\n", IPs, appID)
3939

4040
quit := progress(d.WOut)
41-
_, err = whitelist.Add(s.Client, appID, strings.Split(IPs, ","))
41+
_, err = allowlist.Add(s.Client, appID, strings.Split(IPs, ","))
4242
quit <- true
4343
<-quit
4444
if d.checkAPICompatibility(s.Client, err) != nil {
@@ -49,18 +49,18 @@ func (d *DryccCmd) WhitelistAdd(appID, IPs string) error {
4949
return nil
5050
}
5151

52-
// WhitelistRemove deletes the addresses from the app's Whitelist.
53-
func (d *DryccCmd) WhitelistRemove(appID, IPs string) error {
52+
// AllowlistRemove deletes the addresses from the app's Allowlist.
53+
func (d *DryccCmd) AllowlistRemove(appID, IPs string) error {
5454
s, appID, err := load(d.ConfigFile, appID)
5555

5656
if err != nil {
5757
return err
5858
}
5959

60-
d.Printf("Removing %s from %s whitelist...\n", IPs, appID)
60+
d.Printf("Removing %s from %s allowlist...\n", IPs, appID)
6161

6262
quit := progress(d.WOut)
63-
err = whitelist.Delete(s.Client, appID, strings.Split(IPs, ","))
63+
err = allowlist.Delete(s.Client, appID, strings.Split(IPs, ","))
6464
quit <- true
6565
<-quit
6666
if d.checkAPICompatibility(s.Client, err) != nil {

cmd/whitelist_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/drycc/workflow-cli/pkg/testutil"
1212
)
1313

14-
func TestWhitelistList(t *testing.T) {
14+
func TestAllowlistList(t *testing.T) {
1515
t.Parallel()
1616
cf, server, err := testutil.NewTestServerAndClient()
1717
if err != nil {
@@ -21,20 +21,20 @@ func TestWhitelistList(t *testing.T) {
2121
var b bytes.Buffer
2222
cmdr := DryccCmd{WOut: &b, ConfigFile: cf}
2323

24-
server.Mux.HandleFunc("/v2/apps/foo/whitelist/", func(w http.ResponseWriter, r *http.Request) {
24+
server.Mux.HandleFunc("/v2/apps/foo/allowlist/", func(w http.ResponseWriter, r *http.Request) {
2525
testutil.SetHeaders(w)
2626
fmt.Fprintf(w, `{
2727
"addresses": ["1.2.3.4", "0.0.0.0/0"]
2828
}`)
2929
})
3030

31-
err = cmdr.WhitelistList("foo")
31+
err = cmdr.AllowlistList("foo")
3232
assert.NoErr(t, err)
3333

34-
assert.Equal(t, b.String(), "=== foo Whitelisted Addresses\n1.2.3.4\n0.0.0.0/0\n", "output")
34+
assert.Equal(t, b.String(), "=== foo Allowlisted Addresses\n1.2.3.4\n0.0.0.0/0\n", "output")
3535
}
3636

37-
func TestWhitelistAdd(t *testing.T) {
37+
func TestAllowlistAdd(t *testing.T) {
3838
t.Parallel()
3939
cf, server, err := testutil.NewTestServerAndClient()
4040
if err != nil {
@@ -44,21 +44,21 @@ func TestWhitelistAdd(t *testing.T) {
4444
var b bytes.Buffer
4545
cmdr := DryccCmd{WOut: &b, ConfigFile: cf}
4646

47-
server.Mux.HandleFunc("/v2/apps/foo/whitelist/", func(w http.ResponseWriter, r *http.Request) {
48-
testutil.AssertBody(t, api.Whitelist{Addresses: []string{"1.2.3.4", "0.0.0.0/0"}}, r)
47+
server.Mux.HandleFunc("/v2/apps/foo/allowlist/", func(w http.ResponseWriter, r *http.Request) {
48+
testutil.AssertBody(t, api.Allowlist{Addresses: []string{"1.2.3.4", "0.0.0.0/0"}}, r)
4949
testutil.SetHeaders(w)
5050
w.WriteHeader(http.StatusCreated)
5151
// Body isn't used by CLI, so it isn't set.
5252
w.Write([]byte("{}"))
5353
})
5454

55-
err = cmdr.WhitelistAdd("foo", "1.2.3.4,0.0.0.0/0")
55+
err = cmdr.AllowlistAdd("foo", "1.2.3.4,0.0.0.0/0")
5656
assert.NoErr(t, err)
5757

58-
assert.Equal(t, testutil.StripProgress(b.String()), "Adding 1.2.3.4,0.0.0.0/0 to foo whitelist...\ndone\n", "output")
58+
assert.Equal(t, testutil.StripProgress(b.String()), "Adding 1.2.3.4,0.0.0.0/0 to foo allowlist...\ndone\n", "output")
5959
}
6060

61-
func TestWhitelistRemove(t *testing.T) {
61+
func TestAllowlistRemove(t *testing.T) {
6262
t.Parallel()
6363
cf, server, err := testutil.NewTestServerAndClient()
6464
if err != nil {
@@ -68,16 +68,16 @@ func TestWhitelistRemove(t *testing.T) {
6868
var b bytes.Buffer
6969
cmdr := DryccCmd{WOut: &b, ConfigFile: cf}
7070

71-
server.Mux.HandleFunc("/v2/apps/foo/whitelist/", func(w http.ResponseWriter, r *http.Request) {
72-
testutil.AssertBody(t, api.Whitelist{Addresses: []string{"1.2.3.4"}}, r)
71+
server.Mux.HandleFunc("/v2/apps/foo/allowlist/", func(w http.ResponseWriter, r *http.Request) {
72+
testutil.AssertBody(t, api.Allowlist{Addresses: []string{"1.2.3.4"}}, r)
7373
testutil.SetHeaders(w)
7474
w.WriteHeader(http.StatusCreated)
7575
// Body isn't used by CLI, so it isn't set.
7676
w.Write([]byte("{}"))
7777
})
7878

79-
err = cmdr.WhitelistRemove("foo", "1.2.3.4")
79+
err = cmdr.AllowlistRemove("foo", "1.2.3.4")
8080
assert.NoErr(t, err)
8181

82-
assert.Equal(t, testutil.StripProgress(b.String()), "Removing 1.2.3.4 from foo whitelist...\ndone\n", "output")
82+
assert.Equal(t, testutil.StripProgress(b.String()), "Removing 1.2.3.4 from foo allowlist...\ndone\n", "output")
8383
}

codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
codecov:
2-
branch: master
2+
branch: main
33
slug: "drycc/workflow-cli"

drycc.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Subcommands, use 'drycc help [subcommand]' to learn more::
6767
tls manage TLS settings for applications
6868
users manage users
6969
version display client version
70-
whitelist manage whitelisted addresses of an application
70+
Allowlist manage allowlisted addresses of an application
7171
services manage services for your applications
7272
timeouts manage pods termination grace period
7373
volumes manage volumes for your applications
@@ -160,8 +160,8 @@ Use 'git push drycc master' to deploy to an application.
160160
err = parser.Users(argv, &cmdr)
161161
case "version":
162162
err = parser.Version(argv, &cmdr)
163-
case "whitelist":
164-
err = parser.Whitelist(argv, &cmdr)
163+
case "allowlist":
164+
err = parser.Allowlist(argv, &cmdr)
165165
case "volumes":
166166
err = parser.Volumes(argv, &cmdr)
167167
case "resources":

parser/whitelist.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,49 @@ import (
55
"github.com/drycc/workflow-cli/cmd"
66
)
77

8-
// Whitelist displays all relevant commands for `drycc whitelist`.
9-
func Whitelist(argv []string, cmdr cmd.Commander) error {
8+
// Allowlist displays all relevant commands for `drycc allowlist`.
9+
func Allowlist(argv []string, cmdr cmd.Commander) error {
1010
usage := `
11-
Valid commands for whitelist:
11+
Valid commands for allowlist:
1212
13-
whitelist:add adds addresses to the application's whitelist
14-
whitelist:list list addresses in the application's whitelist
15-
whitelist:remove remove addresses from the application's whitelist
13+
allowlist:add adds addresses to the application's allowlist
14+
allowlist:list list addresses in the application's allowlist
15+
allowlist:remove remove addresses from the application's allowlist
1616
1717
Use 'drycc help [command]' to learn more.
1818
`
1919

2020
switch argv[0] {
21-
case "whitelist:add":
22-
return whitelistAdd(argv, cmdr)
23-
case "whitelist:list":
24-
return whitelistList(argv, cmdr)
25-
case "whitelist:remove":
26-
return whitelistRemove(argv, cmdr)
21+
case "allowlist:add":
22+
return allowlistAdd(argv, cmdr)
23+
case "allowlist:list":
24+
return allowlistList(argv, cmdr)
25+
case "allowlist:remove":
26+
return allowlistRemove(argv, cmdr)
2727
default:
2828
if printHelp(argv, usage) {
2929
return nil
3030
}
3131

32-
if argv[0] == "whitelist" {
33-
argv[0] = "whitelist:list"
34-
return whitelistList(argv, cmdr)
32+
if argv[0] == "allowlist" {
33+
argv[0] = "allowlist:list"
34+
return allowlistList(argv, cmdr)
3535
}
3636

3737
PrintUsage(cmdr)
3838
return nil
3939
}
4040
}
4141

42-
func whitelistAdd(argv []string, cmdr cmd.Commander) error {
42+
func allowlistAdd(argv []string, cmdr cmd.Commander) error {
4343
usage := `
44-
Adds addresses to an application whitelist.
44+
Adds addresses to an application allowlist.
4545
46-
Usage: drycc whitelist:add <addresses> [options]
46+
Usage: drycc allowlist:add <addresses> [options]
4747
4848
Arguments:
4949
<addresses>
50-
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'.
50+
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'.
5151
5252
Options:
5353
-a --app=<app>
@@ -63,14 +63,14 @@ Options:
6363
app := safeGetValue(args, "--app")
6464
addresses := safeGetValue(args, "<addresses>")
6565

66-
return cmdr.WhitelistAdd(app, addresses)
66+
return cmdr.AllowlistAdd(app, addresses)
6767
}
6868

69-
func whitelistList(argv []string, cmdr cmd.Commander) error {
69+
func allowlistList(argv []string, cmdr cmd.Commander) error {
7070
usage := `
71-
Lists whitelisted addresses for an application.
71+
Lists allowlisted addresses for an application.
7272
73-
Usage: drycc whitelist:list [options]
73+
Usage: drycc allowlist:list [options]
7474
7575
Options:
7676
-a --app=<app>
@@ -85,18 +85,18 @@ Options:
8585

8686
app := safeGetValue(args, "--app")
8787

88-
return cmdr.WhitelistList(app)
88+
return cmdr.AllowlistList(app)
8989
}
9090

91-
func whitelistRemove(argv []string, cmdr cmd.Commander) error {
91+
func allowlistRemove(argv []string, cmdr cmd.Commander) error {
9292
usage := `
93-
Removes addresses from an application whitelist.
93+
Removes addresses from an application allowlist.
9494
95-
Usage: drycc whitelist:remove <addresses> [options]
95+
Usage: drycc allowlist:remove <addresses> [options]
9696
9797
Arguments:
9898
<addresses>
99-
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".
99+
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".
100100
101101
Options:
102102
-a --app=<app>
@@ -112,5 +112,5 @@ Options:
112112
app := safeGetValue(args, "--app")
113113
addresses := safeGetValue(args, "<addresses>")
114114

115-
return cmdr.WhitelistRemove(app, addresses)
115+
return cmdr.AllowlistRemove(app, addresses)
116116
}

parser/whitelist_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ import (
1212
// Create fake implementations of each method that return the argument
1313
// we expect to have called the function (as an error to satisfy the interface).
1414

15-
func (d FakeDryccCmd) WhitelistAdd(string, string) error {
16-
return errors.New("whitelist:add")
15+
func (d FakeDryccCmd) AllowlistAdd(string, string) error {
16+
return errors.New("allowlist:add")
1717
}
1818

19-
func (d FakeDryccCmd) WhitelistList(string) error {
20-
return errors.New("whitelist:list")
19+
func (d FakeDryccCmd) AllowlistList(string) error {
20+
return errors.New("allowlist:list")
2121
}
2222

23-
func (d FakeDryccCmd) WhitelistRemove(string, string) error {
24-
return errors.New("whitelist:remove")
23+
func (d FakeDryccCmd) AllowlistRemove(string, string) error {
24+
return errors.New("allowlist:remove")
2525
}
2626

27-
func TestWhitelist(t *testing.T) {
27+
func TestAllowlist(t *testing.T) {
2828
t.Parallel()
2929

3030
cf, server, err := testutil.NewTestServerAndClient()
@@ -42,20 +42,20 @@ func TestWhitelist(t *testing.T) {
4242
expected string
4343
}{
4444
{
45-
args: []string{"whitelist:add", "1.2.3.4"},
45+
args: []string{"allowlist:add", "1.2.3.4"},
4646
expected: "",
4747
},
4848
{
49-
args: []string{"whitelist:list"},
49+
args: []string{"allowlist:list"},
5050
expected: "",
5151
},
5252
{
53-
args: []string{"whitelist:remove", "1.2.3.4"},
53+
args: []string{"allowlist:remove", "1.2.3.4"},
5454
expected: "",
5555
},
5656
{
57-
args: []string{"whitelist"},
58-
expected: "whitelist:list",
57+
args: []string{"allowlist"},
58+
expected: "allowlist:list",
5959
},
6060
}
6161

@@ -68,7 +68,7 @@ func TestWhitelist(t *testing.T) {
6868
} else {
6969
expected = c.expected
7070
}
71-
err = Whitelist(c.args, cmdr)
71+
err = Allowlist(c.args, cmdr)
7272
assert.Err(t, errors.New(expected), err)
7373
}
7474
}

0 commit comments

Comments
 (0)