class TemplateDecorator {

    public Template decorate(Credential credential, Template template, String region, String availabilityZone, String variant, CdpResourceType cdpResourceType) {
        setRootVolumeSize(template);
        PlatformDisks platformDisks = cloudParameterService.getDiskTypes();
        CloudVmTypes vmTypesV2 = cloudParameterService.getVmTypesV2(
                extendedCloudCredentialConverter.convert(credential),
                region,
                variant,
                cdpResourceType,
                new HashMap<>());
        String locationString = locationService.location(region, availabilityZone);
        VolumeParameterConfig config;
        for (VolumeTemplate volumeTemplate : template.getVolumeTemplates()) {
            try {
                config = resolveVolumeParameterConfig(template, volumeTemplate, platformDisks, vmTypesV2, locationString);
            } catch (NoSuchElementException ignored) {
                LOGGER.debug("No VolumeParameterConfig found, which might be normal for platforms like OpenStack");
                config = VolumeParameterConfig.EMPTY;
            }

            if (config.volumeParameterType() != null) {
                if (volumeTemplate.getVolumeCount() == null) {
                    volumeTemplate.setVolumeCount(config.maximumNumber());
                }
                if (volumeTemplate.getVolumeSize() == null) {
                    volumeTemplate.setVolumeSize(config.maximumSize());
                }
            }
        }

        return template;
    }

}