File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 1
1
package com .redhat .labs .omp .models .gitlab ;
2
2
3
+ import java .util .ArrayList ;
3
4
import java .util .List ;
4
5
import java .util .Map ;
5
6
18
19
@ AllArgsConstructor
19
20
public class Project {
20
21
22
+ private static final String DO_NOT_DELETE = "DO_NOT_DELETE" ;
23
+
21
24
@ JsonbProperty ("id" )
22
25
private Integer id ;
23
26
@ NotBlank
@@ -143,4 +146,14 @@ public static Project from(ProjectSearchResults result) {
143
146
144
147
}
145
148
149
+ public void preserve () {
150
+ if (tagList == null ) {
151
+ tagList = new ArrayList <String >();
152
+ }
153
+
154
+ if (!tagList .contains (DO_NOT_DELETE )) {
155
+ tagList .add (DO_NOT_DELETE );
156
+ }
157
+ }
158
+
146
159
}
Original file line number Diff line number Diff line change 6
6
import javax .enterprise .context .ApplicationScoped ;
7
7
import javax .inject .Inject ;
8
8
9
+ import org .eclipse .microprofile .config .inject .ConfigProperty ;
9
10
import org .eclipse .microprofile .rest .client .inject .RestClient ;
10
11
import org .slf4j .Logger ;
11
12
import org .slf4j .LoggerFactory ;
@@ -23,6 +24,9 @@ public class ProjectService {
23
24
@ RestClient
24
25
GitLabService gitLabService ;
25
26
27
+ @ ConfigProperty (name = "engagements.do.not.delete" )
28
+ boolean doNotDelete ;
29
+
26
30
// get a project
27
31
public Optional <Project > getProjectByName (Integer namespaceId , String name )
28
32
throws UnexpectedGitLabResponseException {
@@ -80,6 +84,12 @@ public Optional<Project> createProject(Project project) {
80
84
81
85
Optional <Project > optional = Optional .empty ();
82
86
87
+ if (doNotDelete ) {
88
+ project .preserve ();
89
+ }
90
+
91
+ LOGGER .debug ("create project " + project );
92
+
83
93
// try to create project
84
94
Project createdProject = gitLabService .createProject (project );
85
95
if (null != createdProject ) {
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ config.file=${CONFIG_FILE:schema/config.yml}
30
30
31
31
# engagements
32
32
engagements.repository.id =${ENGAGEMENTS_REPOSITORY_ID:2}
33
+ engagements.do.not.delete =${ENGAGEMENTS_PRESERVE:false}
33
34
34
35
# version
35
36
git.commit =${GIT_API_GIT_COMMIT:not.set}
You can’t perform that action at this time.
0 commit comments