Skip to content

Commit

Permalink
fix (aws/lambda): patch broken translation of uuid fields by object m…
Browse files Browse the repository at this point in the history
…apper (#4892)

Co-authored-by: smaniyedath <shyam_maniyedath@intuit.com>
  • Loading branch information
shyamsfo and shyamsfo committed Sep 16, 2020
1 parent e611e4a commit bdc2f7c
Showing 1 changed file with 21 additions and 2 deletions.
Expand Up @@ -23,7 +23,7 @@
import com.netflix.spinnaker.cats.cache.Cache;
import com.netflix.spinnaker.cats.cache.CacheData;
import com.netflix.spinnaker.clouddriver.lambda.cache.model.LambdaFunction;
import java.util.Map;
import java.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

Expand All @@ -39,6 +39,25 @@ public LambdaCacheClient(Cache cacheView) {
@Override
protected LambdaFunction convert(CacheData cacheData) {
Map<String, Object> attributes = cacheData.getAttributes();
return objectMapper.convertValue(attributes, LambdaFunction.class);
LambdaFunction lambdaFunction = objectMapper.convertValue(attributes, LambdaFunction.class);
// Fix broken translation of uuid fields. Perhaps this is better fixed by configuring the
// objectMapper right
List<Map> eventSourceMappings = (List<Map>) attributes.get("eventSourceMappings");
if (eventSourceMappings == null) {
return lambdaFunction;
}
Map<String, String> arnUuidMap = new HashMap<>();
eventSourceMappings.stream()
.forEach(
xx -> {
arnUuidMap.put((String) xx.get("eventSourceArn"), (String) xx.get("uuid"));
});
lambdaFunction
.getEventSourceMappings()
.forEach(
currMapping -> {
currMapping.setUUID((String) arnUuidMap.get("uuid"));
});
return lambdaFunction;
}
}

0 comments on commit bdc2f7c

Please sign in to comment.