From 4d072652f929d59f4b8149413feb7ac088f7f1fc Mon Sep 17 00:00:00 2001 From: "CORP\\mmrzik" Date: Fri, 27 Oct 2023 13:19:51 +0200 Subject: [PATCH] #13: implement aws toolcommandlet --- .../ide/commandlet/CommandletManagerImpl.java | 2 + .../com/devonfw/tools/ide/tool/aws/Aws.java | 43 +++++++++++++++++++ cli/src/main/resources/nls/Ide.properties | 1 + cli/src/main/resources/nls/Ide_de.properties | 1 + 4 files changed, 47 insertions(+) create mode 100644 cli/src/main/java/com/devonfw/tools/ide/tool/aws/Aws.java diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java index b25a9f761..7ee9769f4 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java @@ -10,6 +10,7 @@ import com.devonfw.tools.ide.context.IdeContext; import com.devonfw.tools.ide.property.KeywordProperty; import com.devonfw.tools.ide.property.Property; +import com.devonfw.tools.ide.tool.aws.Aws; import com.devonfw.tools.ide.tool.az.Azure; import com.devonfw.tools.ide.tool.eclipse.Eclipse; import com.devonfw.tools.ide.tool.gh.Gh; @@ -72,6 +73,7 @@ private CommandletManagerImpl(IdeContext context) { add(new KotlincNative(context)); add(new Vscode(context)); add(new Azure(context)); + add(new Aws(context)); } private void add(Commandlet commandlet) { diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/aws/Aws.java b/cli/src/main/java/com/devonfw/tools/ide/tool/aws/Aws.java new file mode 100644 index 000000000..40249009f --- /dev/null +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/aws/Aws.java @@ -0,0 +1,43 @@ +package com.devonfw.tools.ide.tool.aws; + +import java.nio.file.Path; +import java.util.Set; + +import com.devonfw.tools.ide.context.IdeContext; +import com.devonfw.tools.ide.environment.EnvironmentVariables; +import com.devonfw.tools.ide.environment.EnvironmentVariablesType; +import com.devonfw.tools.ide.tool.ToolCommandlet; + +/** + * {@link ToolCommandlet} for AWS CLI (aws). + */ + +public class Aws extends ToolCommandlet { + + /** + * The constructor. + * + * @param context the {@link IdeContext}. + */ + public Aws(IdeContext context) { + + super(context, "aws", Set.of(TAG_CLOUD)); + } + + @Override + public void postInstall() { + + super.postInstall(); + + EnvironmentVariables variables = this.context.getVariables(); + EnvironmentVariables typeVariables = variables.getByType(EnvironmentVariablesType.CONF); + + Path awsConfigDir = this.context.getConfPath().resolve("aws"); + this.context.getFileAccess().mkdirs(awsConfigDir); + Path awsConfigFile = awsConfigDir.resolve("config"); + Path awsCredentialsFile = awsConfigDir.resolve("credentials"); + typeVariables.set("AWS_CONFIG_FILE", awsConfigFile.toString(), true); + typeVariables.set("AWS_SHARED_CREDENTIALS_FILE", awsCredentialsFile.toString(), true); + typeVariables.save(); + } +} diff --git a/cli/src/main/resources/nls/Ide.properties b/cli/src/main/resources/nls/Ide.properties index 7f1344f9d..f3fd5d78c 100644 --- a/cli/src/main/resources/nls/Ide.properties +++ b/cli/src/main/resources/nls/Ide.properties @@ -2,6 +2,7 @@ usage=Usage: values=Values: commandlets=Available commandlets: options=Options: +cmd-aws=Tool commandlet for AWS CLI. cmd-az=Tool commandlet for Azure CLI. cmd-env=Print the environment variables to set and export. cmd-get-version=Get the version of the selected tool. diff --git a/cli/src/main/resources/nls/Ide_de.properties b/cli/src/main/resources/nls/Ide_de.properties index 37815d7a1..36a82ca98 100644 --- a/cli/src/main/resources/nls/Ide_de.properties +++ b/cli/src/main/resources/nls/Ide_de.properties @@ -2,6 +2,7 @@ usage=Verwendung: values=Werte: commandlets=Verfügbare Kommandos: options=Optionen: +cmd-aws=Werkzeug Kommando fuer AWS Kommandoschnittstelle. cmd-az=Werkzeug Kommando fuer Azure Kommandoschnittstelle. cmd-env=Gibt die zu setztenden und exportierenden Umgebungsvariablen aus. cmd-get-version=Zeigt die Version des selektierten Werkzeugs an.