@@ -18,10 +18,8 @@ limitations under the License.
18
18
package build
19
19
20
20
import (
21
- "bufio"
22
21
"context"
23
22
"fmt"
24
- "io"
25
23
"os"
26
24
"path/filepath"
27
25
"strconv"
@@ -39,7 +37,6 @@ import (
39
37
"github.com/apache/camel-k/pkg/platform"
40
38
"github.com/apache/camel-k/pkg/util/defaults"
41
39
"github.com/apache/camel-k/pkg/util/kubernetes"
42
- "github.com/apache/camel-k/pkg/util/log"
43
40
)
44
41
45
42
const (
@@ -204,14 +201,29 @@ func buildPodName(build *v1.Build) string {
204
201
}
205
202
206
203
func addBuildTaskToPod (build * v1.Build , taskName string , pod * corev1.Pod ) {
207
- if ! hasBuilderVolume (pod ) {
208
- // Add the EmptyDir volume used to share the build state across tasks
209
- pod .Spec .Volumes = append (pod .Spec .Volumes , corev1.Volume {
210
- Name : builderVolume ,
211
- VolumeSource : corev1.VolumeSource {
212
- EmptyDir : & corev1.EmptyDirVolumeSource {},
204
+ if ! hasVolume (pod , builderVolume ) {
205
+ pod .Spec .Volumes = append (pod .Spec .Volumes ,
206
+ // EmptyDir volume used to share the build state across tasks
207
+ corev1.Volume {
208
+ Name : builderVolume ,
209
+ VolumeSource : corev1.VolumeSource {
210
+ EmptyDir : & corev1.EmptyDirVolumeSource {},
211
+ },
213
212
},
214
- })
213
+ )
214
+ }
215
+ if ! hasVolume (pod , "camel-k-maven-repo" ) {
216
+ pod .Spec .Volumes = append (pod .Spec .Volumes ,
217
+ // Maven repo volume
218
+ corev1.Volume {
219
+ Name : "camel-k-maven-repo" ,
220
+ VolumeSource : corev1.VolumeSource {
221
+ PersistentVolumeClaim : & corev1.PersistentVolumeClaimVolumeSource {
222
+ ClaimName : "camel-k-maven-repo" ,
223
+ },
224
+ },
225
+ },
226
+ )
215
227
}
216
228
217
229
container := corev1.Container {
@@ -235,15 +247,6 @@ func addBuildTaskToPod(build *v1.Build, taskName string, pod *corev1.Pod) {
235
247
addContainerToPod (build , container , pod )
236
248
}
237
249
238
- func readSpectrumLogs (newStdOut io.Reader ) {
239
- scanner := bufio .NewScanner (newStdOut )
240
-
241
- for scanner .Scan () {
242
- line := scanner .Text ()
243
- log .Infof (line )
244
- }
245
- }
246
-
247
250
func addBuildahTaskToPod (ctx context.Context , c ctrl.Reader , build * v1.Build , task * v1.BuildahTask , pod * corev1.Pod ) error {
248
251
var bud []string
249
252
@@ -473,19 +476,25 @@ func addKanikoTaskToPod(ctx context.Context, c ctrl.Reader, build *v1.Build, tas
473
476
}
474
477
475
478
func addContainerToPod (build * v1.Build , container corev1.Container , pod * corev1.Pod ) {
476
- if hasBuilderVolume (pod ) {
479
+ if hasVolume (pod , builderVolume ) {
477
480
container .VolumeMounts = append (container .VolumeMounts , corev1.VolumeMount {
478
481
Name : builderVolume ,
479
482
MountPath : filepath .Join (builderDir , build .Name ),
480
483
})
481
484
}
485
+ if hasVolume (pod , "camel-k-maven-repo" ) {
486
+ container .VolumeMounts = append (container .VolumeMounts , corev1.VolumeMount {
487
+ Name : "camel-k-maven-repo" ,
488
+ MountPath : "/tmp/artifacts/m2" ,
489
+ })
490
+ }
482
491
483
492
pod .Spec .InitContainers = append (pod .Spec .InitContainers , container )
484
493
}
485
494
486
- func hasBuilderVolume (pod * corev1.Pod ) bool {
495
+ func hasVolume (pod * corev1.Pod , name string ) bool {
487
496
for _ , volume := range pod .Spec .Volumes {
488
- if volume .Name == builderVolume {
497
+ if volume .Name == name {
489
498
return true
490
499
}
491
500
}
0 commit comments