Skip to content

Commit

Permalink
Merge pull request #115 from msmygit/main
Browse files Browse the repository at this point in the history
Update GHA workflows with latest improvements
  • Loading branch information
clun authored Sep 29, 2023
2 parents 7db48b1 + 712ada4 commit 68eb41b
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cli-native-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
graalvm-version: ['22.2.0','22.3.1']
jdk-version: ['17']
graalvm-distribution: ['graalvm']
jdk-version: ['21', '17']
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Download application package
Expand All @@ -54,7 +54,7 @@ jobs:
name: java-binary
- uses: graalvm/setup-graalvm@v1
with:
version: ${{ matrix.graalvm-version }}
distribution: ${{ matrix.graalvm-distribution }}
java-version: ${{ matrix.jdk-version }}
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cli-nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
with:
java-version: "17"
distribution: "temurin"
cache: "maven"
- name: Test with Maven
run: mvn compile

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

import com.dtsx.astra.cli.core.out.LoggerShell;
import com.dtsx.astra.sdk.utils.ApiLocator;
import com.dtsx.astra.sdk.utils.AstraEnvironment;
import com.dtsx.astra.sdk.utils.AstraRc;

import java.io.File;
Expand Down Expand Up @@ -288,9 +288,9 @@ public String renderSection(String sectionName) {
* @param token
* token to authenticate
*/
public void createSectionWithToken(String sectionName, String token, ApiLocator.AstraEnvironment env) {
public void createSectionWithToken(String sectionName, String token, AstraEnvironment env) {
updateSectionKey(sectionName, AstraRc.ASTRA_DB_APPLICATION_TOKEN, token);
if (ApiLocator.AstraEnvironment.PROD != env) {
if (AstraEnvironment.PROD != env) {
updateSectionKey(sectionName, KEY_ENV, env.name());
}
if (!isSectionExists(ASTRARC_DEFAULT))
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/dtsx/astra/cli/config/ConfigCreateCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.dtsx.astra.cli.core.out.AstraCliConsole;
import com.dtsx.astra.sdk.AstraDevopsApiClient;
import com.dtsx.astra.sdk.org.domain.Organization;
import com.dtsx.astra.sdk.utils.ApiLocator;
import com.dtsx.astra.sdk.utils.AstraEnvironment;
import com.github.rvesse.airline.annotations.Arguments;
import com.github.rvesse.airline.annotations.Command;
import com.github.rvesse.airline.annotations.Option;
Expand All @@ -50,7 +50,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 ApiLocator.AstraEnvironment env = ApiLocator.AstraEnvironment.PROD;
protected AstraEnvironment env = AstraEnvironment.PROD;

/** {@inheritDoc} */
@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/dtsx/astra/cli/config/ServiceConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.dtsx.astra.cli.core.out.AstraCliConsole;
import com.dtsx.astra.cli.core.out.ShellTable;
import com.dtsx.astra.cli.core.out.StringBuilderAnsi;
import com.dtsx.astra.sdk.utils.ApiLocator;
import com.dtsx.astra.sdk.utils.AstraEnvironment;
import com.dtsx.astra.sdk.utils.AstraRc;

import java.util.HashMap;
Expand Down Expand Up @@ -95,7 +95,7 @@ public static void listConfigurations() {
if (isMultiEnv) {
rf.put(COLUMN_ENV, Optional.ofNullable(sections.get(section.getKey())
.get(AstraCliConfiguration.KEY_ENV))
.orElse(ApiLocator.AstraEnvironment.PROD.name()));
.orElse(AstraEnvironment.PROD.name()));
}
sht.getCellValues().add(rf);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import com.dtsx.astra.cli.config.AstraCliConfiguration;
import com.dtsx.astra.cli.core.out.OutputFormat;
import com.dtsx.astra.sdk.utils.ApiLocator;
import com.dtsx.astra.sdk.utils.AstraEnvironment;
import com.github.rvesse.airline.annotations.Option;

import java.util.Locale;
Expand All @@ -43,7 +43,7 @@ public abstract class AbstractConnectedCmd extends AbstractCmd {
* Astra Environment, could be DEV or TEST instead of PROD.
*/
@Option(name = { "--env" }, title = "Environment", description = "Astra Environment to use")
protected ApiLocator.AstraEnvironment env = ApiLocator.AstraEnvironment.PROD;
protected AstraEnvironment env = AstraEnvironment.PROD;

/** Section. */
@Option(name = { "-conf","--config" },
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/dtsx/astra/cli/core/CliContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.dtsx.astra.sdk.db.AstraDbClient;
import com.dtsx.astra.sdk.org.domain.Organization;
import com.dtsx.astra.sdk.streaming.AstraStreamingClient;
import com.dtsx.astra.sdk.utils.ApiLocator;
import com.dtsx.astra.sdk.utils.AstraEnvironment;
import com.dtsx.astra.sdk.utils.AstraRc;
import org.apache.commons.lang3.StringUtils;

Expand Down Expand Up @@ -148,9 +148,9 @@ private void loadCredentialsFromSection()
astraConfig.getSection(tokenOptions.section())
.containsKey(AstraRc.ASTRA_DB_APPLICATION_TOKEN)) {
LoggerShell.debug("Configuration: Using token in section %s".formatted(tokenOptions.section()));
ApiLocator.AstraEnvironment targetEnv = ApiLocator.AstraEnvironment.PROD;
AstraEnvironment targetEnv = AstraEnvironment.PROD;
if (astraConfig.getSection(tokenOptions.section()).containsKey(AstraCliConfiguration.KEY_ENV)) {
targetEnv = ApiLocator.AstraEnvironment.valueOf(
targetEnv = AstraEnvironment.valueOf(
astraConfig.getSection(tokenOptions.section()).get(AstraCliConfiguration.KEY_ENV));
LoggerShell.debug("Configuration: Targeting env %s".formatted(targetEnv));
}
Expand Down Expand Up @@ -202,7 +202,7 @@ public String getToken()
* @throws TokenNotFoundException
* token as not been found
*/
public ApiLocator.AstraEnvironment getAstraEnvironment()
public AstraEnvironment getAstraEnvironment()
throws TokenNotFoundException {
if (tokenOptions == null) {
return null;
Expand All @@ -228,7 +228,7 @@ public AstraCliConfiguration getConfiguration() {
*/
public AstraDevopsApiClient getApiDevops() {
AstraDevopsApiClient devopsApiClient = new AstraDevopsApiClient(getToken(), getAstraEnvironment());
if (!getAstraEnvironment().equals(ApiLocator.AstraEnvironment.PROD)) {
if (!getAstraEnvironment().equals(AstraEnvironment.PROD)) {
LoggerShell.info("You are using a non-production environment '%s' ".formatted(getAstraEnvironment()));
}
validateDevopsClientConnection(devopsApiClient);
Expand All @@ -243,7 +243,7 @@ public AstraDevopsApiClient getApiDevops() {
* @param env
* target environment
*/
public void validateCredentials(String token, ApiLocator.AstraEnvironment env) {
public void validateCredentials(String token, AstraEnvironment env) {
validateDevopsClientConnection(new AstraDevopsApiClient(token, env));
}

Expand All @@ -253,7 +253,7 @@ public void validateCredentials(String token, ApiLocator.AstraEnvironment env) {
private void validateDevopsClientConnection(AstraDevopsApiClient client) {
Organization org = client.getOrganization();
if (org.getId() == null) {
if (!client.getEnvironment().equals(ApiLocator.AstraEnvironment.PROD)) {
if (!client.getEnvironment().equals(AstraEnvironment.PROD)) {
AstraCliConsole.outputError(ExitCode.CANNOT_CONNECT,
"Make sure token targets proper environment '%s'".formatted(client.getEnvironment()));
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/dtsx/astra/cli/core/TokenOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
* #L%
*/

import com.dtsx.astra.sdk.utils.ApiLocator;
import com.dtsx.astra.sdk.utils.AstraEnvironment;

/**
* Options when you need a token.
*/
public record TokenOptions(
String token, // Token Value
String section, //Section Value
ApiLocator.AstraEnvironment env //Target environment.
AstraEnvironment env //Target environment.
) {}

0 comments on commit 68eb41b

Please sign in to comment.