Skip to content

Commit 1fb154d

Browse files
committed
Ready for 0.4
1 parent 78abdcb commit 1fb154d

File tree

10 files changed

+174
-162
lines changed

10 files changed

+174
-162
lines changed

RELEASES.MD

+70-50
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,115 @@
11

2-
### TESTS
2+
## Deployment
33

4-
- Generate Jacoco report and push to Coverall
4+
### 1. Git
55

6+
- Start the agent
67
```bash
7-
mvn clean test jacoco:report coveralls:report
8+
eval "$(ssh-agent -s)"
89
```
910

10-
- Generate Sonar report and push to Coverall
11-
11+
- Check key is available
1212
```bash
13-
export SONAR_TOKEN=...
14-
mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=clun_astra-cli
13+
ssh-add -l
1514
```
1615

17-
### PACKAGING
18-
19-
- Build the project
20-
16+
- Add the key (if needed)
2117
```
22-
mvn clean install
18+
cd ~/.ssh
19+
ssh-add githubff4j
2320
```
2421

25-
- Run with Agent:
22+
### 2. Update versions and dependencies
2623

27-
_Make sure you are using a graalVM JDK_
24+
- Check for dependency updates and update the `pom.xml` file when relevant.
2825

2926
```bash
30-
sdk install java 22.3.1.r17-grl
31-
java --version
27+
mvn versions:display-dependency-update
3228
```
3329

34-
```
35-
/Library/Java/JavaVirtualMachines/graalvm-ce-java17-21.3.0/Contents/Home/bin/java -agentlib:native-image-agent=config-output-dir=/tmp/native-image -jar target/astra-cli-0.2-shaded.jar token list
30+
- Update project version
31+
```bash
32+
mvn versions:set -DnewVersion=0.4
3633
```
3734

38-
- Build as a native image
39-
40-
```
41-
mvn clean install -Pnative
35+
- When ok commit
36+
```bash
37+
mvn versions:commit
4238
```
4339

44-
### PUSH
45-
46-
- Start the `ssh-agent`
47-
```
48-
eval "$(ssh-agent -s)"
49-
```
50-
- Add the ssh key to the agent
51-
```
52-
cd ~/.ssh
53-
ssh-add githubff4j
54-
```
55-
- Update sources
40+
- Make sure everything is in sync
5641
```
5742
find . -type f -name *.DS_Store -ls -delete
5843
git pull
5944
git add -A
60-
git commit -m "delivery"
61-
git push
45+
git commit -m "Preparing for deployment"
6246
```
63-
- Release
47+
48+
### 3. Build and Tests
49+
50+
- Generate Jacoco report and push to Coverall and get results at [Coveralls.io](https://coveralls.io/github/datastax/astra-cli)
51+
52+
```bash
53+
mvn clean test jacoco:report coveralls:report
6454
```
65-
mvn clean -DskipTests -Darguments=-DskipTests release:prepare release:perform
55+
56+
- Generate Sonar report and push to sonar cloud and get results at [SonarCloud.io](https://sonarcloud.io/summary/overall?id=clun_astra-cli)
57+
58+
```bash
59+
export SONAR_TOKEN=...
60+
mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=clun_astra-cli
6661
```
6762

68-
### DEPLOY
63+
### 4. Packaging
6964

70-
- Build the project
65+
- Install proper java and graal VM if needed
7166

72-
- Copy `astra-init.sh` on each distribution folder
67+
```bash
68+
sdk install java 22.3.1.r17-grl
69+
java --version
70+
```
7371

74-
- Copy the shaded and put it in Java folder, rename to `astra-cli.jar`
72+
- Build project
7573

76-
- Build in native
74+
```
75+
mvn clean install
76+
```
77+
78+
- Check `reflect-config.json` and `resource-config.json` are updated with all classes and commands
79+
80+
```json
81+
{
82+
"name":"com.dtsx.astra.cli.org.OrgIdCmd",
83+
"allDeclaredFields":true,
84+
"methods":[{"name":"<init>","parameterTypes":[] }]
85+
}
86+
```
87+
- Build project a native image
7788

7889
```
7990
mvn clean install -Pnative
8091
```
8192

82-
- Chmod everything
93+
- Chmod everything execution files
94+
95+
```bash
96+
chmod 755 src/main/dist/astra-init.sh
97+
```
98+
99+
- Copy `dist/astra-init.sh` (_generated by a test)_ on each distribution folder
100+
101+
102+
- Copy the shaded and put it in Java folder, rename to `astra-cli.jar`
103+
83104

84105
- Packaging
85106

86107
```
87-
zip astra-cli-0.2.zip *
88-
zip astra-cli-0.2-linux.zip *
89-
zip astra-cli-0.2-windows.zip *
90-
zip astra-cli-0.2-mac.zip *
91-
tar -czf astra-cli-0.2-brew.tar.gz *
92-
brew create https://github.com/datastax/astra-cli/releases/download/0.2/astra-cli-0.2-homebrew.tar.gz
108+
zip astra-cli-0.4.zip *
109+
zip astra-cli-0.4-linux.zip *
110+
zip astra-cli-0.4-mac.zip *
111+
tar -czf astra-cli-0.4-brew.tar.gz *
112+
brew create https://github.com/datastax/astra-cli/releases/download/0.4/astra-cli-0.4-homebrew.tar.gz
93113
```
94114

95115
- Edit Releases

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
1515
<app.main.class>com.dtsx.astra.cli.AstraCli</app.main.class>
1616
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17-
<astra-sdk.version>0.6.7-SNAPSHOT</astra-sdk.version>
17+
<astra-sdk.version>0.6.7</astra-sdk.version>
1818
<jansi.version>2.4.0</jansi.version>
1919
<airline.version>2.9.0</airline.version>
2020
<slf4j.version>2.0.7</slf4j.version>

src/main/java/com/dtsx/astra/cli/AstraCli.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
import com.dtsx.astra.sdk.db.exception.ChangeDataCaptureNotFoundException;
108108
import com.dtsx.astra.sdk.db.exception.DatabaseNotFoundException;
109109
import com.dtsx.astra.sdk.db.exception.KeyspaceAlreadyExistException;
110+
import com.dtsx.astra.sdk.db.exception.KeyspaceNotFoundException;
110111
import com.dtsx.astra.sdk.db.exception.RegionAlreadyExistException;
111112
import com.dtsx.astra.sdk.db.exception.RegionNotFoundException;
112113
import com.dtsx.astra.sdk.streaming.exception.TenantAlreadyExistException;
@@ -315,7 +316,7 @@ public static ExitCode run(Class<?> clazz, String[] args) {
315316
} catch (InvalidArgumentException | IllegalArgumentException dex) {
316317
AstraCliConsole.outputError(ExitCode.INVALID_ARGUMENT, dex.getMessage());
317318
return ExitCode.INVALID_ARGUMENT;
318-
} catch (DatabaseNotFoundException |
319+
} catch (DatabaseNotFoundException | KeyspaceNotFoundException |
319320
TenantNotFoundException |
320321
RoleNotFoundException | ChangeDataCaptureNotFoundException |
321322
UserNotFoundException | RegionNotFoundException ex) {

src/main/java/com/dtsx/astra/cli/config/ServiceConfig.java

+6-14
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,8 @@
2929
import com.dtsx.astra.sdk.utils.ApiLocator;
3030
import com.dtsx.astra.sdk.utils.AstraRc;
3131

32-
import java.util.ArrayList;
3332
import java.util.HashMap;
34-
import java.util.List;
3533
import java.util.Map;
36-
import java.util.Map.Entry;
3734
import java.util.Optional;
3835

3936
/**
@@ -86,17 +83,17 @@ public static void listConfigurations() {
8683
.get(AstraCliConfiguration.ASTRARC_DEFAULT)
8784
.get(AstraRc.ASTRA_DB_APPLICATION_TOKEN));
8885
}
89-
for (String sectionName : sections.keySet()) {
90-
if (!AstraCliConfiguration.ASTRARC_DEFAULT.equalsIgnoreCase(sectionName)) {
86+
for (Map.Entry<String, Map<String, String>> section : sections.entrySet()) {
87+
if (!AstraCliConfiguration.ASTRARC_DEFAULT.equalsIgnoreCase(section.getKey())) {
9188
Map<String, String> rf = new HashMap<>();
92-
String currentToken = sections.get(sectionName).get(AstraRc.ASTRA_DB_APPLICATION_TOKEN);
89+
String currentToken = sections.get(section.getKey()).get(AstraRc.ASTRA_DB_APPLICATION_TOKEN);
9390
if (defaultToken.isPresent() && defaultToken.get().equals(currentToken)) {
94-
rf.put(COLUMN_TITLE, StringBuilderAnsi.colored(sectionName + " (in use)", AstraAnsiColors.PURPLE_300));
91+
rf.put(COLUMN_TITLE, StringBuilderAnsi.colored(section.getKey() + " (in use)", AstraAnsiColors.PURPLE_300));
9592
} else {
96-
rf.put(COLUMN_TITLE, sectionName);
93+
rf.put(COLUMN_TITLE, section.getKey());
9794
}
9895
if (isMultiEnv) {
99-
rf.put(COLUMN_ENV, Optional.ofNullable(sections.get(sectionName)
96+
rf.put(COLUMN_ENV, Optional.ofNullable(sections.get(section.getKey())
10097
.get(AstraCliConfiguration.KEY_ENV))
10198
.orElse(ApiLocator.AstraEnvironment.PROD.name()));
10299
}
@@ -118,11 +115,6 @@ public static boolean isMultiEnvironment(Map<String, Map<String, String>> sectio
118115
.anyMatch(key -> key.equals(AstraCliConfiguration.KEY_ENV));
119116
}
120117

121-
public static boolean isDefaultSection(Map<String, Map<String, String>> sections, String sectionName) {
122-
return AstraCliConfiguration.ASTRARC_DEFAULT.equalsIgnoreCase(sectionName)
123-
&& sections.containsKey(AstraCliConfiguration.ASTRARC_DEFAULT);
124-
}
125-
126118
/**
127119
* Test existence of section in document.
128120
*

src/main/java/com/dtsx/astra/cli/core/CliContext.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
*/
2222

2323
import com.dtsx.astra.cli.config.AstraCliConfiguration;
24-
import com.dtsx.astra.cli.core.exception.AstraEnvironmentNotFoundException;
2524
import com.dtsx.astra.cli.core.exception.InvalidTokenException;
2625
import com.dtsx.astra.cli.core.exception.TokenNotFoundException;
2726
import com.dtsx.astra.cli.core.out.AstraCliConsole;
@@ -205,8 +204,8 @@ public String getToken()
205204
*/
206205
public ApiLocator.AstraEnvironment getAstraEnvironment()
207206
throws TokenNotFoundException {
208-
if (tokenOptions == null || tokenOptions.env() == null) {
209-
throw new AstraEnvironmentNotFoundException();
207+
if (tokenOptions == null) {
208+
return null;
210209
}
211210
return tokenOptions.env();
212211
}

src/main/java/com/dtsx/astra/cli/core/exception/AstraEnvironmentNotFoundException.java

-43
This file was deleted.

0 commit comments

Comments
 (0)