private List<EffectiveServiceSpec> mergeServiceSpec(List<File> serviceSpecFiles,
            Map<String, Entry<String, File>> serviceVsProfile) throws HyscaleException {

        List<EffectiveServiceSpec> effectiveServiceSpecList = new ArrayList<>();
        ObjectMapper mapper = null;

        for (File serviceSpecFile : serviceSpecFiles) {
            EffectiveServiceSpec effectiveServiceSpec = new EffectiveServiceSpec();
            ServiceMetadata serviceMetadata = new ServiceMetadata();
            effectiveServiceSpec.setServiceMetadata(serviceMetadata);
            mapper = ObjectMapperFactory.yamlMapper();
            String serviceName = ServiceSpecUtil.getServiceName(serviceSpecFile);
            serviceMetadata.setServiceName(serviceName);
            Entry<String, File> profileDetail = serviceVsProfile.remove(serviceName);
            String serviceSpecData = HyscaleFilesUtil.readFileData(serviceSpecFile);
            if (profileDetail != null) {
                String profileName = profileDetail.getKey();
                serviceMetadata.setEnvName(profileName);
                File profileFile = profileDetail.getValue();
                WorkflowLogger.startActivity(ControllerActivity.APPLYING_PROFILE_FOR_SERVICE, profileName, serviceName);
                mapper = ObjectMapperFactory.jsonMapper();
                try {
                    MapFieldDataProvider mapFieldDataProvider = new MapFieldDataProvider();
                    // Merge
                    serviceSpecData = new EffectiveServiceSpecBuilder().type(ServiceInputType.YAML)
                            .withServiceSpec(serviceSpecData).withProfile(HyscaleFilesUtil.readFileData(profileFile))
                            .withFieldMetaDataProvider(mapFieldDataProvider).build();
                    WorkflowLogger.endActivity(Status.DONE);
                } catch (HyscaleException e) {
                    logger.error("Error while applying profile {} for service {}", profileName, serviceName, e);
                    WorkflowLogger.endActivity(Status.FAILED);
                    throw e;
                }
            }
            if (serviceMetadata.getEnvName() == null) {
                serviceMetadata.setEnvName(WorkflowConstants.DEV_ENV);
            }
            try {
                effectiveServiceSpec.setServiceSpec(new ServiceSpec(mapper.readTree(serviceSpecData)));
                effectiveServiceSpecList.add(effectiveServiceSpec);
            } catch (IOException e) {
                logger.error("Error while processing service spec ", e);
                throw new HyscaleException(ControllerErrorCodes.SERVICE_SPEC_PROCESSING_FAILED, e.getMessage());
            }
        }
        return effectiveServiceSpecList;
    }
For each service spec file, read service spec data
if profile available for service spec
uses {@link EffectiveServiceSpecBuilder} to merge profile and spec
to get updated service spec data

Uses service spec data to create {@link ServiceSpec}

@param serviceSpecFiles
@param serviceVsProfile
@return List of {@link EffectiveServiceSpec}
@throws HyscaleException
workflow-controller/controller-service/src/main/java/io/hyscale/controller/provider/EffectiveServiceSpecProvider.java