-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added git chart repository working directory param
- Loading branch information
Showing
7 changed files
with
77 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 19 additions & 2 deletions
21
src/main/groovy/dk/kmd/helm/chart/publish/properties/WorkDirPropertiesProvider.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,34 @@ | ||
package dk.kmd.helm.chart.publish.properties | ||
|
||
import dk.kmd.helm.chart.publish.HelmChartPublisherExtension | ||
import org.gradle.api.Project | ||
|
||
class WorkDirPropertiesProvider { | ||
|
||
static String GIT_CHART_REPO_WORK_DIR_PROPERTY = "gitChartRepo.workDir" | ||
|
||
|
||
Project project | ||
HelmChartPublisherExtension extension | ||
|
||
WorkDirPropertiesProvider(Project project) { | ||
WorkDirPropertiesProvider(Project project, HelmChartPublisherExtension extension) { | ||
this.project = project | ||
this.extension = extension | ||
} | ||
|
||
WorkDirProperties provide() { | ||
return new WorkDirProperties(chartRepoTmpDirectory: "${project.buildDir}/helm-chart-repository") | ||
def chartRepoTmpDirectory = "${project.buildDir}/helm-chart-repository" | ||
return new WorkDirProperties(chartRepoTmpDirectory: chartRepoTmpDirectory, chartRepoWorkingDirectory: "${chartRepoTmpDirectory}/${chartRepositoryWorkDir()}") | ||
} | ||
|
||
|
||
private def chartRepositoryWorkDir() { | ||
if (project.hasProperty(GIT_CHART_REPO_WORK_DIR_PROPERTY)) { | ||
return project.property(GIT_CHART_REPO_WORK_DIR_PROPERTY) | ||
} | ||
if (extension.gitChartRepoWorkDir) { | ||
return extension.gitChartRepoWorkDir | ||
} | ||
return "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/test/groovy/dk/kmd/helm/chart/publish/properties/WorkDirPropertiesProviderTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package dk.kmd.helm.chart.publish.properties | ||
|
||
import static dk.kmd.helm.chart.publish.properties.TestDataProvider.extensionWithAnyParams | ||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.testfixtures.ProjectBuilder | ||
import spock.lang.Specification | ||
|
||
class WorkDirPropertiesProviderTest extends Specification { | ||
|
||
def "should resolve git chart repository work directory from properties"() { | ||
given: | ||
def givenWorkDir = randomAlphabetic(4) | ||
Project project = ProjectBuilder.builder().build() | ||
project.extensions.extraProperties.set("gitChartRepo.workDir", givenWorkDir) | ||
def extension = extensionWithAnyParams(gitChartRepoWorkDir: randomAlphabetic(4)) | ||
|
||
when: | ||
def result = new WorkDirPropertiesProvider(project, extension).provide() | ||
|
||
then: | ||
result.chartRepoWorkingDirectory == "${result.chartRepoTmpDirectory}/${givenWorkDir}" | ||
} | ||
|
||
def "should resolve git chart repository work directory from extension"() { | ||
given: | ||
def givenWorkDir = randomAlphabetic(4) | ||
Project project = ProjectBuilder.builder().build() | ||
def extension = extensionWithAnyParams(gitChartRepoWorkDir: givenWorkDir) | ||
|
||
when: | ||
def result = new WorkDirPropertiesProvider(project, extension).provide() | ||
|
||
then: | ||
result.chartRepoWorkingDirectory == "${result.chartRepoTmpDirectory}/${givenWorkDir}" | ||
} | ||
|
||
def "should resolve to empty if git chart repository work directory not set"() { | ||
given: | ||
def extension = extensionWithAnyParams(gitChartRepoWorkDir: null) | ||
|
||
|
||
when: | ||
def result = new WorkDirPropertiesProvider(ProjectBuilder.builder().build(), extension).provide() | ||
|
||
then: | ||
result.chartRepoWorkingDirectory == "${result.chartRepoTmpDirectory}/" | ||
} | ||
} |