@@ -75,7 +75,9 @@ public class BuildRequest {
75
75
76
76
private final List <ImageReference > tags ;
77
77
78
- private final Map <String , String > cacheVolumeNames ;
78
+ private final Cache buildCache ;
79
+
80
+ private final Cache launchCache ;
79
81
80
82
BuildRequest (ImageReference name , Function <Owner , TarArchive > applicationContent ) {
81
83
Assert .notNull (name , "Name must not be null" );
@@ -94,13 +96,14 @@ public class BuildRequest {
94
96
this .bindings = Collections .emptyList ();
95
97
this .network = null ;
96
98
this .tags = Collections .emptyList ();
97
- this .cacheVolumeNames = Collections .emptyMap ();
99
+ this .buildCache = null ;
100
+ this .launchCache = null ;
98
101
}
99
102
100
103
BuildRequest (ImageReference name , Function <Owner , TarArchive > applicationContent , ImageReference builder ,
101
104
ImageReference runImage , Creator creator , Map <String , String > env , boolean cleanCache ,
102
105
boolean verboseLogging , PullPolicy pullPolicy , boolean publish , List <BuildpackReference > buildpacks ,
103
- List <Binding > bindings , String network , List <ImageReference > tags , Map < String , String > cacheVolumeNames ) {
106
+ List <Binding > bindings , String network , List <ImageReference > tags , Cache buildCache , Cache launchCache ) {
104
107
this .name = name ;
105
108
this .applicationContent = applicationContent ;
106
109
this .builder = builder ;
@@ -115,7 +118,8 @@ public class BuildRequest {
115
118
this .bindings = bindings ;
116
119
this .network = network ;
117
120
this .tags = tags ;
118
- this .cacheVolumeNames = cacheVolumeNames ;
121
+ this .buildCache = buildCache ;
122
+ this .launchCache = launchCache ;
119
123
}
120
124
121
125
/**
@@ -127,7 +131,7 @@ public BuildRequest withBuilder(ImageReference builder) {
127
131
Assert .notNull (builder , "Builder must not be null" );
128
132
return new BuildRequest (this .name , this .applicationContent , builder .inTaggedOrDigestForm (), this .runImage ,
129
133
this .creator , this .env , this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish ,
130
- this .buildpacks , this .bindings , this .network , this .tags , this .cacheVolumeNames );
134
+ this .buildpacks , this .bindings , this .network , this .tags , this .buildCache , this . launchCache );
131
135
}
132
136
133
137
/**
@@ -138,7 +142,7 @@ public BuildRequest withBuilder(ImageReference builder) {
138
142
public BuildRequest withRunImage (ImageReference runImageName ) {
139
143
return new BuildRequest (this .name , this .applicationContent , this .builder , runImageName .inTaggedOrDigestForm (),
140
144
this .creator , this .env , this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish ,
141
- this .buildpacks , this .bindings , this .network , this .tags , this .cacheVolumeNames );
145
+ this .buildpacks , this .bindings , this .network , this .tags , this .buildCache , this . launchCache );
142
146
}
143
147
144
148
/**
@@ -150,7 +154,7 @@ public BuildRequest withCreator(Creator creator) {
150
154
Assert .notNull (creator , "Creator must not be null" );
151
155
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , creator , this .env ,
152
156
this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish , this .buildpacks , this .bindings ,
153
- this .network , this .tags , this .cacheVolumeNames );
157
+ this .network , this .tags , this .buildCache , this . launchCache );
154
158
}
155
159
156
160
/**
@@ -166,7 +170,7 @@ public BuildRequest withEnv(String name, String value) {
166
170
env .put (name , value );
167
171
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator ,
168
172
Collections .unmodifiableMap (env ), this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish ,
169
- this .buildpacks , this .bindings , this .network , this .tags , this .cacheVolumeNames );
173
+ this .buildpacks , this .bindings , this .network , this .tags , this .buildCache , this . launchCache );
170
174
}
171
175
172
176
/**
@@ -180,7 +184,8 @@ public BuildRequest withEnv(Map<String, String> env) {
180
184
updatedEnv .putAll (env );
181
185
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator ,
182
186
Collections .unmodifiableMap (updatedEnv ), this .cleanCache , this .verboseLogging , this .pullPolicy ,
183
- this .publish , this .buildpacks , this .bindings , this .network , this .tags , this .cacheVolumeNames );
187
+ this .publish , this .buildpacks , this .bindings , this .network , this .tags , this .buildCache ,
188
+ this .launchCache );
184
189
}
185
190
186
191
/**
@@ -191,7 +196,7 @@ public BuildRequest withEnv(Map<String, String> env) {
191
196
public BuildRequest withCleanCache (boolean cleanCache ) {
192
197
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
193
198
cleanCache , this .verboseLogging , this .pullPolicy , this .publish , this .buildpacks , this .bindings ,
194
- this .network , this .tags , this .cacheVolumeNames );
199
+ this .network , this .tags , this .buildCache , this . launchCache );
195
200
}
196
201
197
202
/**
@@ -202,7 +207,7 @@ public BuildRequest withCleanCache(boolean cleanCache) {
202
207
public BuildRequest withVerboseLogging (boolean verboseLogging ) {
203
208
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
204
209
this .cleanCache , verboseLogging , this .pullPolicy , this .publish , this .buildpacks , this .bindings ,
205
- this .network , this .tags , this .cacheVolumeNames );
210
+ this .network , this .tags , this .buildCache , this . launchCache );
206
211
}
207
212
208
213
/**
@@ -213,7 +218,7 @@ public BuildRequest withVerboseLogging(boolean verboseLogging) {
213
218
public BuildRequest withPullPolicy (PullPolicy pullPolicy ) {
214
219
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
215
220
this .cleanCache , this .verboseLogging , pullPolicy , this .publish , this .buildpacks , this .bindings ,
216
- this .network , this .tags , this .cacheVolumeNames );
221
+ this .network , this .tags , this .buildCache , this . launchCache );
217
222
}
218
223
219
224
/**
@@ -224,7 +229,7 @@ public BuildRequest withPullPolicy(PullPolicy pullPolicy) {
224
229
public BuildRequest withPublish (boolean publish ) {
225
230
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
226
231
this .cleanCache , this .verboseLogging , this .pullPolicy , publish , this .buildpacks , this .bindings ,
227
- this .network , this .tags , this .cacheVolumeNames );
232
+ this .network , this .tags , this .buildCache , this . launchCache );
228
233
}
229
234
230
235
/**
@@ -248,7 +253,7 @@ public BuildRequest withBuildpacks(List<BuildpackReference> buildpacks) {
248
253
Assert .notNull (buildpacks , "Buildpacks must not be null" );
249
254
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
250
255
this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish , buildpacks , this .bindings ,
251
- this .network , this .tags , this .cacheVolumeNames );
256
+ this .network , this .tags , this .buildCache , this . launchCache );
252
257
}
253
258
254
259
/**
@@ -272,7 +277,7 @@ public BuildRequest withBindings(List<Binding> bindings) {
272
277
Assert .notNull (bindings , "Bindings must not be null" );
273
278
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
274
279
this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish , this .buildpacks , bindings ,
275
- this .network , this .tags , this .cacheVolumeNames );
280
+ this .network , this .tags , this .buildCache , this . launchCache );
276
281
}
277
282
278
283
/**
@@ -284,7 +289,7 @@ public BuildRequest withBindings(List<Binding> bindings) {
284
289
public BuildRequest withNetwork (String network ) {
285
290
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
286
291
this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish , this .buildpacks , this .bindings ,
287
- network , this .tags , this .cacheVolumeNames );
292
+ network , this .tags , this .buildCache , this . launchCache );
288
293
}
289
294
290
295
/**
@@ -306,39 +311,31 @@ public BuildRequest withTags(List<ImageReference> tags) {
306
311
Assert .notNull (tags , "Tags must not be null" );
307
312
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
308
313
this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish , this .buildpacks , this .bindings ,
309
- this .network , tags , this .cacheVolumeNames );
314
+ this .network , tags , this .buildCache , this . launchCache );
310
315
}
311
316
312
317
/**
313
- * Return a new {@link BuildRequest} with an additional cache volume name.
314
- * @param type the cache volume type
315
- * @param name the cache volume name
318
+ * Return a new {@link BuildRequest} with an updated build cache.
319
+ * @param buildCache the build cache
316
320
* @return an updated build request
317
321
*/
318
- public BuildRequest withCacheVolumeName (String type , String name ) {
319
- Assert .hasText (type , "Type must not be empty" );
320
- Assert .state ((type .equals ("build" ) || type .equals ("launch" )), "Type must be either 'build' or 'launch'" );
321
- Assert .hasText (name , "Name must not be empty" );
322
- Map <String , String > cacheVolumeNames = new LinkedHashMap <>(this .cacheVolumeNames );
323
- cacheVolumeNames .put (type , name );
322
+ public BuildRequest withBuildCache (Cache buildCache ) {
323
+ Assert .notNull (buildCache , "BuildCache must not be null" );
324
324
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
325
325
this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish , this .buildpacks , this .bindings ,
326
- this .network , this .tags , Collections . unmodifiableMap ( cacheVolumeNames ) );
326
+ this .network , this .tags , buildCache , this . launchCache );
327
327
}
328
328
329
329
/**
330
- * Return a new {@link BuildRequest} with additional cache volume names .
331
- * @param entries the additional cache volume names
330
+ * Return a new {@link BuildRequest} with an updated launch cache .
331
+ * @param launchCache the cache
332
332
* @return an updated build request
333
333
*/
334
- public BuildRequest withCacheVolumeNames (Map <String , String > entries ) {
335
- Assert .notNull (entries , "Entries must not be null" );
336
- Assert .state (!entries .isEmpty (), "Entries must not be empty" );
337
- BuildRequest request = null ;
338
- for (Map .Entry <String , String > entry : entries .entrySet ()) {
339
- request = withCacheVolumeName (entry .getKey (), entry .getValue ());
340
- }
341
- return request ;
334
+ public BuildRequest withLaunchCache (Cache launchCache ) {
335
+ Assert .notNull (launchCache , "LaunchCache must not be null" );
336
+ return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
337
+ this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish , this .buildpacks , this .bindings ,
338
+ this .network , this .tags , this .buildCache , launchCache );
342
339
}
343
340
344
341
/**
@@ -459,11 +456,19 @@ public List<ImageReference> getTags() {
459
456
}
460
457
461
458
/**
462
- * Return the custom cache volume names that should be used by the lifecycle.
463
- * @return the cache volume names
459
+ * Return the custom build cache that should be used by the lifecycle.
460
+ * @return the build cache
461
+ */
462
+ public Cache getBuildCache () {
463
+ return this .buildCache ;
464
+ }
465
+
466
+ /**
467
+ * Return the custom launch cache that should be used by the lifecycle.
468
+ * @return the launch cache
464
469
*/
465
- public Map < String , String > getCacheVolumeNames () {
466
- return this .cacheVolumeNames ;
470
+ public Cache getLaunchCache () {
471
+ return this .launchCache ;
467
472
}
468
473
469
474
/**
0 commit comments