Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #31 from KusionStack/fix-npe-for-cdn-source
Browse files Browse the repository at this point in the history
fix: npe problem in cdn source and refine docs
  • Loading branch information
elliotxx committed Jun 17, 2022
2 parents 98bd07f + 23534c1 commit 97f43ad
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 23 deletions.
34 changes: 23 additions & 11 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,24 @@

### Homebrew

`KusionStack/tap` 有 MacOS 和 GNU/Linux 的预编译二进制版本可用
`KusionStack/tap` 有 MacOS 和 GNU/Linux 的预编译二进制版本可用

第一次安装:
```
brew install KusionStack/tap/kusionup
brew install KusionStack/tap/kusionup && kusionup init
```

升级:
```
brew upgrade KusionStack/tap/kusionup
```

### 从源码构建

使用 Go 1.17+ 版本,你可以通过 `go install` 直接从源码安装 `kusionup`

```
go install github.com/KusionStack/kusionup/cmd@latest
go install github.com/KusionStack/kusionup/cmd@latest && kusionup init
```

### Docker
Expand All @@ -58,7 +64,15 @@ docker pull kusionstack/kusionup:latest
## ⚡ 使用

```
$ kusionup install
$ kusionup init # Need to run at first execution
$ kusionup ls-ver # View all installable kusion versions
github@latest
github@v0.4.3
cdn@latest
cdn@v0.4.3
$ kusionup install cdn@latest # Install the specified kusion version
Downloaded 0.0% ( 2426 / 139988826 bytes) ...
Downloaded 11.4% ( 16003466 / 139988826 bytes) ...
Downloaded 21.0% ( 29433014 / 139988826 bytes) ...
Expand All @@ -70,16 +84,14 @@ Downloaded 71.2% ( 99667706 / 139988826 bytes) ...
Downloaded 81.5% (114078806 / 139988826 bytes) ...
Downloaded 91.5% (128134166 / 139988826 bytes) ...
Downloaded 100.0% (139988826 / 139988826 bytes)
INFO[0053] Unpacking ~/.kusionup/kusion-open@latest/kusion-darwin.tgz ...
INFO[0059] Success: latest downloaded in ~/.kusionup/kusion-open@latest
INFO[0059] Default Kusion is set to 'latest'
INFO[0053] Unpacking ~/.kusionup/kusion-cdn@latest/kusion-darwin.tgz ...
INFO[0059] Success: latest downloaded in ~/.kusionup/kusion-cdn@latest
INFO[0059] Default Kusion is set to 'cdn@latest'
$ kusionup show
$ kusionup show # View all installed kusion versions
| VERSION | ACTIVE |
|---------------|--------|
| latest | * |
$ kusion version
| cdn@latest | * |
```

详情请参考[文档](https://kusionstack.io/docs/user_docs/getting-started/install/kusionup)
Expand Down
34 changes: 23 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,24 @@ To get the binary just download the latest release for your OS/Arch from the [re

### Homebrew

The `KusionStack/tap` has macOS and GNU/Linux pre-built binaries available:
The `KusionStack/tap` has macOS and GNU/Linux pre-built binaries available.

First installation:
```
brew install KusionStack/tap/kusionup
brew install KusionStack/tap/kusionup && kusionup init
```

Upgrade:
```
brew upgrade KusionStack/tap/kusionup
```

### Build from Source

Starting with Go 1.17, you can install `kusionup` from source using go install:

```
go install github.com/KusionStack/kusionup/cmd@latest
go install github.com/KusionStack/kusionup/cmd@latest && kusionup init
```

### Docker
Expand All @@ -58,7 +64,15 @@ docker pull kusionstack/kusionup:latest
## ⚡ Usage

```
$ kusionup install
$ kusionup init # Need to run at first execution
$ kusionup ls-ver # View all installable kusion versions
github@latest
github@v0.4.3
cdn@latest
cdn@v0.4.3
$ kusionup install cdn@latest # Install the specified kusion version
Downloaded 0.0% ( 2426 / 139988826 bytes) ...
Downloaded 11.4% ( 16003466 / 139988826 bytes) ...
Downloaded 21.0% ( 29433014 / 139988826 bytes) ...
Expand All @@ -70,16 +84,14 @@ Downloaded 71.2% ( 99667706 / 139988826 bytes) ...
Downloaded 81.5% (114078806 / 139988826 bytes) ...
Downloaded 91.5% (128134166 / 139988826 bytes) ...
Downloaded 100.0% (139988826 / 139988826 bytes)
INFO[0053] Unpacking ~/.kusionup/kusion-open@latest/kusion-darwin.tgz ...
INFO[0059] Success: latest downloaded in ~/.kusionup/kusion-open@latest
INFO[0059] Default Kusion is set to 'open@latest'
INFO[0053] Unpacking ~/.kusionup/kusion-cdn@latest/kusion-darwin.tgz ...
INFO[0059] Success: latest downloaded in ~/.kusionup/kusion-cdn@latest
INFO[0059] Default Kusion is set to 'cdn@latest'
$ kusionup show
$ kusionup show # View all installed kusion versions
| VERSION | ACTIVE |
|---------------|--------|
| latest | * |
$ kusion version
| cdn@latest | * |
```

For details, please refer to the [documentation](https://kusionstack.io/docs/user_docs/getting-started/install/kusionup)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sources/cdn/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (s *releaseSource) GetVersions() []string {

func (s *releaseSource) GetDownloadURL(ver string) (string, error) {
vers := s.GetVersions()
if ver == "latest" && len(vers) > 0 {
if ver == "latest" && len(vers) > 1 {
return getArchiveDownloadURL(vers[1])
}

Expand Down

0 comments on commit 97f43ad

Please sign in to comment.