Skip to content

Commit abf5e81

Browse files
authored
Merge branch 'master' into vpc
2 parents a0f837d + e70bc4c commit abf5e81

36 files changed

+259
-144
lines changed

.appveyor.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ clone_folder: C:\Users\appveyor\go\src\github.com\aliyun\aliyun-cli
77
# scripts that run after cloning repository
88
install:
99
# by default, all script lines are interpreted as batch
10-
- cmd: git clone -q --branch=master https://github.com/aliyun/aliyun-openapi-meta.git C:\Users\appveyor\go\src\github.com\aliyun\aliyun-openapi-meta
10+
- cmd: git submodule update --init --recursive
1111
- cmd: set path=%path%;C:\Users\appveyor\go\bin
12-
- cmd: set VERSION=3.0.81
12+
- cmd: set VERSION=3.0.85
1313
- cmd: go get -u github.com/shuLhan/go-bindata/...
14-
- cmd: go-bindata -o resource/metas.go -pkg resource -prefix ../aliyun-openapi-meta ../aliyun-openapi-meta/...
14+
- cmd: go-bindata -o resource/metas.go -pkg resource ./aliyun-openapi-meta/...
1515
- cmd: go build -ldflags "-X 'github.com/aliyun/aliyun-cli/cli.Version=%VERSION%'" -o C:\Users\appveyor\go\bin\aliyun.exe main/main.go
1616

1717
# build platform, i.e. x86, x64, Any CPU. This setting is optional.
@@ -28,4 +28,3 @@ test_script:
2828
$client.DownloadFile('https://github.com/stedolan/jq/releases/download/jq-1.6/jq-win64.exe', 'C:/go/bin/jq.exe')
2929
3030
if (-not $env:ACCESS_KEY_ID.length -eq 0 -and -not $env:ACCESS_KEY_SECRET.length -eq 0){./integration/ecs_test.PS1}
31-

.github/workflows/go.yml

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ jobs:
1010

1111
build:
1212
runs-on: ubuntu-latest
13+
env:
14+
ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }}
15+
ACCESS_KEY_SECRET: ${{ secrets.ACCESS_KEY_SECRET }}
16+
REGION_ID: ${{ secrets.REGION_ID }}
1317
steps:
1418
- uses: actions/checkout@v2
1519
# fetch submodule for aliyun-openapi-meta

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ before_install:
1313
- sudo apt-get install -y jq
1414

1515
install:
16+
- git submodule update --init --recursive
1617
- make build
1718
- sudo cp out/aliyun /usr/local/bin
1819

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
### Master
44

5+
### 3.0.85
6+
7+
- update: meta data
8+
9+
### 3.0.84
10+
11+
- update: meta data
12+
13+
### 3.0.83
14+
15+
- update: meta data
16+
17+
### 3.0.82
18+
19+
- update: meta data
20+
521
### 3.0.81
622

723
- update: meta data

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export VERSION=3.0.81
1+
export VERSION=3.0.85
22
export RELEASE_PATH="releases/aliyun-cli-${VERSION}"
33

44
all: build

README-CN.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ CLI 版本更改说明请参考 [CHANGELOG](./CHANGELOG.md)
4343

4444
阿里云CLI工具下载、解压后即可使用,支持Mac, Linux, Windows平台(x64版本)。您可以将解压的`aliyun`可执行文件移至`/usr/local/bin`目录下,或添加到`$PATH`中。
4545

46-
下载链接如下 (3.0.81):
46+
下载链接如下 (3.0.85):
4747

48-
- [Mac](https://aliyuncli.alicdn.com/aliyun-cli-macosx-3.0.81-amd64.tgz)
49-
- [Linux](https://aliyuncli.alicdn.com/aliyun-cli-linux-3.0.81-amd64.tgz)
50-
- [Windows (64 bit)](https://aliyuncli.alicdn.com/aliyun-cli-windows-3.0.81-amd64.zip)
48+
- [Mac](https://aliyuncli.alicdn.com/aliyun-cli-macosx-3.0.85-amd64.tgz)
49+
- [Linux](https://aliyuncli.alicdn.com/aliyun-cli-linux-3.0.85-amd64.tgz)
50+
- [Windows (64 bit)](https://aliyuncli.alicdn.com/aliyun-cli-windows-3.0.85-amd64.zip)
5151

5252
- **使用brew**
5353

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ The release notes for the CLI can be found in the [CHANGELOG](./CHANGELOG.md)
4141

4242
Download the installer, then extract the installer. You can move the extracted `aliyun` executable file to the `/usr/local/bin` directory or add it to the `$PATH`.
4343

44-
Download link: (3.0.81)
44+
Download link: (3.0.85)
4545

46-
- [Mac](https://aliyuncli.alicdn.com/aliyun-cli-macosx-3.0.81-amd64.tgz)
47-
- [Linux](https://aliyuncli.alicdn.com/aliyun-cli-linux-3.0.81-amd64.tgz)
48-
- [Windows (64 bit)](https://aliyuncli.alicdn.com/aliyun-cli-windows-3.0.81-amd64.zip)
46+
- [Mac](https://aliyuncli.alicdn.com/aliyun-cli-macosx-3.0.85-amd64.tgz)
47+
- [Linux](https://aliyuncli.alicdn.com/aliyun-cli-linux-3.0.85-amd64.tgz)
48+
- [Windows (64 bit)](https://aliyuncli.alicdn.com/aliyun-cli-windows-3.0.85-amd64.zip)
4949

5050
- **Use brew**
5151
If you have installed `brew` in your computer, you can use it to install Alibaba Cloud CLI as following:

aliyun-openapi-meta

Submodule aliyun-openapi-meta updated 188 files

cli/command.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,14 @@ func (c *Command) executeInner(ctx *Context, args []string) error {
230230
}
231231

232232
func (c *Command) processError(ctx *Context, err error) {
233-
Errorf(ctx.Writer(), "ERROR: %s\n", err.Error())
233+
Errorf(ctx.Stderr(), "ERROR: %s\n", err.Error())
234234
if e, ok := err.(SuggestibleError); ok {
235235
PrintSuggestions(ctx, i18n.GetLanguage(), e.GetSuggestions())
236236
Exit(2)
237237
return
238238
}
239239
if e, ok := err.(ErrorWithTip); ok {
240-
Noticef(ctx.Writer(), "\n%s\n", e.GetTip(i18n.GetLanguage()))
240+
Noticef(ctx.Stderr(), "\n%s\n", e.GetTip(i18n.GetLanguage()))
241241
Exit(3)
242242
return
243243
}

cli/command_help.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ func (c *Command) PrintFlags(ctx *Context) {
7777
}
7878

7979
func (c *Command) PrintFailed(ctx *Context, err error, suggestion string) {
80-
Errorf(ctx.Writer(), "ERROR: %v\n", err)
81-
Printf(ctx.Writer(), "%s\n", suggestion)
80+
Errorf(ctx.Stderr(), "ERROR: %v\n", err)
81+
Printf(ctx.Stderr(), "%s\n", suggestion)
8282
}
8383

8484
func (c *Command) PrintTail(ctx *Context) {

cli/command_help_test.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import (
2424

2525
func TestCmdPrint(t *testing.T) {
2626
w := new(bytes.Buffer)
27-
ctx := NewCommandContext(w)
27+
stderr := new(bytes.Buffer)
28+
ctx := NewCommandContext(w, stderr)
2829
c := &Command{
2930
Name: "aliyun",
3031
EnableUnknownFlag: true,
@@ -44,19 +45,23 @@ func TestCmdPrint(t *testing.T) {
4445

4546
//PrintUsage
4647
w.Reset()
48+
stderr.Reset()
4749
c.PrintUsage(ctx)
4850
assert.Equal(t, "\nUsage:\n aliyun [subcmd]\n", w.String())
4951
w.Reset()
52+
stderr.Reset()
5053
c.Usage = ""
5154
assert.Empty(t, w.String())
5255

5356
//PrintSample
5457
w.Reset()
58+
stderr.Reset()
5559
c.PrintSample(ctx)
5660
assert.Equal(t, "\nSample:\n aliyun oss\n", w.String())
5761

5862
//PrintSubCommands
5963
w.Reset()
64+
stderr.Reset()
6065
subcmd := &Command{
6166
Name: "oss",
6267
SuggestDistance: 2,
@@ -72,24 +77,29 @@ func TestCmdPrint(t *testing.T) {
7277

7378
//PrintFlags
7479
w.Reset()
80+
stderr.Reset()
7581
c.PrintFlags(ctx)
7682
assert.Empty(t, w.String())
7783
c.flags.flags = []*Flag{&Flag{Name: "output", Shorthand: 'o'}}
7884
w.Reset()
85+
stderr.Reset()
7986
c.PrintFlags(ctx)
8087
assert.Equal(t, "\nFlags:\n", w.String())
8188
w.Reset()
89+
stderr.Reset()
8290
ctx.flags.flags = []*Flag{&Flag{Name: "output", Shorthand: 'o', Short: i18n.T("o test", "")}, &Flag{Name: "filter", Short: i18n.T("", "")}, &Flag{Name: "hidden", Hidden: true}}
8391
c.PrintFlags(ctx)
8492
assert.Equal(t, "\nFlags:\n --output,-o o test\n --filter \n", w.String())
8593

8694
//PrintFailed
8795
w.Reset()
96+
stderr.Reset()
8897
c.PrintFailed(ctx, errors.New("you failed"), "come on again")
89-
assert.Equal(t, "\x1b[1;31mERROR: you failed\n\x1b[0mcome on again\n", w.String())
98+
assert.Equal(t, "\x1b[1;31mERROR: you failed\n\x1b[0mcome on again\n", stderr.String())
9099

91100
//PrintTail
92101
w.Reset()
102+
stderr.Reset()
93103
c.PrintTail(ctx)
94104
assert.Equal(t, "\nUse `aliyun --help` for more information.\n", w.String())
95105
}

cli/command_test.go

+12-7
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ func TestCommand(t *testing.T) {
8282

8383
//ExecuteComplete
8484
w := new(bytes.Buffer)
85-
ctx := NewCommandContext(w)
85+
stderr := new(bytes.Buffer)
86+
ctx := NewCommandContext(w, stderr)
8687
ctx.completion = new(Completion)
8788
ctx.completion.Current = "--f"
8889
ctx.flags.flags = append(ctx.flags.flags, []*Flag{
@@ -192,7 +193,8 @@ func TestGetSubCommand(t *testing.T) {
192193

193194
func TestExecute(t *testing.T) {
194195
buf := new(bytes.Buffer)
195-
ctx := NewCommandContext(buf)
196+
buf2 := new(bytes.Buffer)
197+
ctx := NewCommandContext(buf, buf2)
196198

197199
cmd := newAliyunCmd()
198200
subCmd := newTestCmd()
@@ -204,25 +206,27 @@ func TestExecute(t *testing.T) {
204206
DisableExitCode()
205207
defer EnableExitCode()
206208
cmd.Execute(ctx, []string{})
207-
assert.Equal(t, "\x1b[1;31mERROR: 'test' is not a vaild command\n\x1b[0m", buf.String())
209+
assert.Equal(t, "\x1b[1;31mERROR: 'test' is not a vaild command\n\x1b[0m", buf2.String())
208210
}
209211

210212
func TestProcessError(t *testing.T) {
211213
DisableExitCode()
212214
defer EnableExitCode()
213215
cmd := newAliyunCmd()
214216
buf := new(bytes.Buffer)
215-
ctx := NewCommandContext(buf)
217+
buf2 := new(bytes.Buffer)
218+
ctx := NewCommandContext(buf, buf2)
216219
e := errors.New("test error tip")
217220
err := NewErrorWithTip(e, "")
218221
cmd.processError(ctx, err)
219-
assert.Equal(t, "\x1b[1;31mERROR: test error tip\n\x1b[0m\x1b[1;33m\n\n\x1b[0m", buf.String())
222+
assert.Equal(t, "\x1b[1;31mERROR: test error tip\n\x1b[0m\x1b[1;33m\n\n\x1b[0m", buf2.String())
220223
}
221224

222225
func TestExecuteHelp(t *testing.T) {
223226
cmd := newAliyunCmd()
224227
buf := new(bytes.Buffer)
225-
ctx := NewCommandContext(buf)
228+
buf2 := new(bytes.Buffer)
229+
ctx := NewCommandContext(buf, buf2)
226230
cmd.Help = func(ctx *Context, args []string) error {
227231
fmt.Fprint(ctx.Writer(), "test execute help")
228232
return nil
@@ -231,11 +235,12 @@ func TestExecuteHelp(t *testing.T) {
231235
assert.Equal(t, "test execute help", buf.String())
232236

233237
buf.Reset()
238+
buf2.Reset()
234239
DisableExitCode()
235240
defer EnableExitCode()
236241
cmd.Help = func(ctx *Context, args []string) error {
237242
return errors.New("test help error")
238243
}
239244
cmd.executeHelp(ctx, nil)
240-
assert.Equal(t, "\x1b[1;31mERROR: test help error\n\x1b[0m", buf.String())
245+
assert.Equal(t, "\x1b[1;31mERROR: test help error\n\x1b[0m", buf2.String())
241246
}

cli/completion_installer.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ package cli
1515

1616
import (
1717
"fmt"
18-
"io"
1918

2019
"github.com/aliyun/aliyun-cli/i18n"
2120
)
@@ -44,9 +43,9 @@ func NewAutoCompleteCommand() *Command {
4443
// fmt.Printf("zshInstaller: %s\n", f)
4544
//}
4645
if uninstallFlag.IsAssigned() {
47-
uninstallCompletion(ctx.Writer(), "aliyun")
46+
uninstallCompletion(ctx, "aliyun")
4847
} else {
49-
installCompletion(ctx.Writer(), "aliyun")
48+
installCompletion(ctx, "aliyun")
5049
}
5150
return nil
5251
},
@@ -55,32 +54,32 @@ func NewAutoCompleteCommand() *Command {
5554
return cmd
5655
}
5756

58-
func installCompletion(w io.Writer, cmd string) {
57+
func installCompletion(ctx *Context, cmd string) {
5958
bin, err := getBinaryPath()
6059
if err != nil {
61-
Errorf(w, "can't get binary path %s", err)
60+
Errorf(ctx.Stderr(), "can't get binary path %s", err)
6261
return
6362
}
6463

6564
for _, i := range completionInstallers() {
6665
err := i.Install(cmd, bin)
6766
if err != nil {
68-
Errorf(w, "install completion failed for %s %s\n", bin, err)
67+
Errorf(ctx.Stderr(), "install completion failed for %s %s\n", bin, err)
6968
}
7069
}
7170
}
7271

73-
func uninstallCompletion(w io.Writer, cmd string) {
72+
func uninstallCompletion(ctx *Context, cmd string) {
7473
bin, err := hookGetBinaryPath(getBinaryPath)()
7574
if err != nil {
76-
Errorf(w, "can't get binary path %s", err)
75+
Errorf(ctx.Stderr(), "can't get binary path %s", err)
7776
return
7877
}
7978

8079
for _, i := range completionInstallers() {
8180
err := i.Uninstall(cmd, bin)
8281
if err != nil {
83-
Errorf(w, "uninstall %s failed\n", err)
82+
Errorf(ctx.Stderr(), "uninstall %s failed\n", err)
8483
}
8584
}
8685
}

cli/completion_installer_test.go

+11-7
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ func TestCompletionInstallers(t *testing.T) {
101101
}
102102
func TestCompletion(t *testing.T) {
103103
w := new(bytes.Buffer)
104-
installCompletion(w, "is this a cmd?")
104+
stderr := new(bytes.Buffer)
105+
ctx := NewCommandContext(w, stderr)
106+
installCompletion(ctx, "is this a cmd?")
105107
assert.Empty(t, w.String())
106108
}
107109

@@ -114,9 +116,9 @@ func TestNewAutoCompleteCommand(t *testing.T) {
114116
Usage: "auto-completion [--uninstall]",
115117
Run: func(ctx *Context, args []string) error {
116118
if uninstallFlag.IsAssigned() {
117-
uninstallCompletion(ctx.Writer(), "aliyun")
119+
uninstallCompletion(ctx, "aliyun")
118120
} else {
119-
installCompletion(ctx.Writer(), "aliyun")
121+
installCompletion(ctx, "aliyun")
120122
}
121123
return nil
122124
},
@@ -125,14 +127,14 @@ func TestNewAutoCompleteCommand(t *testing.T) {
125127
cmd := NewAutoCompleteCommand()
126128
assert.ObjectsAreEqualValues(excmd, cmd)
127129
w := new(bytes.Buffer)
128-
ctx := NewCommandContext(w)
130+
stderr := new(bytes.Buffer)
131+
ctx := NewCommandContext(w, stderr)
129132
err := cmd.Run(ctx, []string{})
130133
assert.Nil(t, err)
131134
assert.Empty(t, w.String())
132135
}
133136

134137
func TestUninstallCompletion(t *testing.T) {
135-
136138
orighookGetBinaryPath := hookGetBinaryPath
137139
defer func() {
138140
hookGetBinaryPath = orighookGetBinaryPath
@@ -144,6 +146,8 @@ func TestUninstallCompletion(t *testing.T) {
144146
}
145147

146148
w := new(bytes.Buffer)
147-
uninstallCompletion(w, "aliyun")
148-
assert.Equal(t, "\x1b[1;31mcan't get binary path path error\x1b[0m", w.String())
149+
stderr := new(bytes.Buffer)
150+
ctx := NewCommandContext(w, stderr)
151+
uninstallCompletion(ctx, "aliyun")
152+
assert.Equal(t, "\x1b[1;31mcan't get binary path path error\x1b[0m", stderr.String())
149153
}

0 commit comments

Comments
 (0)