Skip to content

Commit 3d97f64

Browse files
author
dakodakov
authored
Fix git url pattern. Make it configurable (#3426)
1 parent 20bdcd7 commit 3d97f64

File tree

6 files changed

+12
-5
lines changed

6 files changed

+12
-5
lines changed

projects/control-service/projects/helm_charts/pipelines-control-service/templates/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ spec:
8181
value: "{{ .Values.deploymentGitUsername }}"
8282
- name: GIT_PASSWORD
8383
value: "{{ .Values.deploymentGitPassword }}"
84+
- name: GIT_URL_PATTERN
85+
value: "{{ .Values.deploymentGitUrlPattern }}"
8486
- name: AWS_REGION
8587
value: "{{ .Values.deploymentEcrAwsRegion }}"
8688
- name: AWS_ACCESS_KEY_ID

projects/control-service/projects/helm_charts/pipelines-control-service/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ deploymentGitRemote: "origin"
187187
# Credentials with read-only access to the Git repository.
188188
deploymentGitUsername: ""
189189
deploymentGitPassword: ""
190+
deploymentGitUrlPattern: "/tree/%s/%s"
190191
# Credentials with read and write access to the Git repository.
191192
uploadGitReadWriteUsername: ""
192193
uploadGitReadWritePassword: ""

projects/control-service/projects/pipelines_control_service/src/main/java/com/vmware/taurus/service/graphql/strategy/datajob/JobFieldStrategyBySourceUrl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,17 @@ public class JobFieldStrategyBySourceUrl extends FieldStrategy<V2DataJob> {
2424
private final String gitDataJobsUrl;
2525

2626
private final String getGitDataJobsBranch;
27+
private final String gitUrlPattern;
2728

2829
public JobFieldStrategyBySourceUrl(
2930
@Value("${datajobs.git.url}") String gitDataJobsUrl,
3031
@Value("${datajobs.git.branch}") String getGitDataJobsBranch,
32+
@Value("${datajobs.git.url.pattern:/tree/%s/%s}") String gitUrlPattern,
3133
@Value("${datajobs.git.ssl.enabled}") boolean gitDataJobsSslEnabled) {
3234

3335
this.gitDataJobsUrl = GitWrapper.constructCorrectGitUrl(gitDataJobsUrl, gitDataJobsSslEnabled);
3436
this.getGitDataJobsBranch = getGitDataJobsBranch;
37+
this.gitUrlPattern = gitUrlPattern;
3538
}
3639

3740
@Override
@@ -64,8 +67,8 @@ public void alterFieldData(V2DataJob dataJob) {
6467
StringUtils.stripFilenameExtension(gitDataJobsUrl)
6568
.concat(
6669
String.format(
67-
"/-/tree/%s/%s",
68-
getGitDataJobsBranch,
70+
this.gitUrlPattern,
71+
this.getGitDataJobsBranch,
6972
dataJob.getJobName())); // TODO in TAUR-1400, when deployments are implemented,
7073
// replace master
7174
config.setSourceUrl(sourceUrl);

projects/control-service/projects/pipelines_control_service/src/main/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ datajobs.git.url=${GIT_URL}
127127
datajobs.git.username=${GIT_USERNAME}
128128
datajobs.git.password=${GIT_PASSWORD}
129129
datajobs.git.branch=${GIT_BRANCH:master}
130+
datajobs.git.url.pattern=${GIT_URL_PATTERN:/tree/%s/%s}
130131
datajobs.git.remote=${GIT_REMOTE:origin}
131132
datajobs.git.ssl.enabled=${GIT_SSL_ENABLED:true}
132133
# The registry type, if left blank, defaults to ecr. The alternative registry type is generic

projects/control-service/projects/pipelines_control_service/src/test/java/com/vmware/taurus/service/graphql/GraphQLDataFetchersTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ private Set<FieldStrategy<V2DataJob>> collectSupportedFieldStrategies() {
547547
strategies.add(new JobFieldStrategyByName());
548548
strategies.add(new JobFieldStrategyByNextRun());
549549
strategies.add(new JobFieldStrategyByScheduleCron());
550-
strategies.add(new JobFieldStrategyBySourceUrl("gitlab.com/demo-data-jobs.git", "main", true));
550+
strategies.add(new JobFieldStrategyBySourceUrl("gitlab.com/demo-data-jobs.git", "main", "/tree/%s/%s",true));
551551
strategies.add(new JobFieldStrategyByTeam());
552552
strategies.add(new JobFieldStrategyByLastExecutionStatus());
553553
strategies.add(new JobFieldStrategyByLastExecutionTime());

projects/control-service/projects/pipelines_control_service/src/test/java/com/vmware/taurus/service/graphql/strategy/datajob/JobFieldStrategyBySourceUrlTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class JobFieldStrategyBySourceUrlTest {
2222
private static final String GIT_REPO_URL_FORMATTED = "https://gitlab.com/taurus/jobs";
2323
private static final String GIT_REPO_BRANCH = "main";
2424
private final JobFieldStrategyBySourceUrl strategyBySourceUrl =
25-
new JobFieldStrategyBySourceUrl(GIT_REPO_URL_RAW, GIT_REPO_BRANCH, true);
25+
new JobFieldStrategyBySourceUrl(GIT_REPO_URL_RAW, GIT_REPO_BRANCH, "/tree/%s/%s", true);
2626

2727
@Test
2828
void testJobSourceUrlStrategy_whenGettingStrategyName_shouldBeSpecific() {
@@ -38,7 +38,7 @@ void testJobSourceUrlStrategy_whenAlteringFieldData_shouldModifyState() {
3838

3939
assertThat(dataJob.getConfig().getSourceUrl())
4040
.isEqualTo(
41-
String.format("%s/-/tree/%s/%s", GIT_REPO_URL_FORMATTED, GIT_REPO_BRANCH, jobName));
41+
String.format("%s/tree/%s/%s", GIT_REPO_URL_FORMATTED, GIT_REPO_BRANCH, jobName));
4242
}
4343

4444
@Test

0 commit comments

Comments
 (0)