-
Couldn't load subscription status.
- Fork 45
#13: implement tool commandlet for aws cli #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hohwille
merged 34 commits into
devonfw:main
from
MattesMrzik:feature/#13-implement-ToolCommandlet-for-AWS-CLI
Jan 31, 2024
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
4d07265
#13: implement aws toolcommandlet
MattesMrzik 01f9484
#13: added linux specific procedure to install aws
MattesMrzik bd4b999
Merge branch 'devonfw:main' into feature/#13-implement-ToolCommandlet…
MattesMrzik a710192
aws toolcommandlet now for linux
MattesMrzik e94cc15
aws extends localtoolcommandlet
MattesMrzik c970265
#139: relative symlink feature
MattesMrzik a360f9f
#139: clean up
MattesMrzik 15d2525
#13: before i merge branch 139: relative symlink into this branch
MattesMrzik d9f33a8
Merge remote-tracking branch 'origin/feature/#139-feature-for-making-…
MattesMrzik 42a008b
#13: fix merge error and bug in Aws.moveAndProcessExtraction
MattesMrzik e295e9d
#139: added check for windows when rewriting junction
MattesMrzik 4e1ba6f
#13: implemented suggested improvements
MattesMrzik 66f09cf
#139: rewrote test, one still missing
MattesMrzik 75eb709
#139: improved test, removed makeSymlinkRelative
MattesMrzik 0719c4f
Merge remote-tracking branch 'upstream/main' into feature/#139-featur…
MattesMrzik cf287fe
#139: small bugfix in test
MattesMrzik 24f3307
#139: fixed linux bug
MattesMrzik 5252a35
Merge remote-tracking branch 'upstream/main' into feature/#13-impleme…
MattesMrzik 70aef25
Merge remote-tracking branch 'origin/feature/#139-feature-for-making-…
MattesMrzik eaa85fc
Merge remote-tracking branch 'origin/main' into feature/#13-implement…
MattesMrzik 9f4e0ea
Merge branch 'main' of https://github.com/devonfw/IDEasy into feature…
MattesMrzik 2138357
#13: small change
MattesMrzik 0b23360
#13: reformatted comment
MattesMrzik b5a2d4b
#13: readded @SuppressWarnings("javadoc")
MattesMrzik 208b39d
Merge branch 'main' into feature/#13-implement-ToolCommandlet-for-AWS…
MattesMrzik fa619a9
Merge branch 'main' into feature/#13-implement-ToolCommandlet-for-AWS…
hohwille af01a32
Update cli/src/main/java/com/devonfw/tools/ide/tool/aws/Aws.java
MattesMrzik 88b0e48
#13: removed paths.add(path) in SystemPath.setPath
MattesMrzik e521c6b
Merge branch 'main' of https://github.com/devonfw/IDEasy into feature…
MattesMrzik 0c241ff
Merge branch 'feature/#13-implement-ToolCommandlet-for-AWS-CLI' of ht…
MattesMrzik 05f1576
#13: added url to TODO issue
MattesMrzik f255f75
#13: added missing import
MattesMrzik ce21ca6
Merge branch 'main' into feature/#13-implement-ToolCommandlet-for-AWS…
MattesMrzik c358890
Merge branch 'main' into feature/#13-implement-ToolCommandlet-for-AWS…
hohwille File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
cli/src/main/java/com/devonfw/tools/ide/tool/aws/Aws.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| package com.devonfw.tools.ide.tool.aws; | ||
|
|
||
| import java.io.IOException; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.attribute.PosixFilePermission; | ||
| import java.util.Set; | ||
|
|
||
| import com.devonfw.tools.ide.common.Tag; | ||
| 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.process.ProcessContext; | ||
| import com.devonfw.tools.ide.tool.LocalToolCommandlet; | ||
|
|
||
| /** | ||
| * {@link LocalToolCommandlet} for AWS CLI (aws). | ||
| * | ||
| * @see <a href="https://docs.aws.amazon.com/cli/">AWS CLI homepage</a> | ||
| */ | ||
|
|
||
| public class Aws extends LocalToolCommandlet { | ||
|
|
||
| /** | ||
| * The constructor. | ||
| * | ||
| * @param context the {@link IdeContext}. | ||
| */ | ||
| public Aws(IdeContext context) { | ||
|
|
||
| super(context, "aws", Set.of(Tag.CLOUD)); | ||
| } | ||
|
|
||
| private void makeExecutable(Path file) { | ||
|
|
||
| // TODO this can be removed if issue #132 is fixed. See https://github.com/devonfw/IDEasy/issues/132 | ||
| Set<PosixFilePermission> permissions = null; | ||
| try { | ||
| permissions = Files.getPosixFilePermissions(file); | ||
| permissions.add(PosixFilePermission.GROUP_EXECUTE); | ||
| permissions.add(PosixFilePermission.OWNER_EXECUTE); | ||
| permissions.add(PosixFilePermission.OTHERS_EXECUTE); | ||
| Files.setPosixFilePermissions(file, permissions); | ||
| } catch (IOException e) { | ||
| throw new RuntimeException("Adding execution permission for Group, Owner and Others did not work for " + file, e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected void moveAndProcessExtraction(Path from, Path to) { | ||
|
|
||
| if (this.context.getSystemInfo().isLinux()) { | ||
| // make binary executable using java nio because unpacking didn't preserve the file permissions | ||
| // TODO this can be removed if issue #132 is fixed | ||
| Path awsInDistPath = from.resolve("dist").resolve("aws"); | ||
| Path awsCompleterInDistPath = from.resolve("dist").resolve("aws_completer"); | ||
| makeExecutable(awsInDistPath); | ||
| makeExecutable(awsCompleterInDistPath); | ||
|
|
||
| // running the install-script that aws shipped | ||
| ProcessContext pc = this.context.newProcess(); | ||
| Path linuxInstallScript = from.resolve("install"); | ||
| pc.executable(linuxInstallScript); | ||
| pc.addArgs("-i", from.toString(), "-b", from.toString()); | ||
| pc.run(); | ||
hohwille marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // The install-script that aws ships creates symbolic links to binaries but using absolute paths. | ||
| // Since the current process happens in a temporary dir, these links wouldn't be valid after moving the | ||
| // installation files to the target dir. So the absolute paths are replaced by relative ones. | ||
| for (String file : new String[] { "aws", "aws_completer", Path.of("v2").resolve("current").toString() }) { | ||
| Path link = from.resolve(file); | ||
| try { | ||
| this.context.getFileAccess().symlink(link.toRealPath(), link, true); | ||
| } catch (IOException e) { | ||
| throw new RuntimeException( | ||
| "Failed to replace absolute link (" + link + ") provided by AWS install script with relative link.", e); | ||
| } | ||
| } | ||
| this.context.getFileAccess().delete(linuxInstallScript); | ||
| this.context.getFileAccess().delete(from.resolve("dist")); | ||
| } | ||
| super.moveAndProcessExtraction(from, to); | ||
| } | ||
|
|
||
| @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(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.