use of org.alien4cloud.tosca.editor.exception.UnsupportedSecretException in project alien4cloud by alien4cloud.
the class SetNodeCapabilityPropertyAsSecretProcessor method processNodeOperation.
@Override
protected void processNodeOperation(Csar csar, Topology topology, SetNodeCapabilityPropertyAsSecretOperation operation, NodeTemplate nodeTemplate) {
Capability capabilityTemplate = getOrFail(nodeTemplate.getCapabilities(), operation.getCapabilityName(), "Capability {} does not exist for node {}", operation.getCapabilityName(), operation.getNodeName());
CapabilityType capabilityType = ToscaContext.get(CapabilityType.class, capabilityTemplate.getType());
getOrFail(capabilityType.getProperties(), operation.getPropertyName(), "Property {} do not exist for capability {} of node {}", operation.getPropertyName(), operation.getCapabilityName(), operation.getNodeName());
if (operation.getCapabilityName().equals(FORBIDDEN_CAPABILITY)) {
throw new UnsupportedSecretException("We cannot set a secret on the capability " + operation.getCapabilityName());
}
if ("".equals(operation.getSecretPath())) {
throw new InvalidSecretPathException("The secret path to the property " + operation.getPropertyName() + "is null.");
}
FunctionPropertyValue getSecret = new FunctionPropertyValue();
getSecret.setFunction(ToscaFunctionConstants.GET_SECRET);
getSecret.setParameters(Arrays.asList(operation.getSecretPath()));
nodeTemplate.getCapabilities().get(operation.getCapabilityName()).getProperties().put(operation.getPropertyName(), getSecret);
log.debug("Set the property [ {} ] of capability template [ {} ] of node [ {} ] to the secret path [ {} ].", operation.getPropertyName(), operation.getCapabilityName(), operation.getNodeName(), topology.getId());
}
use of org.alien4cloud.tosca.editor.exception.UnsupportedSecretException in project alien4cloud by alien4cloud.
the class SetNodePropertyAsSecretProcessor method processNodeOperation.
@Override
protected void processNodeOperation(Csar csar, Topology topology, SetNodePropertyAsSecretOperation operation, NodeTemplate nodeTemplate) {
NodeType indexedNodeType = ToscaContext.get(NodeType.class, nodeTemplate.getType());
getOrFail(indexedNodeType.getProperties(), operation.getPropertyName(), "Property {} do not exist for node {}", operation.getPropertyName(), operation.getNodeName());
if (operation.getPropertyName().equals(FORBIDDEN_PROPERTY)) {
throw new UnsupportedSecretException("We cannot set a secret on the property " + operation.getPropertyName());
}
if ("".equals(operation.getSecretPath())) {
throw new InvalidSecretPathException("The secret path to the property " + operation.getPropertyName() + " is null.");
}
FunctionPropertyValue getSecret = new FunctionPropertyValue();
getSecret.setFunction(ToscaFunctionConstants.GET_SECRET);
getSecret.setParameters(Arrays.asList(operation.getSecretPath()));
nodeTemplate.getProperties().put(operation.getPropertyName(), getSecret);
log.debug("Associate the property [ {} ] of the node template [ {} ] as secret [ {} ] of the topology [ {} ].", operation.getPropertyName(), operation.getNodeName(), operation.getSecretPath(), topology.getId());
}
Aggregations