use of com.netflix.spinnaker.front50.model.pipeline.PipelineTemplate in project front50 by spinnaker.
the class PipelineTemplateController method update.
@RequestMapping(value = "{id}", method = RequestMethod.PUT)
PipelineTemplate update(@PathVariable String id, @RequestBody PipelineTemplate pipelineTemplate) {
PipelineTemplate existingPipelineTemplate = getPipelineTemplateDAO().findById(id);
if (!pipelineTemplate.getId().equals(existingPipelineTemplate.getId())) {
throw new InvalidRequestException("The provided id " + id + " doesn't match the pipeline template id " + pipelineTemplate.getId());
}
pipelineTemplate.setLastModified(System.currentTimeMillis());
getPipelineTemplateDAO().update(id, pipelineTemplate);
return pipelineTemplate;
}
use of com.netflix.spinnaker.front50.model.pipeline.PipelineTemplate in project front50 by spinnaker.
the class V2PipelineTemplateController method get.
@RequestMapping(value = "{id}", method = RequestMethod.GET)
PipelineTemplate get(@PathVariable String id, @RequestParam(value = "tag", required = false) String tag, @RequestParam(value = "digest", required = false) String digest) {
String templateId = formatId(id, tag, digest);
// We don't need to surface our internal accounting information to the user.
// This would muddle the API and probably be bug-friendly.
PipelineTemplate foundTemplate = getPipelineTemplateDAO().findById(templateId);
foundTemplate.remove("digest");
foundTemplate.remove("tag");
return foundTemplate;
}
use of com.netflix.spinnaker.front50.model.pipeline.PipelineTemplate in project front50 by spinnaker.
the class V2PipelineTemplateController method computeSHA256Digest.
@VisibleForTesting
public String computeSHA256Digest(PipelineTemplate pipelineTemplate) {
Map<String, Object> sortedMap = (Map<String, Object>) sortObjectRecursive(pipelineTemplate);
try {
String jsonPayload = objectMapper.writeValueAsString(sortedMap).replaceAll("\\s+", "");
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hashBytes = digest.digest(jsonPayload.getBytes(StandardCharsets.UTF_8));
return Hex.encodeHexString(hashBytes);
} catch (NoSuchAlgorithmException | JsonProcessingException e) {
throw new InvalidRequestException(String.format("Computing digest for pipeline template %s failed. Nested exception is %s", pipelineTemplate.undecoratedId(), e));
}
}
Aggregations