-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
402c6b6
commit e1a519f
Showing
11 changed files
with
226 additions
and
18 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
extensions/extensions-helm/aissemble-jenkins-chart/values.yaml
This file contains 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,10 @@ | ||
# Default values for aissemble-jenkins. | ||
jenkins: | ||
controller: | ||
image: ghcr.io/boozallen/aissemble-jenkins-controller | ||
# note the official chart does not use the controller tag value for testing, so disabling here | ||
testEnabled: false | ||
tag: "1.8.1-SNAPSHOT" | ||
agent: | ||
image: ghcr.io/boozallen/aissemble-jenkins-agent | ||
tag: "1.8.1-SNAPSHOT" |
This file contains 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
45 changes: 45 additions & 0 deletions
45
...upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/AbstractPomMigration.java
This file contains 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,45 @@ | ||
package com.boozallen.aissemble.upgrade.migration; | ||
|
||
/*- | ||
* #%L | ||
* aiSSEMBLE::Foundation::Upgrade | ||
* %% | ||
* Copyright (C) 2021 Booz Allen | ||
* %% | ||
* This software package is licensed under the Booz Allen Public License. All Rights Reserved. | ||
* #L% | ||
*/ | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.technologybrewery.baton.BatonException; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.util.stream.Stream; | ||
|
||
public abstract class AbstractPomMigration extends AbstractAissembleMigration { | ||
protected static final Logger logger = LoggerFactory.getLogger(AbstractPomMigration.class); | ||
|
||
public static final String POM = "pom"; | ||
public static final String GUARANTEED_TAG = "<modelVersion>"; | ||
|
||
protected String indent; | ||
|
||
protected void detectAndSetIndent(File file) { | ||
try (Stream<String> lines = Files.lines(file.toPath())) { | ||
indent = lines.filter(line -> line.contains(GUARANTEED_TAG)) | ||
.findFirst() | ||
.map(artifact -> artifact.substring(0, artifact.indexOf(GUARANTEED_TAG))) | ||
.orElse(null); | ||
if (StringUtils.isEmpty(indent)) { | ||
logger.info("Failed to detect indent for POM. Using default. {}", file); | ||
indent = " "; | ||
} | ||
} catch (IOException e) { | ||
throw new BatonException("Failed to get indent from POM:" + file, e); | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...dation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/util/AissembleFileUtils.java
This file contains 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,39 @@ | ||
package com.boozallen.aissemble.upgrade.util; | ||
|
||
/*- | ||
* #%L | ||
* aiSSEMBLE::Foundation::Upgrade | ||
* %% | ||
* Copyright (C) 2021 Booz Allen | ||
* %% | ||
* This software package is licensed under the Booz Allen Public License. All Rights Reserved. | ||
* #L% | ||
*/ | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
public class AissembleFileUtils { | ||
|
||
/** | ||
* Copy lines between startLine and endLine, inclusive, from the file. | ||
* | ||
* @param file the file to copy lines from | ||
* @param startLine the index of the first line to copy | ||
* @param endLine the index of the last line to copy | ||
* @return a list of the copied lines | ||
*/ | ||
public static List<String> getLines(Path file, int startLine, int endLine) { | ||
try (Stream<String> lines = Files.lines(file)) { | ||
return lines.skip(startLine) | ||
.limit(endLine - startLine + 1) | ||
.collect(Collectors.toList()); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
This file contains 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
46 changes: 46 additions & 0 deletions
46
...src/test/java/com/boozallen/aissemble/upgrade/migration/utils/AissembleFileUtilSteps.java
This file contains 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,46 @@ | ||
package com.boozallen.aissemble.upgrade.migration.utils; | ||
|
||
/*- | ||
* #%L | ||
* aiSSEMBLE::Foundation::Upgrade | ||
* %% | ||
* Copyright (C) 2021 Booz Allen | ||
* %% | ||
* This software package is licensed under the Booz Allen Public License. All Rights Reserved. | ||
* #L% | ||
*/ | ||
|
||
import com.boozallen.aissemble.upgrade.util.AissembleFileUtils; | ||
import io.cucumber.java.en.Given; | ||
import io.cucumber.java.en.Then; | ||
import io.cucumber.java.en.When; | ||
import org.junit.Assert; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.StandardOpenOption; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class AissembleFileUtilSteps { | ||
|
||
private Path testFile = Path.of("target/test.txt"); | ||
private List<String> fetchedLines; | ||
|
||
@Given("a file with the contents:") | ||
public void aFileWithTheContents(String contents) throws IOException { | ||
Files.write(testFile, contents.getBytes(), StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE); | ||
} | ||
|
||
@When("I retrieve the lines {int} to {int} of the file") | ||
public void iRetrieveTheLinesStartToEndOfTheFile(int start, int end) { | ||
fetchedLines = AissembleFileUtils.getLines(testFile, start, end); | ||
} | ||
|
||
@Then("the lines should be {string}") | ||
public void theLinesShouldBe(String expected) { | ||
List<String> expectedLines = expected.lines().collect(Collectors.toList()); | ||
Assert.assertEquals("getLines fetched incorrect content", expectedLines, fetchedLines); | ||
} | ||
} |
This file contains 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 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 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 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
20 changes: 20 additions & 0 deletions
20
foundation/foundation-upgrade/src/test/resources/specifications/file-util.feature
This file contains 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,20 @@ | ||
Feature: Common File Operations | ||
|
||
Scenario Outline: Retrieve lines | ||
Given a file with the contents: | ||
""" | ||
first line | ||
second line | ||
third line | ||
fourth line | ||
""" | ||
When I retrieve the lines <start> to <end> of the file | ||
Then the lines should be "<lines>" | ||
|
||
Examples: | ||
| start | end | lines | | ||
| 0 | 2 | first line\nsecond line\nthird line | | ||
| 1 | 2 | second line\nthird line | | ||
| 2 | 3 | third line\nfourth line | | ||
| 0 | 99 | first line\nsecond line\nthird line\nfourth line | | ||
|