Skip to content

Commit 68c61fa

Browse files
committed
Reducing size of shell, updagrading all versions, preparing for 0.3.1
1 parent aa3e753 commit 68c61fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2759
-969
lines changed

astra-sdk/src/main/java/com/datastax/astra/sdk/utils/AstraRc.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,13 @@
2525
import java.util.Optional;
2626
import java.util.Scanner;
2727

28-
import org.slf4j.Logger;
29-
import org.slf4j.LoggerFactory;
30-
3128
/**
3229
* Utility class to load/save .astrarc file. This file is used to store Astra configuration.
3330
*
3431
* @author Cedrick LUNVEN (@clunven)
3532
*/
3633
public class AstraRc {
37-
38-
/** Logger for our Client. */
39-
private static final Logger LOGGER = LoggerFactory.getLogger(AstraRc.class);
40-
34+
4135
/** Default filename we are looking for. */
4236
public static final String ASTRARC_FILENAME = ".astrarc";
4337

@@ -96,6 +90,7 @@ public static boolean isDefaultConfigFileExists() {
9690
* @param sectionName
9791
* section name
9892
* @return
93+
* tell if the section exists
9994
*/
10095
public boolean isSectionExists(String sectionName) {
10196
return sectionName != null && sections.containsKey(sectionName);
@@ -231,7 +226,6 @@ public void save() {
231226
try {
232227
out = new FileWriter(configFile);
233228
out.write(renderSections());
234-
LOGGER.info("File {} has been successfully updated.", configFile.getAbsolutePath());
235229
} catch (IOException e) {
236230
throw new IllegalStateException("Cannot save configuration file", e);
237231
} finally {
@@ -248,8 +242,6 @@ public void save() {
248242
*
249243
* @param file
250244
* configuration file
251-
* @return
252-
* parser.
253245
*/
254246
private void parseConfigFile() {
255247
try (Scanner scanner = new Scanner(configFile)) {
@@ -282,8 +274,8 @@ private void parseConfigFile() {
282274
/**
283275
* Prepare file content
284276
*
285-
* @param astraRc
286-
* Map
277+
* @return
278+
* sections as a string
287279
*/
288280
public String renderSections() {
289281
StringBuilder sb = new StringBuilder();
@@ -292,8 +284,12 @@ public String renderSections() {
292284
}
293285

294286
/**
295-
* Show
287+
* Display section as a string.
288+
*
296289
* @param sectionName
290+
* name of section
291+
* @return
292+
* section as a string
297293
*/
298294
public String renderSection(String sectionName) {
299295
StringBuilder sb = new StringBuilder();
@@ -307,10 +303,12 @@ public String renderSection(String sectionName) {
307303
}
308304

309305
/**
310-
* Use Astra Devops Api to list databases.
311-
*
306+
* Create a section in the configuration file.
307+
*
308+
* @param sectionName
309+
* current section name
312310
* @param token
313-
* token
311+
* token to authenticate
314312
*/
315313
public void createSectionWithToken(String sectionName, String token) {
316314
updateSectionKey(sectionName, ASTRA_DB_APPLICATION_TOKEN, token);

astra-shell/README.MD

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,41 @@ $myAstraOrganization>create db --name workshop --region eu-central-1 --keyspace
4040

4141
## Installations
4242

43-
- Download the zip archive
44-
- run `astra-install.sh`
45-
- run `astra-autocomplete.bash`
46-
- run `astra version` to validate installation
43+
- Download and extract the zip archive
44+
45+
```
46+
unzip astra-shell-alpha1.zip
47+
```
48+
49+
- Initialization
50+
51+
```
52+
cd astra-shell
53+
chmod 700 astra
54+
source auto-completions.bash
55+
```
56+
57+
- Configuration
4758

48-
## Setup
4959

50-
- Will ask for token and initialize config file
51-
- Each time you want to add a new token you can use it
60+
You are already set and can start typing commands
61+
62+
```
63+
astra show dbs -t <TOKEN>
64+
```
65+
66+
But it is annoying each time having to provide a token. What if you could save it ?
5267

5368
```
5469
astra setup
5570
```
5671

72+
- You can now
73+
74+
```
75+
astra show dbs
76+
```
77+
5778
## Configuration file
5879

5980
- List available configurations
@@ -66,13 +87,14 @@ astra config list
6687
- Create a new configuration providing a name
6788

6889
```
69-
astra config create my_new_section -t <TOKEN>
90+
astra config create dev -t <TOKEN>
91+
astra config list
7092
```
7193

72-
- Show details of a configuration
94+
- Show details of a dev
7395

7496
```
75-
astra config show my_new_section
97+
astra config show dev
7698
```
7799

78100
- Set a configuration as default
@@ -90,21 +112,40 @@ astra config rename my_new_section --name section2
90112
- Delete a configuration
91113

92114
```
93-
astra config delete my_new_section
115+
astra config delete dev
116+
astra config list
94117
```
95118

119+
## Let's start the SHOW
96120

97-
121+
```
98122
astra show dbs
99-
astra show db <DB>
123+
```
100124

125+
```
101126
astra show roles
127+
```
128+
129+
```
102130
astra show role <ROLE>
131+
```
103132

133+
```
104134
astra show users
135+
```
136+
137+
```
105138
astra show user <USER>
106139
```
107140

141+
## Shell we started now ?
142+
143+
144+
```
145+
astra shell
146+
```
147+
148+
108149
## Configuration
109150

110151
```

astra-shell/astra

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
java -jar target/astra-shell-0.3.1-SNAPSHOT-shaded.jar "$@"
4+

astra-shell/astra-native-agent

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
java -agentlib:native-image-agent=config-output-dir=. -jar target/astra-shell-0.3.1-SNAPSHOT-shaded.jar "$@"
4+

astra-shell/dependency-reduced-pom.xml

Lines changed: 79 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,6 @@
99
<artifactId>astra-shell</artifactId>
1010
<name>+ astra-shell</name>
1111
<build>
12-
<pluginManagement>
13-
<plugins>
14-
<plugin>
15-
<groupId>org.codehaus.mojo</groupId>
16-
<artifactId>exec-maven-plugin</artifactId>
17-
<version>${maven-plugin-exec.version}</version>
18-
<executions>
19-
<execution>
20-
<goals>
21-
<goal>exec</goal>
22-
</goals>
23-
</execution>
24-
</executions>
25-
<configuration>
26-
<mainClass>com.datastax.astra.AstraShell</mainClass>
27-
<additionalClasspathElements>
28-
<additionalClasspathElement>src/test/resources</additionalClasspathElement>
29-
</additionalClasspathElements>
30-
</configuration>
31-
</plugin>
32-
</plugins>
33-
</pluginManagement>
3412
<plugins>
3513
<plugin>
3614
<artifactId>maven-shade-plugin</artifactId>
@@ -60,6 +38,15 @@
6038
</configuration>
6139
</execution>
6240
</executions>
41+
<configuration>
42+
<artifactSet>
43+
<excludes>
44+
<exclude>*:junit-*</exclude>
45+
<exclude>*:opentest4j-*</exclude>
46+
<exclude>*:airline-help-bash*</exclude>
47+
</excludes>
48+
</artifactSet>
49+
</configuration>
6350
</plugin>
6451
<plugin>
6552
<groupId>com.github.rvesse</groupId>
@@ -96,7 +83,69 @@
9683
</plugin>
9784
</plugins>
9885
</build>
86+
<profiles>
87+
<profile>
88+
<id>native</id>
89+
<build>
90+
<plugins>
91+
<plugin>
92+
<groupId>org.graalvm.buildtools</groupId>
93+
<artifactId>native-maven-plugin</artifactId>
94+
<version>0.9.11</version>
95+
<extensions>true</extensions>
96+
<executions>
97+
<execution>
98+
<id>build-native</id>
99+
<phase>package</phase>
100+
<goals>
101+
<goal>build</goal>
102+
</goals>
103+
<configuration>
104+
<imageName>astra-native</imageName>
105+
<useArgFile>false</useArgFile>
106+
<quickBuild>false</quickBuild>
107+
<skipNativeBuild>false</skipNativeBuild>
108+
<mainClass>com.datastax.astra.shell.AstraCli</mainClass>
109+
<fallback>false</fallback>
110+
<verbose>true</verbose>
111+
<buildArgs>
112+
<buildArg>--no-fallback</buildArg>
113+
<buildArg>-H:ReflectionConfigurationFiles=../src/main/resources/META-INF/native-image/reflect-config.json</buildArg>
114+
</buildArgs>
115+
<classpath>
116+
<param>/Users/cedricklunven/dev/workspaces/datastax/astra-sdk-java/astra-shell/target/astra-shell-0.3.1-SNAPSHOT-shaded.jar</param>
117+
</classpath>
118+
</configuration>
119+
</execution>
120+
</executions>
121+
<configuration>
122+
<imageName>astra-native</imageName>
123+
<useArgFile>false</useArgFile>
124+
<quickBuild>false</quickBuild>
125+
<skipNativeBuild>false</skipNativeBuild>
126+
<mainClass>com.datastax.astra.shell.AstraCli</mainClass>
127+
<fallback>false</fallback>
128+
<verbose>true</verbose>
129+
<buildArgs>
130+
<buildArg>--no-fallback</buildArg>
131+
<buildArg>-H:ReflectionConfigurationFiles=../src/main/resources/META-INF/native-image/reflect-config.json</buildArg>
132+
</buildArgs>
133+
<classpath>
134+
<param>/Users/cedricklunven/dev/workspaces/datastax/astra-sdk-java/astra-shell/target/astra-shell-0.3.1-SNAPSHOT-shaded.jar</param>
135+
</classpath>
136+
</configuration>
137+
</plugin>
138+
</plugins>
139+
</build>
140+
</profile>
141+
</profiles>
99142
<dependencies>
143+
<dependency>
144+
<groupId>org.junit.jupiter</groupId>
145+
<artifactId>junit-jupiter-api</artifactId>
146+
<version>5.8.2</version>
147+
<scope>compile</scope>
148+
</dependency>
100149
<dependency>
101150
<groupId>org.junit.jupiter</groupId>
102151
<artifactId>junit-jupiter-engine</artifactId>
@@ -133,12 +182,20 @@
133182
</exclusion>
134183
</exclusions>
135184
</dependency>
185+
<dependency>
186+
<groupId>com.github.rvesse</groupId>
187+
<artifactId>airline-help-bash</artifactId>
188+
<version>2.8.5</version>
189+
<scope>test</scope>
190+
</dependency>
136191
</dependencies>
137192
<properties>
138193
<airline.version>2.8.5</airline.version>
139194
<commons-cli.version>1.5.0</commons-cli.version>
140195
<maven-plugin-exec.version>3.0.0</maven-plugin-exec.version>
141196
<jansi.version>2.4.0</jansi.version>
197+
<commons-compress.version>1.21</commons-compress.version>
142198
<commons-lang.version>3.12.0</commons-lang.version>
199+
<native.maven.plugin.version>0.9.11</native.maven.plugin.version>
143200
</properties>
144201
</project>

0 commit comments

Comments
 (0)