use of com.amazonaws.services.cloudformation.model.Tag in project pipeline-aws-plugin by jenkinsci.
the class TagsFileParser method parseTags.
public static Collection<Tag> parseTags(InputStream is) throws IOException {
ObjectMapper mapper = new ObjectMapper();
JsonNode tree = mapper.readTree(is);
ArrayNode jsonNodes = (ArrayNode) tree;
return StreamSupport.stream(jsonNodes.spliterator(), false).map(node -> {
return new Tag().withKey(node.get("Key").asText()).withValue(node.get("Value").asText());
}).collect(Collectors.toList());
}
use of com.amazonaws.services.cloudformation.model.Tag in project pipeline-aws-plugin by jenkinsci.
the class TagsFileParserTests method parseJson.
@Test
public void parseJson() throws IOException {
Collection<Tag> tags = TagsFileParser.parseTags(getClass().getResourceAsStream("tags.json"));
Assertions.assertThat(tags).containsExactlyInAnyOrder(new Tag().withKey("foo1").withValue("bar1"), new Tag().withKey("foo2").withValue("bar2"));
}
use of com.amazonaws.services.cloudformation.model.Tag in project pipeline-aws-plugin by jenkinsci.
the class TemplateStepBase method getAwsTags.
protected final Collection<Tag> getAwsTags() {
Collection<Tag> tagList = new ArrayList<>();
if (this.tags == null) {
return tagList;
}
for (String tag : this.tags) {
int i = tag.indexOf('=');
if (i < 0) {
throw new IllegalArgumentException("Missing = in tag " + tag);
}
String key = tag.substring(0, i);
String value = tag.substring(i + 1);
tagList.add(new Tag().withKey(key).withValue(value));
}
return tagList;
}
use of com.amazonaws.services.cloudformation.model.Tag in project pipeline-aws-plugin by jenkinsci.
the class TemplateStepBase method getAwsTags.
protected final Collection<Tag> getAwsTags(StepExecution stepExecution) {
Collection<Tag> tagList = new ArrayList<>();
if (this.tags != null) {
for (String tag : this.tags) {
int i = tag.indexOf('=');
if (i < 0) {
throw new IllegalArgumentException("Missing = in tag " + tag);
}
String key = tag.substring(0, i);
String value = tag.substring(i + 1);
tagList.add(new Tag().withKey(key).withValue(value));
}
}
if (this.tagsFile != null) {
FilePath tagsFile = loadFileFromWorkspace(stepExecution, this.tagsFile);
try {
tagList.addAll(TagsFileParser.parseTags(tagsFile.read()));
} catch (IOException e) {
throw new UncheckedIOException(e);
} catch (InterruptedException e) {
Thread.interrupted();
throw new RuntimeException(e);
}
}
return tagList;
}
Aggregations