-
Notifications
You must be signed in to change notification settings - Fork 63
/
options.go
52 lines (46 loc) · 1.49 KB
/
options.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
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors.
// Licensed under the BSD-3-Clause License (the "License").
// You may not use this file except in compliance with the License.
package initrd
type InitrdOptions struct {
compress bool
output string
cacheDir string
arch string
}
type InitrdOption func(*InitrdOptions) error
// WithCompression sets the compression of the resulting CPIO archive file.
func WithCompression(compress bool) InitrdOption {
return func(opts *InitrdOptions) error {
opts.compress = compress
return nil
}
}
// WithOutput sets the location of the output location of the resulting CPIO
// archive file.
func WithOutput(output string) InitrdOption {
return func(opts *InitrdOptions) error {
opts.output = output
return nil
}
}
// WithCacheDir sets the path of an internal location that's used during the
// serialization of the initramfs as a mechanism for storing temporary files
// used as cache.
func WithCacheDir(dir string) InitrdOption {
return func(opts *InitrdOptions) error {
opts.cacheDir = dir
return nil
}
}
// WithArchitecture sets the architecture of the file contents of binaries in
// the initramfs. Files may not always be architecture specific, this option
// simply indicates the target architecture if any binaries are compiled by the
// implementing initrd builder.
func WithArchitecture(arch string) InitrdOption {
return func(opts *InitrdOptions) error {
opts.arch = arch
return nil
}
}