Skip to content

Commit

Permalink
Fixing Bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
clun committed Oct 25, 2023
1 parent c6283b9 commit 30512ac
Show file tree
Hide file tree
Showing 12 changed files with 439 additions and 120 deletions.
197 changes: 170 additions & 27 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@
<version>0.4</version>
<url>https://github.com/datastax/astra-cli</url>
<properties>
<sonar.organization>clun-datastax</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<app.main.class>com.dtsx.astra.cli.AstraCli</app.main.class>

<imageName>astra</imageName>
<app.main.class>com.dtsx.astra.cli.AstraCli</app.main.class>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.organization>clun-datastax</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

<astra-sdk.version>0.7.1</astra-sdk.version>
<jansi.version>2.4.1</jansi.version>
<airline.version>2.9.0</airline.version>
<slf4j.version>2.0.9</slf4j.version>
<httpclient.version>5.1.2</httpclient.version>
<jackson-datatype.version>2.15.3</jackson-datatype.version>
<!-- commons -->
<commons-compress.version>1.24.0</commons-compress.version>
<!-- Junit -->
<junit-jupiter.version>5.10.0</junit-jupiter.version>
Expand All @@ -33,17 +35,17 @@
<version.maven.plugin.assembly>3.6.0</version.maven.plugin.assembly>
<version.maven.plugin.compiler>3.11.0</version.maven.plugin.compiler>
<version.maven.plugin.coveralls>4.3.0</version.maven.plugin.coveralls>
<version.maven.plugin.dependency>3.6.0</version.maven.plugin.dependency>
<version.maven.plugin.exec>3.0.0</version.maven.plugin.exec>
<version.maven.plugin.dependency>3.6.1</version.maven.plugin.dependency>
<version.maven.plugin.exec>3.1.0</version.maven.plugin.exec>
<version.maven.plugin.jacoco>0.8.11</version.maven.plugin.jacoco>
<version.maven.plugin.javadoc>3.4.1</version.maven.plugin.javadoc>
<version.maven.plugin.javadoc>3.6.0</version.maven.plugin.javadoc>
<version.maven.plugin.jar>3.3.0</version.maven.plugin.jar>
<version.maven.plugin.license>2.2.0</version.maven.plugin.license>
<version.maven.plugin.native>0.9.28</version.maven.plugin.native>
<version.maven.plugin.release>2.5.2</version.maven.plugin.release>
<version.maven.plugin.release>3.0.1</version.maven.plugin.release>
<version.maven.plugin.resources>3.3.1</version.maven.plugin.resources>
<version.maven.plugin.shade>3.5.1</version.maven.plugin.shade>
<version.maven.plugin.surefire>3.1.2</version.maven.plugin.surefire>
<version.maven.plugin.surefire>3.2.1</version.maven.plugin.surefire>
</properties>

<dependencies>
Expand Down Expand Up @@ -91,11 +93,17 @@
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson-datatype.version}</version>
</dependency>

<dependency>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>junit-platform-native</artifactId>
<version>${version.maven.plugin.native}</version>
</dependency>

<!-- Unit tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
Expand All @@ -105,21 +113,17 @@
<version>${airline.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.awaitility/awaitility -->
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>${awaitibility.version}</version>
<scope>test</scope>
</dependency>


</dependencies>

<build>

<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -130,7 +134,6 @@
<showWarnings>false</showWarnings>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand All @@ -141,13 +144,11 @@
</includes>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${version.maven.plugin.dependency}</version>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
Expand Down Expand Up @@ -179,7 +180,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand All @@ -194,7 +194,6 @@
</archive>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
Expand All @@ -204,7 +203,11 @@
<encoding>UTF-8</encoding>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${version.maven.plugin.release}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand Down Expand Up @@ -245,7 +248,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.github.rvesse</groupId>
<artifactId>airline-maven-plugin</artifactId>
Expand All @@ -272,8 +274,6 @@
</execution>
</executions>
</plugin>

<!-- Coveralls.io -->
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
Expand All @@ -289,7 +289,6 @@
</dependency>
</dependencies>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
Expand Down Expand Up @@ -321,7 +320,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
Expand All @@ -342,7 +340,6 @@
</execution>
</executions>
</plugin>

</plugins>
</build>

Expand All @@ -357,16 +354,29 @@
<version>${version.maven.plugin.native}</version>
<extensions>true</extensions>
<executions>
<execution>
<id>test-native</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
<execution>
<id>build-native</id>
<!--
<goals>
<goal>build</goal>
</goals>-->
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<imageName>astra-native</imageName>
<imageName>${imageName}</imageName>
<skip>false</skip>
<fallback>false</fallback>
<mainClass>${app.main.class}</mainClass>
<buildArgs>
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
Expand All @@ -378,11 +388,144 @@
<classpath>
<param>${project.build.directory}/${project.artifactId}-${project.version}-shaded.jar</param>
</classpath>
<agent>
<enabled>true</enabled>
</agent>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${version.maven.plugin.exec}</version>
<executions>
<execution>
<id>java-agent</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>${app.main.class}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>java</id>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>${app.main.class}</mainClass>
</configuration>
</execution>
<execution>
<id>native</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${project.build.directory}/${imageName}</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>shaded</id>
<dependencies>
<dependency>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>junit-platform-native</artifactId>
<version>${version.maven.plugin.native}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${version.maven.plugin.shade}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${version.maven.plugin.assembly}</version>
<configuration>
<descriptors>
<descriptor>src/assembly/test-jar-with-dependencies.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-test-jar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>${version.maven.plugin.native}</version>
<extensions>true</extensions>
<executions>
<execution>
<id>test-native</id>
<goals>
<goal>test</goal>
</goals>
<phase>integration-test</phase>
<configuration>
<classpath>
<param>${project.build.directory}/${project.artifactId}-${project.version}-tests.jar</param>
</classpath>
</configuration>
</execution>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
<configuration>
<classpath>
<param>${project.build.directory}/${project.artifactId}-${project.version}-shaded.jar</param>
</classpath>
</configuration>
</execution>
</executions>
<configuration>
<skip>false</skip>
<useArgFile>false</useArgFile>
<imageName>${imageName}</imageName>
<fallback>false</fallback>
</configuration>
</plugin>
</plugins>
</build>
</profile>

</profiles>

<scm>
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/dtsx/astra/cli/config/ConfigCreateCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.dtsx.astra.cli.core.exception.InvalidTokenException;
import com.dtsx.astra.cli.core.exception.TokenNotFoundException;
import com.dtsx.astra.cli.core.out.AstraCliConsole;
import com.dtsx.astra.cli.utils.AstraCliUtils;
import com.dtsx.astra.sdk.AstraOpsClient;
import com.dtsx.astra.sdk.org.domain.Organization;
import com.dtsx.astra.sdk.utils.AstraEnvironment;
Expand All @@ -50,7 +51,7 @@ public class ConfigCreateCmd extends AbstractCmd {

/** To use Cli on non production environment. */
@Option(name = { "-e", "--env" }, title = "Environment", description = "Environment to use for this section.")
protected AstraEnvironment env = AstraEnvironment.PROD;
protected String env = "prod";

/** {@inheritDoc} */
@Override
Expand All @@ -65,13 +66,14 @@ public void execute() {
throw new InvalidTokenException(token);
}
// validate token at the same time
Organization o = new AstraOpsClient(token, env).getOrganization();
AstraEnvironment targetEnv = AstraCliUtils.lookupEnvironment(env);
Organization o = new AstraOpsClient(token, targetEnv).getOrganization();
if (sectionName == null) {
sectionName = o.getName();
}
sectionName = removeQuotesIfAny(sectionName);
ctx().validateCredentials(token, env);
ctx().getConfiguration().createSectionWithToken(sectionName, token, env);
ctx().validateCredentials(token, targetEnv);
ctx().getConfiguration().createSectionWithToken(sectionName, token, targetEnv);
ctx().getConfiguration().save();
AstraCliConsole.outputSuccess("Configuration has been saved.");
}
Expand Down
Loading

0 comments on commit 30512ac

Please sign in to comment.