• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 9907372175

12 Jul 2024 11:49AM UTC coverage: 61.142% (-0.02%) from 61.162%
9907372175

push

github

hohwille
fixed tests

1997 of 3595 branches covered (55.55%)

Branch coverage included in aggregate %.

5296 of 8333 relevant lines covered (63.55%)

2.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

5.71
cli/src/main/java/com/devonfw/tools/ide/tool/aws/Aws.java
1
package com.devonfw.tools.ide.tool.aws;
2

3
import java.io.IOException;
4
import java.nio.file.Path;
5
import java.util.Set;
6

7
import com.devonfw.tools.ide.common.Tag;
8
import com.devonfw.tools.ide.context.IdeContext;
9
import com.devonfw.tools.ide.environment.EnvironmentVariables;
10
import com.devonfw.tools.ide.environment.EnvironmentVariablesType;
11
import com.devonfw.tools.ide.io.FileAccess;
12
import com.devonfw.tools.ide.nls.NlsBundle;
13
import com.devonfw.tools.ide.process.ProcessContext;
14
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
15

16
/**
17
 * {@link LocalToolCommandlet} for <a href="https://docs.aws.amazon.com/cli/">AWS CLI</a> (Amazon Web Services Command Line Interface).
18
 */
19
public class Aws extends LocalToolCommandlet {
20

21
  /**
22
   * The constructor.
23
   *
24
   * @param context the {@link IdeContext}.
25
   */
26
  public Aws(IdeContext context) {
27

28
    super(context, "aws", Set.of(Tag.CLOUD));
6✔
29
  }
1✔
30

31
  @Override
32
  public void postInstall() {
33

34
    super.postInstall();
×
35
    EnvironmentVariables variables = this.context.getVariables();
×
36
    EnvironmentVariables typeVariables = variables.getByType(EnvironmentVariablesType.CONF);
×
37
    Path awsConfigDir = this.context.getConfPath().resolve("aws");
×
38
    this.context.getFileAccess().mkdirs(awsConfigDir);
×
39
    Path awsConfigFile = awsConfigDir.resolve("config");
×
40
    Path awsCredentialsFile = awsConfigDir.resolve("credentials");
×
41
    typeVariables.set("AWS_CONFIG_FILE", awsConfigFile.toString(), true);
×
42
    typeVariables.set("AWS_SHARED_CREDENTIALS_FILE", awsCredentialsFile.toString(), true);
×
43
    typeVariables.save();
×
44
  }
×
45

46
  @Override
47
  protected void postExtract(Path extractedDir) {
48

49
    if (this.context.getSystemInfo().isLinux()) {
×
50
      // running the install-script that aws shipped
51
      ProcessContext pc = this.context.newProcess();
×
52
      Path linuxInstallScript = extractedDir.resolve("install");
×
53
      pc.executable(linuxInstallScript);
×
54
      pc.addArgs("-i", extractedDir.toString(), "-b", extractedDir.toString());
×
55
      pc.run();
×
56

57
      // The install-script that aws ships creates symbolic links to binaries but using absolute paths.
58
      // Since the current process happens in a temporary dir, these links wouldn't be valid after moving the
59
      // installation files to the target dir. So the absolute paths are replaced by relative ones.
60
      FileAccess fileAccess = this.context.getFileAccess();
×
61
      for (String file : new String[] { "aws", "aws_completer", "v2/current" }) {
×
62
        Path link = extractedDir.resolve(file);
×
63
        try {
64
          fileAccess.symlink(link.toRealPath(), link, true);
×
65
        } catch (IOException e) {
×
66
          throw new RuntimeException(
×
67
              "Failed to replace absolute link (" + link + ") provided by AWS install script with relative link.", e);
68
        }
×
69
      }
70
      fileAccess.delete(linuxInstallScript);
×
71
      fileAccess.delete(extractedDir.resolve("dist"));
×
72
    }
73
  }
×
74

75
  @Override
76
  public void printHelp(NlsBundle bundle) {
77

78
    this.context.info("To get detailed help about the usage of the AWS CLI, use \"aws help\"");
×
79
  }
×
80

81
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc