forked from buildpacks/pack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.go
670 lines (584 loc) · 20 KB
/
build.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
package pack
import (
"context"
"fmt"
"math/rand"
"net/url"
"os"
"path/filepath"
"runtime"
"sort"
"strings"
"github.com/Masterminds/semver"
"github.com/buildpacks/imgutil"
"github.com/docker/docker/api/types"
"github.com/docker/docker/volume/mounts"
"github.com/google/go-containerregistry/pkg/name"
"github.com/pkg/errors"
"github.com/buildpacks/pack/internal/archive"
"github.com/buildpacks/pack/internal/build"
"github.com/buildpacks/pack/internal/builder"
"github.com/buildpacks/pack/internal/buildpack"
"github.com/buildpacks/pack/internal/buildpackage"
"github.com/buildpacks/pack/internal/dist"
"github.com/buildpacks/pack/internal/layer"
"github.com/buildpacks/pack/internal/paths"
"github.com/buildpacks/pack/internal/stack"
"github.com/buildpacks/pack/internal/stringset"
"github.com/buildpacks/pack/internal/style"
)
const (
lifecycleImageRepo = "buildpacksio/lifecycle"
minLifecycleVersionSupportingCreator = "0.7.4"
prevLifecycleVersionSupportingImage = "0.6.1"
minLifecycleVersionSupportingImage = "0.7.5"
)
type Lifecycle interface {
Execute(ctx context.Context, opts build.LifecycleOptions) error
}
type BuildOptions struct {
Image string // required
Builder string // required
Registry string
AppPath string // defaults to current working directory
RunImage string // defaults to the best mirror from the builder metadata or AdditionalMirrors
AdditionalMirrors map[string][]string // only considered if RunImage is not provided
Env map[string]string
Publish bool
NoPull bool
ClearCache bool
TrustBuilder bool
Buildpacks []string
ProxyConfig *ProxyConfig // defaults to environment proxy vars
ContainerConfig ContainerConfig
DefaultProcessType string
FileFilter func(string) bool
}
type ProxyConfig struct {
HTTPProxy string
HTTPSProxy string
NoProxy string
}
type ContainerConfig struct {
Network string
Volumes []string
}
func (c *Client) Build(ctx context.Context, opts BuildOptions) error {
imageRef, err := c.parseTagReference(opts.Image)
if err != nil {
return errors.Wrapf(err, "invalid image name '%s'", opts.Image)
}
appPath, err := c.processAppPath(opts.AppPath)
if err != nil {
return errors.Wrapf(err, "invalid app path '%s'", opts.AppPath)
}
proxyConfig := c.processProxyConfig(opts.ProxyConfig)
builderRef, err := c.processBuilderName(opts.Builder)
if err != nil {
return errors.Wrapf(err, "invalid builder '%s'", opts.Builder)
}
rawBuilderImage, err := c.imageFetcher.Fetch(ctx, builderRef.Name(), true, !opts.NoPull)
if err != nil {
return errors.Wrapf(err, "failed to fetch builder image '%s'", builderRef.Name())
}
bldr, err := c.getBuilder(rawBuilderImage)
if err != nil {
return errors.Wrapf(err, "invalid builder %s", style.Symbol(opts.Builder))
}
runImageName := c.resolveRunImage(opts.RunImage, imageRef.Context().RegistryStr(), builderRef.Context().RegistryStr(), bldr.Stack(), opts.AdditionalMirrors, opts.Publish)
runImage, err := c.validateRunImage(ctx, runImageName, opts.NoPull, opts.Publish, bldr.StackID)
if err != nil {
return errors.Wrapf(err, "invalid run-image '%s'", runImageName)
}
var runMixins []string
if _, err := dist.GetLabel(runImage, stack.MixinsLabel, &runMixins); err != nil {
return err
}
fetchedBPs, order, err := c.processBuildpacks(ctx, bldr.Image(), bldr.Buildpacks(), bldr.Order(), opts.Buildpacks, opts.NoPull, opts.Publish, opts.Registry)
if err != nil {
return err
}
if err := c.validateMixins(fetchedBPs, bldr, runImageName, runMixins); err != nil {
return errors.Wrap(err, "validating stack mixins")
}
ephemeralBuilder, err := c.createEphemeralBuilder(rawBuilderImage, opts.Env, order, fetchedBPs)
if err != nil {
return err
}
defer c.docker.ImageRemove(context.Background(), ephemeralBuilder.Name(), types.ImageRemoveOptions{Force: true})
builderPlatformAPIs := append(
ephemeralBuilder.LifecycleDescriptor().APIs.Platform.Deprecated,
ephemeralBuilder.LifecycleDescriptor().APIs.Platform.Supported...,
)
if !supportsPlatformAPI(builderPlatformAPIs) {
c.logger.Debugf("pack %s supports Platform API(s): %s", Version, strings.Join(build.SupportedPlatformAPIVersions.AsStrings(), ", "))
c.logger.Debugf("Builder %s supports Platform API(s): %s", style.Symbol(opts.Builder), strings.Join(builderPlatformAPIs.AsStrings(), ", "))
return errors.Errorf("Builder %s is incompatible with this version of pack", style.Symbol(opts.Builder))
}
processedVolumes, warnings, err := processVolumes(opts.ContainerConfig.Volumes)
if err != nil {
return err
}
for _, warning := range warnings {
c.logger.Warn(warning)
}
lifecycleOpts := build.LifecycleOptions{
AppPath: appPath,
Image: imageRef,
Builder: ephemeralBuilder,
RunImage: runImageName,
ClearCache: opts.ClearCache,
Publish: opts.Publish,
UseCreator: false,
TrustBuilder: opts.TrustBuilder,
LifecycleImage: ephemeralBuilder.Name(),
HTTPProxy: proxyConfig.HTTPProxy,
HTTPSProxy: proxyConfig.HTTPSProxy,
NoProxy: proxyConfig.NoProxy,
Network: opts.ContainerConfig.Network,
Volumes: processedVolumes,
DefaultProcessType: opts.DefaultProcessType,
FileFilter: opts.FileFilter,
}
lifecycleVersion := ephemeralBuilder.LifecycleDescriptor().Info.Version
// Technically the creator is supported as of platform API version 0.3 (lifecycle version 0.7.0+) but earlier versions
// have bugs that make using the creator problematic.
lifecycleSupportsCreator := !lifecycleVersion.LessThan(semver.MustParse(minLifecycleVersionSupportingCreator))
if lifecycleSupportsCreator && opts.TrustBuilder {
lifecycleOpts.UseCreator = true
// no need to fetch a lifecycle image, it won't be used
return c.lifecycle.Execute(ctx, lifecycleOpts)
}
lifecycleImageSupported := lifecycleVersion.Equal(builder.VersionMustParse(prevLifecycleVersionSupportingImage)) || !lifecycleVersion.LessThan(semver.MustParse(minLifecycleVersionSupportingImage))
if !opts.TrustBuilder {
switch lifecycleImageSupported {
case true:
lifecycleImage, err := c.imageFetcher.Fetch(
ctx,
fmt.Sprintf("%s:%s", lifecycleImageRepo, lifecycleVersion.String()),
true,
!opts.NoPull,
)
if err != nil {
return errors.Wrap(err, "fetching lifecycle image")
}
lifecycleOpts.LifecycleImage = lifecycleImage.Name()
default:
return errors.Errorf("Lifecycle %s does not have an associated lifecycle image. Builder must be trusted.", lifecycleVersion.String())
}
}
if err := c.lifecycle.Execute(ctx, lifecycleOpts); err != nil {
return errors.Wrap(err, "executing lifecycle. This may be the result of using an untrusted builder")
}
return nil
}
// supportsPlatformAPI determines whether pack can build using the builder based on the builder's supported Platform API versions.
func supportsPlatformAPI(builderPlatformAPIs builder.APISet) bool {
for _, packSupportedAPI := range build.SupportedPlatformAPIVersions {
for _, builderSupportedAPI := range builderPlatformAPIs {
supportsPlatform := packSupportedAPI.Compare(builderSupportedAPI) == 0
if supportsPlatform {
return true
}
}
}
return false
}
func (c *Client) processBuilderName(builderName string) (name.Reference, error) {
if builderName == "" {
return nil, errors.New("builder is a required parameter if the client has no default builder")
}
return name.ParseReference(builderName, name.WeakValidation)
}
func (c *Client) getBuilder(img imgutil.Image) (*builder.Builder, error) {
bldr, err := builder.FromImage(img)
if err != nil {
return nil, err
}
if bldr.Stack().RunImage.Image == "" {
return nil, errors.New("builder metadata is missing run-image")
}
lifecycleDescriptor := bldr.LifecycleDescriptor()
if lifecycleDescriptor.Info.Version == nil {
return nil, errors.New("lifecycle version must be specified in builder")
}
if len(lifecycleDescriptor.APIs.Buildpack.Supported) == 0 {
return nil, errors.New("supported Lifecycle Buildpack APIs not specified")
}
if len(lifecycleDescriptor.APIs.Platform.Supported) == 0 {
return nil, errors.New("supported Lifecycle Platform APIs not specified")
}
return bldr, nil
}
func (c *Client) validateRunImage(context context.Context, name string, noPull bool, publish bool, expectedStack string) (imgutil.Image, error) {
if name == "" {
return nil, errors.New("run image must be specified")
}
img, err := c.imageFetcher.Fetch(context, name, !publish, !noPull)
if err != nil {
return nil, err
}
stackID, err := img.Label("io.buildpacks.stack.id")
if err != nil {
return nil, err
}
if stackID != expectedStack {
return nil, fmt.Errorf("run-image stack id '%s' does not match builder stack '%s'", stackID, expectedStack)
}
return img, nil
}
func (c *Client) validateMixins(additionalBuildpacks []dist.Buildpack, bldr *builder.Builder, runImageName string, runMixins []string) error {
if err := stack.ValidateMixins(bldr.Image().Name(), bldr.Mixins(), runImageName, runMixins); err != nil {
return err
}
bps, err := allBuildpacks(bldr.Image(), additionalBuildpacks)
if err != nil {
return err
}
mixins := assembleAvailableMixins(bldr.Mixins(), runMixins)
for _, bp := range bps {
if err := bp.EnsureStackSupport(bldr.StackID, mixins, true); err != nil {
return err
}
}
return nil
}
// assembleAvailableMixins returns the set of mixins that are common between the two provided sets, plus build-only mixins and run-only mixins.
func assembleAvailableMixins(buildMixins, runMixins []string) []string {
// NOTE: We cannot simply union the two mixin sets, as this could introduce a mixin that is only present on one stack
// image but not the other. A buildpack that happens to require the mixin would fail to run properly, even though validation
// would pass.
//
// For example:
//
// Incorrect:
// Run image mixins: [A, B]
// Build image mixins: [A]
// Merged: [A, B]
// Buildpack requires: [A, B]
// Match? Yes
//
// Correct:
// Run image mixins: [A, B]
// Build image mixins: [A]
// Merged: [A]
// Buildpack requires: [A, B]
// Match? No
buildOnly := stack.FindStageMixins(buildMixins, "build")
runOnly := stack.FindStageMixins(runMixins, "run")
_, _, common := stringset.Compare(buildMixins, runMixins)
return append(common, append(buildOnly, runOnly...)...)
}
// allBuildpacks aggregates all buildpacks declared on the image with additional buildpacks passed in. They are sorted
// by ID then Version.
func allBuildpacks(builderImage imgutil.Image, additionalBuildpacks []dist.Buildpack) ([]dist.BuildpackDescriptor, error) {
var all []dist.BuildpackDescriptor
var bpLayers dist.BuildpackLayers
if _, err := dist.GetLabel(builderImage, dist.BuildpackLayersLabel, &bpLayers); err != nil {
return nil, err
}
for id, bps := range bpLayers {
for ver, bp := range bps {
desc := dist.BuildpackDescriptor{
Info: dist.BuildpackInfo{
ID: id,
Version: ver,
},
Stacks: bp.Stacks,
Order: bp.Order,
}
all = append(all, desc)
}
}
for _, bp := range additionalBuildpacks {
all = append(all, bp.Descriptor())
}
sort.Slice(all, func(i, j int) bool {
if all[i].Info.ID != all[j].Info.ID {
return all[i].Info.ID < all[j].Info.ID
}
return all[i].Info.Version < all[j].Info.Version
})
return all, nil
}
func (c *Client) processAppPath(appPath string) (string, error) {
var (
resolvedAppPath string
err error
)
if appPath == "" {
if appPath, err = os.Getwd(); err != nil {
return "", errors.Wrap(err, "get working dir")
}
}
if resolvedAppPath, err = filepath.EvalSymlinks(appPath); err != nil {
return "", errors.Wrap(err, "evaluate symlink")
}
if resolvedAppPath, err = filepath.Abs(resolvedAppPath); err != nil {
return "", errors.Wrap(err, "resolve absolute path")
}
fi, err := os.Stat(resolvedAppPath)
if err != nil {
return "", errors.Wrap(err, "stat file")
}
if !fi.IsDir() {
fh, err := os.Open(resolvedAppPath)
if err != nil {
return "", errors.Wrap(err, "read file")
}
defer fh.Close()
isZip, err := archive.IsZip(fh)
if err != nil {
return "", errors.Wrap(err, "check zip")
}
if !isZip {
return "", errors.New("app path must be a directory or zip")
}
}
return resolvedAppPath, nil
}
func (c *Client) processProxyConfig(config *ProxyConfig) ProxyConfig {
var (
httpProxy, httpsProxy, noProxy string
ok bool
)
if config != nil {
return *config
}
if httpProxy, ok = os.LookupEnv("HTTP_PROXY"); !ok {
httpProxy = os.Getenv("http_proxy")
}
if httpsProxy, ok = os.LookupEnv("HTTPS_PROXY"); !ok {
httpsProxy = os.Getenv("https_proxy")
}
if noProxy, ok = os.LookupEnv("NO_PROXY"); !ok {
noProxy = os.Getenv("no_proxy")
}
return ProxyConfig{
HTTPProxy: httpProxy,
HTTPSProxy: httpsProxy,
NoProxy: noProxy,
}
}
// processBuildpacks computes an order group based on the existing builder order and declared buildpacks. Additionally,
// it returns buildpacks that should be added to the builder.
//
// Visual examples:
//
// BUILDER ORDER
// ----------
// - group:
// - A
// - B
// - group:
// - A
//
// WITH DECLARED: "from=builder", X
// ----------
// - group:
// - A
// - B
// - X
// - group:
// - A
// - X
//
// WITH DECLARED: X, "from=builder", Y
// ----------
// - group:
// - X
// - A
// - B
// - Y
// - group:
// - X
// - A
// - Y
//
// WITH DECLARED: X
// ----------
// - group:
// - X
//
// WITH DECLARED: A
// ----------
// - group:
// - A
func (c *Client) processBuildpacks(ctx context.Context, builderImage imgutil.Image, builderBPs []dist.BuildpackInfo, builderOrder dist.Order, declaredBPs []string, noPull bool, publish bool, registry string) (fetchedBPs []dist.Buildpack, order dist.Order, err error) {
order = dist.Order{{Group: []dist.BuildpackRef{}}}
for _, bp := range declaredBPs {
locatorType, err := buildpack.GetLocatorType(bp, builderBPs)
if err != nil {
return nil, nil, err
}
switch locatorType {
case buildpack.FromBuilderLocator:
switch {
case len(order) == 0 || len(order[0].Group) == 0:
order = builderOrder
case len(order) > 1:
// This should only ever be possible if they are using from=builder twice which we don't allow
return nil, nil, errors.New("buildpacks from builder can only be defined once")
default:
newOrder := dist.Order{}
groupToAdd := order[0].Group
for _, bOrderEntry := range builderOrder {
newEntry := dist.OrderEntry{Group: append(groupToAdd, bOrderEntry.Group...)}
newOrder = append(newOrder, newEntry)
}
order = newOrder
}
case buildpack.IDLocator:
id, version := buildpack.ParseIDLocator(bp)
order = appendBuildpackToOrder(order, dist.BuildpackInfo{
ID: id,
Version: version,
})
case buildpack.URILocator:
err := ensureBPSupport(bp)
if err != nil {
return fetchedBPs, order, errors.Wrapf(err, "checking support")
}
blob, err := c.downloader.Download(ctx, bp)
if err != nil {
return fetchedBPs, order, errors.Wrapf(err, "downloading buildpack from %s", style.Symbol(bp))
}
var mainBP dist.Buildpack
var dependencyBPs []dist.Buildpack
isOCILayout, err := buildpackage.IsOCILayoutBlob(blob)
if err != nil {
return fetchedBPs, order, errors.Wrapf(err, "checking format")
}
if isOCILayout {
mainBP, dependencyBPs, err = buildpackage.BuildpacksFromOCILayoutBlob(blob)
if err != nil {
return fetchedBPs, order, errors.Wrapf(err, "extracting buildpacks from %s", style.Symbol(bp))
}
} else {
layerWriterFactory, err := layer.NewWriterFactory(builderImage)
if err != nil {
return fetchedBPs, order, errors.Wrapf(err, "get tar writer factory for image %s", style.Symbol(builderImage.Name()))
}
mainBP, err = dist.BuildpackFromRootBlob(blob, layerWriterFactory)
if err != nil {
return fetchedBPs, order, errors.Wrapf(err, "creating buildpack from %s", style.Symbol(bp))
}
}
fetchedBPs = append(append(fetchedBPs, mainBP), dependencyBPs...)
order = appendBuildpackToOrder(order, mainBP.Descriptor().Info)
case buildpack.PackageLocator:
mainBP, depBPs, err := extractPackagedBuildpacks(ctx, bp, c.imageFetcher, publish, noPull)
if err != nil {
return fetchedBPs, order, errors.Wrapf(err, "creating from buildpackage %s", style.Symbol(bp))
}
fetchedBPs = append(append(fetchedBPs, mainBP), depBPs...)
order = appendBuildpackToOrder(order, mainBP.Descriptor().Info)
case buildpack.RegistryLocator:
registryCache, err := c.getRegistry(c.logger, registry)
if err != nil {
return fetchedBPs, order, errors.Wrapf(err, "invalid registry '%s'", registry)
}
registryBp, err := registryCache.LocateBuildpack(bp)
if err != nil {
return fetchedBPs, order, errors.Wrapf(err, "locating in registry %s", style.Symbol(bp))
}
mainBP, depBPs, err := extractPackagedBuildpacks(ctx, registryBp.Address, c.imageFetcher, publish, noPull)
if err != nil {
return fetchedBPs, order, errors.Wrapf(err, "extracting from registry %s", style.Symbol(bp))
}
fetchedBPs = append(append(fetchedBPs, mainBP), depBPs...)
order = appendBuildpackToOrder(order, mainBP.Descriptor().Info)
default:
return nil, nil, fmt.Errorf("invalid buildpack string %s", style.Symbol(bp))
}
}
return fetchedBPs, order, nil
}
func appendBuildpackToOrder(order dist.Order, bpInfo dist.BuildpackInfo) (newOrder dist.Order) {
for _, orderEntry := range order {
newEntry := orderEntry
newEntry.Group = append(newEntry.Group, dist.BuildpackRef{
BuildpackInfo: bpInfo,
Optional: false,
})
newOrder = append(newOrder, newEntry)
}
return newOrder
}
func ensureBPSupport(bpPath string) (err error) {
p := bpPath
if paths.IsURI(bpPath) {
var u *url.URL
u, err = url.Parse(bpPath)
if err != nil {
return err
}
if u.Scheme == "file" {
p, err = paths.URIToFilePath(bpPath)
if err != nil {
return err
}
}
}
if runtime.GOOS == "windows" && !paths.IsURI(p) {
isDir, err := paths.IsDir(p)
if err != nil {
return err
}
if isDir {
return fmt.Errorf("buildpack %s: directory-based buildpacks are not currently supported on Windows", style.Symbol(bpPath))
}
}
return nil
}
func (c *Client) createEphemeralBuilder(rawBuilderImage imgutil.Image, env map[string]string, order dist.Order, buildpacks []dist.Buildpack) (*builder.Builder, error) {
origBuilderName := rawBuilderImage.Name()
bldr, err := builder.New(rawBuilderImage, fmt.Sprintf("pack.local/builder/%x:latest", randString(10)))
if err != nil {
return nil, errors.Wrapf(err, "invalid builder %s", style.Symbol(origBuilderName))
}
bldr.SetEnv(env)
for _, bp := range buildpacks {
bpInfo := bp.Descriptor().Info
c.logger.Debugf("Adding buildpack %s version %s to builder", style.Symbol(bpInfo.ID), style.Symbol(bpInfo.Version))
bldr.AddBuildpack(bp)
}
if len(order) > 0 && len(order[0].Group) > 0 {
c.logger.Debug("Setting custom order")
bldr.SetOrder(order)
}
if err := bldr.Save(c.logger, builder.CreatorMetadata{Version: Version}); err != nil {
return nil, err
}
return bldr, nil
}
func randString(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = 'a' + byte(rand.Intn(26))
}
return string(b)
}
func processVolumes(volumes []string) (processed []string, warnings []string, err error) {
// Assume a linux container
parser := mounts.NewParser(mounts.OSLinux)
for _, v := range volumes {
volume, err := parser.ParseMountRaw(v, "")
if err != nil {
return nil, nil, errors.Wrapf(err, "platform volume %q has invalid format", v)
}
for _, p := range [...]string{"/cnb", "/layers"} {
if strings.HasPrefix(volume.Spec.Target, p) {
warnings = append(warnings, fmt.Sprintf("Mounting to a sensitive directory %s", style.Symbol(volume.Spec.Target)))
}
}
processed = append(processed, fmt.Sprintf("%s:%s:%s", volume.Spec.Source, volume.Spec.Target, processMode(volume.Mode)))
}
return processed, warnings, nil
}
func processMode(mode string) string {
if mode == "" {
return "ro"
}
return mode
}