Skip to content
This repository was archived by the owner on Dec 18, 2025. It is now read-only.

Commit b64572c

Browse files
author
Ryan SVIHLA
authored
Cli rename (#29)
* successfully renamed * adding dockerfile for deployment options * adding github package * added install scripts
1 parent 12a4732 commit b64572c

19 files changed

+599
-207
lines changed

.github/workflows/docker.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Astra Cli docker image
2+
3+
on:
4+
push:
5+
# Publish `master` as Docker `latest` image.
6+
branches:
7+
- main
8+
- seed
9+
10+
# Publish `v1.2.3` tags as releases.
11+
tags:
12+
- v*
13+
14+
# Run tests for any PRs.
15+
pull_request:
16+
17+
env:
18+
IMAGE_NAME: astra-cli
19+
20+
jobs:
21+
# Push image to GitHub Packages.
22+
# See also https://docs.docker.com/docker-hub/builds/
23+
push:
24+
runs-on: ubuntu-latest
25+
permissions:
26+
packages: write
27+
contents: read
28+
29+
steps:
30+
- uses: actions/checkout@v2
31+
32+
- name: Build image
33+
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
34+
35+
- name: Log in to registry
36+
# This is where you will update the PAT to GITHUB_TOKEN
37+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
38+
39+
- name: Push image
40+
run: |
41+
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
42+
43+
# Change all uppercase to lowercase
44+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
45+
# Strip git ref prefix from version
46+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
47+
# Strip "v" prefix from tag name
48+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
49+
# Use Docker `latest` tag convention
50+
[ "$VERSION" == "main" ] && VERSION=latest
51+
echo IMAGE_ID=$IMAGE_ID
52+
echo VERSION=$VERSION
53+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
54+
docker push $IMAGE_ID:$VERSION

.golangci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ linters:
1717
- gocyclo
1818
- gofmt
1919
- goimports
20-
- golint
20+
- revive
2121
- gomnd
2222
- goprintffuncname
2323
- gosimple
@@ -27,7 +27,7 @@ linters:
2727
- nakedret
2828
- nolintlint
2929
- rowserrcheck
30-
- scopelint
30+
- exportloopref
3131
- staticcheck
3232
- structcheck
3333
- typecheck

.goreleaser.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ before:
55
# You may remove this if you don't use go modules.
66
- go mod tidy
77
builds:
8-
- id: astra-cli
8+
- id: astra
99
goos:
1010
- windows
1111
- linux
1212
goarch:
1313
- amd64
1414
- arm64
15-
- id: astra-cli-osx-amd
16-
binary: astra-cli
15+
- id: astra-osx-amd
16+
binary: astra
1717
goos:
1818
- darwin
1919
goarch:
2020
- amd64
2121
hooks:
2222
post: gon gon_osx_darwin_amd64.hcl
23-
- id: astra-cli-osx-arm
24-
binary: astra-cli
23+
- id: astra-osx-arm
24+
binary: astra
2525
goos:
2626
- darwin
2727
goarch:

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM golang:1.17.3-alpine as BUILD
2+
3+
COPY / /astra
4+
WORKDIR /astra
5+
6+
RUN ./script/build
7+
8+
FROM alpine:latest
9+
RUN apk --no-cache add ca-certificates
10+
WORKDIR /root/
11+
COPY --from=0 /astra/bin/astra /astra

README.md

Lines changed: 38 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ Apache 2.0 licensed Astra Cloud Management CLI
1212

1313
Ready for production
1414

15+
## How to install - install script
16+
17+
* /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/rsds143/astra-cli/main/script/install-astra.sh)"
18+
* astra login
19+
20+
## How to install - docker
21+
22+
Instead of downloading the binary this trusts that you have docker installed
23+
24+
* make sure docker is installed
25+
* /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/rsds143/astra-cli/main/script/install-astra-docker.sh)"
26+
* astra.sh login
27+
1528
## How to install - Homebrew for Mac and Linux
1629

1730
* [install homebrew](https://brew.sh/) if you have not
@@ -22,13 +35,13 @@ Ready for production
2235
* download a [release](https://github.com/rsds143/astra-cli/releases)
2336
* tar zxvf <download>
2437
* cd <extracted folder>
25-
* ./astra-cli
38+
* ./astra
2639

2740
## How to install - From Source
2841

29-
* Install [Go 1.16](https://golang.org/dl/)
42+
* Install [Go 1.17](https://golang.org/dl/)
3043
* run `git clone git@github.com:rsds143/astra-cli.git`
31-
* run `./scripts/build` or `go build -o ./bin/astra-cli .`
44+
* run `./scripts/build` or `go build -o ./bin/astra .`
3245

3346
## How to use
3447

@@ -40,58 +53,51 @@ Ready for production
4053
After creating a token with rights to use the devops api
4154

4255
```
43-
./bin/astra-cli login --token "changed"
56+
astra login --token "changed"
4457
Login information saved
4558
```
4659
### login service account
4760

4861
After creating a service account on the Astra page
4962

5063
```
51-
./bin/astra-cli login --id "changed" --name "changed" --secret "changed"
64+
astra login --id "changed" --name "changed" --secret "changed"
5265
Login information saved
5366
```
5467

5568
## login service account with json
5669

5770
```
58-
./bin/astra-cli login --json '{"clientId":"changed","clientName":"change@me.com","clientSecret":"changed"}'
71+
astra login --json '{"clientId":"changed","clientName":"change@me.com","clientSecret":"changed"}'
5972
Login information saved
6073
6174
```
6275

6376
### creating database
6477

6578
```
66-
./bin/astra-cli db create -v --keyspace myks --name mydb
67-
2021/02/24 18:23:24 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state PENDING but expected ACTIVE trying again 19 more times
68-
2021/02/24 18:23:29 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state PENDING but expected ACTIVE trying again 18 more times
69-
2021/02/24 18:23:35 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state PENDING but expected ACTIVE trying again 17 more times
70-
2021/02/24 18:23:40 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state PENDING but expected ACTIVE trying again 16 more times
71-
2021/02/24 18:23:45 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state PENDING but expected ACTIVE trying again 15 more times
72-
2021/02/24 18:23:50 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state PENDING but expected ACTIVE trying again 14 more times
73-
2021/02/24 18:23:55 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state PENDING but expected ACTIVE trying again 13 more times
74-
2021/02/24 18:24:00 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state PENDING but expected ACTIVE trying again 12 more times
79+
astra db create -v --keyspace myks --name mydb
80+
............
7581
database 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b created
7682
```
7783

7884
### get secure connection bundle
7985

8086
```
81-
./bin/astra-cli db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -d external -l external.zip
87+
astra db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -d external -l external.zip
8288
file external.zip saved 12072 bytes written
83-
./bin/astra-cli db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -d internal -l internal.zip
89+
astra db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -d internal -l internal.zip
8490
file internal.zip saved 12066 bytes written
85-
./bin/astra-cli db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -d proxy-internal -l proxy-internal.zip
91+
astra db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -d proxy-internal -l proxy-internal.zip
8692
file proxy-internal.zip saved 348 bytes written
87-
./bin/astra-cli db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -d proxy-external -l proxy-external.zip
93+
astra db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -d proxy-external -l proxy-external.zip
8894
file proxy-external.zip saved 339 bytes written
8995
```
9096

9197
### get secure connection bundle URLs
9298

9399
```
94-
./bin/astra-cli db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -o list
100+
astra db secBundle 3c577e51-4ff5-4551-86a4-41d475c61822 -o list
95101
external bundle: changed
96102
internal bundle: changed
97103
external proxy: changed
@@ -101,15 +107,15 @@ file proxy-external.zip saved 339 bytes written
101107
### listing databases
102108

103109
```
104-
./bin/astra-cli db list
110+
astra db list
105111
name id status
106112
mydb 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b ACTIVE
107113
```
108114

109115
### listing databases in json
110116

111117
```
112-
./bin/astra-cli db list -o json
118+
astra db list -o json
113119
[
114120
{
115121
"id": "2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b",
@@ -157,15 +163,15 @@ mydb 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b ACTIVE
157163
### getting database by id
158164

159165
```
160-
./bin/astra-cli db get 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b
166+
astra db get 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b
161167
name id status
162168
mydb 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b ACTIVE
163169
```
164170

165171
### getting database by id in json
166172

167173
```
168-
./bin/astra-cli db get 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b -o json
174+
astra db get 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b -o json
169175
{
170176
"id": "2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b",
171177
"orgId": "changed",
@@ -212,49 +218,30 @@ mydb 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b ACTIVE
212218

213219
### parking database
214220

215-
Does not work on serverless
221+
NOTE: Does not work on serverless
216222

217223
```
218-
./bin/astra-cli db park -v 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b
224+
astra db park -v 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b
219225
starting to park database 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b
220-
2021/02/24 18:31:26 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state PARKING but expected PARKED trying again 29 more times
221-
2021/02/24 18:31:56 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state PARKING but expected PARKED trying again 28 more times
222-
2021/02/24 18:32:26 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state PARKING but expected PARKED trying again 27 more times
223-
2021/02/24 18:32:57 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state PARKING but expected PARKED trying again 26 more times
224-
2021/02/24 18:33:27 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state PARKING but expected PARKED trying again 25 more times
226+
...........
225227
database 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b parked
226228
```
227229

228230
### unparking database
229231

230-
Does not work on serverless
232+
NOTE: Does not work on serverless
231233

232234
```
233-
./bin/astra-cli db unpark -v 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b
235+
astra db unpark -v 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b
234236
starting to unpark database 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b
235-
2021/02/25 08:41:02 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state UNPARKING but expected ACTIVE trying again 59 more times
236-
2021/02/25 08:41:32 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state UNPARKING but expected ACTIVE trying again 58 more times
237-
2021/02/25 08:42:02 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state UNPARKING but expected ACTIVE trying again 57 more times
238-
2021/02/25 08:42:32 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state UNPARKING but expected ACTIVE trying again 56 more times
239-
2021/02/25 08:43:02 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state UNPARKING but expected ACTIVE trying again 55 more times
240-
2021/02/25 08:43:32 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state UNPARKING but expected ACTIVE trying again 54 more times
241-
2021/02/25 08:44:02 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state UNPARKING but expected ACTIVE trying again 53 more times
242-
2021/02/25 08:44:32 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state UNPARKING but expected ACTIVE trying again 52 more times
243-
2021/02/25 08:45:03 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state UNPARKING but expected ACTIVE trying again 51 more times
244-
2021/02/25 08:45:33 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state UNPARKING but expected ACTIVE trying again 50 more times
245-
2021/02/25 08:46:03 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state UNPARKING but expected ACTIVE trying again 49 more times
246-
2021/02/25 08:46:33 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state UNPARKING but expected ACTIVE trying again 48 more times
247-
2021/02/25 08:47:03 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state UNPARKING but expected ACTIVE trying again 47 more times
248-
2021/02/25 08:47:33 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state UNPARKING but expected ACTIVE trying again 46 more times
249-
2021/02/25 08:48:03 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state UNPARKING but expected ACTIVE trying again 45 more times
250-
2021/02/25 08:48:33 db 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b in state UNPARKING but expected ACTIVE trying again 44 more times
237+
...........
251238
database 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b unparked
252239
```
253240

254241
### deleting database
255242

256243
```
257-
./bin/astra-cli db delete -v 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b
244+
astra db delete -v 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b
258245
starting to delete database 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b
259246
database 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b deleted
260247
```
@@ -264,7 +251,7 @@ database 2c3bc0d6-5e3e-4d77-81c8-d95a35bdc58b deleted
264251
I did not have a paid account to verify this works, but you can see it succesfully starts the process
265252

266253
```
267-
./bin/astra-cli db resize -v 72c4d35b-1875-495a-b5f1-97329d90b6c5 2
254+
astra db resize -v 72c4d35b-1875-495a-b5f1-97329d90b6c5 2
268255
unable to unpark '72c4d35b-1875-495a-b5f1-97329d90b6c5' with error expected status code 2xx but had: 400 error was [map[ID:2.000009e+06 message:resizing is not supported for this database tier]]
269256
```
270257

cmd/db/list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ var startingAfter string
3333
var listFmt string
3434

3535
func init() {
36-
ListCmd.Flags().IntVarP(&limit, "limit", "l", 10, "limit of databases retrieved")
36+
defaultLimit := 10
37+
ListCmd.Flags().IntVarP(&limit, "limit", "l", defaultLimit, "limit of databases retrieved")
3738
ListCmd.Flags().StringVarP(&include, "include", "i", "", "the type of filter to apply")
3839
ListCmd.Flags().StringVarP(&provider, "provider", "p", "", "provider to filter by")
3940
ListCmd.Flags().StringVarP(&startingAfter, "startingAfter", "a", "", "timestamp filter, ie only show databases created after this timestamp")

cmd/db/resize.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ func executeResize(args []string, makeClient func() (pkg.Client, error)) error {
5151
}
5252
id := args[0]
5353
capacityUnitRaw := args[1]
54-
capacityUnit, err := strconv.ParseInt(capacityUnitRaw, 10, 32)
54+
defaultCapacity := 10
55+
bits := 32
56+
capacityUnit, err := strconv.ParseInt(capacityUnitRaw, defaultCapacity, bits)
5557
if err != nil {
5658
return &pkg.ParseError{
5759
Args: args,

0 commit comments

Comments
 (0)