-
Notifications
You must be signed in to change notification settings - Fork 132
/
overlay_create.go
79 lines (70 loc) · 2.17 KB
/
overlay_create.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
// Copyright (c) Contributors to the Apptainer project, established as
// Apptainer a Series of LF Projects LLC.
// For website terms of use, trademark policy, privacy policy and other
// project policies see https://lfprojects.org/policies
package cli
import (
"github.com/apptainer/apptainer/docs"
"github.com/apptainer/apptainer/internal/app/apptainer"
"github.com/apptainer/apptainer/pkg/cmdline"
"github.com/apptainer/apptainer/pkg/sylog"
"github.com/spf13/cobra"
)
var (
overlaySize int
overlayDirs []string
isOverlayFakeroot bool
overlaySparse bool
)
// -s|--size
var overlaySizeFlag = cmdline.Flag{
ID: "overlaySizeFlag",
Value: &overlaySize,
DefaultValue: 64,
Name: "size",
ShortHand: "s",
Usage: "size of the EXT3 writable overlay in MiB",
}
// --sparse/-S
var overlaySparseFlag = cmdline.Flag{
ID: "overlaySparseFlag",
Value: &overlaySparse,
DefaultValue: false,
Name: "sparse",
ShortHand: "S",
Usage: "create a sparse overlay",
EnvKeys: []string{"SPARSE"},
}
// --create-dir
var overlayCreateDirFlag = cmdline.Flag{
ID: "overlayCreateDirFlag",
Value: &overlayDirs,
DefaultValue: []string{},
Name: "create-dir",
Usage: "directory to create as part of the overlay layout",
}
// --fakeroot
var overlayFakerootFlag = cmdline.Flag{
ID: "overlayFakerootFlag",
Value: &isOverlayFakeroot,
DefaultValue: false,
Name: "fakeroot",
ShortHand: "f",
Usage: "make overlay layout usable by actions run with --fakeroot",
EnvKeys: []string{"FAKEROOT"},
}
// OverlayCreateCmd is the 'overlay create' command that allows to create writable overlay.
var OverlayCreateCmd = &cobra.Command{
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if err := apptainer.OverlayCreate(overlaySize, args[0], overlaySparse, isOverlayFakeroot, overlayDirs...); err != nil {
sylog.Fatalf(err.Error())
}
return nil
},
DisableFlagsInUseLine: true,
Use: docs.OverlayCreateUse,
Short: docs.OverlayCreateShort,
Long: docs.OverlayCreateLong,
Example: docs.OverlayCreateExample,
}