@Test public void testExecuteWithAnsibleLintStdOutput() throws IOException { Path baseDir = context.fileSystem().baseDirPath(); InputFile playbook = TestInputFileBuilder.create("moduleKey", baseDir.resolve("playbooks/playbook1.yml").toString()) .setModuleBaseDir(Paths.get(".")) .setContents(new String(Files.readAllBytes(baseDir.resolve("playbooks/playbook1.yml")))) .setLanguage(YamlLanguage.KEY) .setCharset(StandardCharsets.UTF_8) .build(); context.fileSystem().add(playbook); if (System.getProperty("os.name").toLowerCase().contains("windows")) { context.settings().appendProperty(AnsibleSettings.ANSIBLE_LINT_PATH_KEY, new File(getClass().getResource("/scripts/ansible-lint.cmd").getFile()).getAbsolutePath()); } else { String path = new File(getClass().getResource("/scripts/ansible-lint.sh").getFile()).getAbsolutePath(); context.settings().appendProperty(AnsibleSettings.ANSIBLE_LINT_PATH_KEY, path); Set<PosixFilePermission> perms = new HashSet<>(); perms.add(PosixFilePermission.OWNER_READ); perms.add(PosixFilePermission.OWNER_WRITE); perms.add(PosixFilePermission.OWNER_EXECUTE); perms.add(PosixFilePermission.GROUP_READ); perms.add(PosixFilePermission.GROUP_EXECUTE); perms.add(PosixFilePermission.OTHERS_READ); perms.add(PosixFilePermission.OTHERS_EXECUTE); Files.setPosixFilePermissions(Paths.get(path), perms); } sensor.execute(context); assertEquals(1, sensor.scannedFiles.size()); assertTrue(sensor.scannedFiles.contains(playbook)); Collection<Issue> issues = context.allIssues(); assertEquals(3, issues.size()); assertTrue(issueExists(issues, ruleKey1, playbook, 1, "A first error")); assertTrue(issueExists(issues, ruleKey2, playbook, 3, "An error -p")); assertTrue(issueExists(issues, ruleKey3, playbook, 5, "Another error --nocolor")); }
@Override public void execute(SensorContext context) { executeWithAnsibleLint(context, null); }
AnsibleSensor extends AbstractAnsibleSensor { @Override public void execute(SensorContext context) { executeWithAnsibleLint(context, null); } }
AnsibleSensor extends AbstractAnsibleSensor { @Override public void execute(SensorContext context) { executeWithAnsibleLint(context, null); } AnsibleSensor(FileSystem fileSystem); }
AnsibleSensor extends AbstractAnsibleSensor { @Override public void execute(SensorContext context) { executeWithAnsibleLint(context, null); } AnsibleSensor(FileSystem fileSystem); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context); }
AnsibleSensor extends AbstractAnsibleSensor { @Override public void execute(SensorContext context) { executeWithAnsibleLint(context, null); } AnsibleSensor(FileSystem fileSystem); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context);  }