Skip to content

Commit

Permalink
Prepare deployment-dependencies file evolution (orange-cloudfoundry/c…
Browse files Browse the repository at this point in the history
  • Loading branch information
JCL38-ORANGE committed Jul 9, 2018
1 parent bbe25ea commit fe9845b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
6 changes: 4 additions & 2 deletions TODO-coabc.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ coab-depls/m_f49911f7-b69a-4aba-afdf-23fd11014278
- add systematic symlink of any secrets/ file
- regardless of their name if their present as file in this directory,

[TODO] https://github.com/orange-cloudfoundry/cf-ops-automation/issues/150
- review deployment-dependencies.yml generation. See
[DONE] https://github.com/orange-cloudfoundry/cf-ops-automation/issues/150
- [DONE]deployment-dependencies.yml generation as symlink
- [TODO]enable symlink generation instead of file generation
- [TODO]clean useless code (file generation)

[DONE]
- investigate intellij/maven handling of symlinks in resources and workarounds:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void generate(Path workDir, String serviceInstanceId, CoabVarsFileDto coa

//Generate deployment dependencies file
this.generateDeploymentDependenciesFile(workDir, serviceInstanceId);
//this.generateDeploymentDependenciesFileSymLink(workDir, serviceInstanceId);

//Generate coab vars file
this.generateCoabVarsFile(workDir, serviceInstanceId, coabVarsFileDto);
Expand Down Expand Up @@ -151,6 +152,13 @@ protected void generateDeploymentDependenciesFile(Path workDir, String serviceIn
StructureGeneratorHelper.generateFile(workDir, targetPathElements, sourceFileName, sourceFileName, mapDeploymentDependenciesFile);
}

protected void generateDeploymentDependenciesFileSymLink(Path workDir, String serviceInstanceId){
String[] sourcePathElements = new String[] {this.rootDeployment, this.modelDeployment};
String[] targetPathElements = new String[] {this.rootDeployment, this.computeDeploymentName(serviceInstanceId)};
String sourceFileName = DeploymentConstants.DEPLOYMENT_DEPENDENCIES_FILENAME;
StructureGeneratorHelper.generateSymbolicLink(workDir, sourcePathElements, targetPathElements, sourceFileName, sourceFileName);
}

protected void generateCoabVarsFile(Path workDir, String serviceInstanceId, CoabVarsFileDto coabVarsFileDto){
String[] targetPathElements = new String[] {this.rootDeployment, this.computeDeploymentName(serviceInstanceId), DeploymentConstants.TEMPLATE};
String sourceFileName = DeploymentConstants.COAB + DeploymentConstants.HYPHEN + DeploymentConstants.VARS + DeploymentConstants.YML_EXTENSION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,31 @@ public void check_that_symlink_towards_coab_operators_file_is_generated() throws
DeploymentConstants.COAB + DeploymentConstants.COA_OPERATORS_FILE_SUFFIX)));
}

@Test
public void check_that_symlink_towards_deployment_dependencies_file_is_generated() throws Exception {
//Given repository, root deployment,model deployment and operators directory with coab-operators file
Structure modelStructure = new Structure.StructureBuilder(this.workDir)
.withFile(new String[]{this.deploymentProperties.getRootDeployment(), this.deploymentProperties.getModelDeployment()},
DeploymentConstants.DEPLOYMENT_DEPENDENCIES_FILENAME)
.build();
Structure deploymentStructure = new Structure.StructureBuilder(this.workDir)
.withDirectoryHierarchy(this.deploymentProperties.getRootDeployment(), this.templatesGenerator.computeDeploymentName(SERVICE_INSTANCE_ID))
.build();

//When
this.templatesGenerator.generateDeploymentDependenciesFileSymLink(this.workDir, SERVICE_INSTANCE_ID);

//Then
Path targetDeploymentDependenciesFile = StructureGeneratorHelper.generatePath(this.workDir,
this.deploymentProperties.getRootDeployment(),
this.templatesGenerator.computeDeploymentName(SERVICE_INSTANCE_ID),
DeploymentConstants.DEPLOYMENT_DEPENDENCIES_FILENAME);
assertThat("Symbolic link towards deployment dependencies file doesn't exist", Files.exists(targetDeploymentDependenciesFile));
assertThat("Deployment dependencies file is not a symbolic link", Files.isSymbolicLink(targetDeploymentDependenciesFile));
assertThat(Files.readSymbolicLink(targetDeploymentDependenciesFile).toString(), is(equalTo("../" + this.deploymentProperties.getModelDeployment() +
File.separator + DeploymentConstants.DEPLOYMENT_DEPENDENCIES_FILENAME)));
}

@Test
public void check_that_all_symlinks_templates_directory_are_generated() throws Exception {

Expand Down

0 comments on commit fe9845b

Please sign in to comment.