File tree Expand file tree Collapse file tree 2 files changed +35
-5
lines changed
Expand file tree Collapse file tree 2 files changed +35
-5
lines changed Original file line number Diff line number Diff line change @@ -26,15 +26,19 @@ func main() {
2626 log .Err (err ).Msg ("Error while running parserCli.ParseYamlFile()" )
2727 }
2828
29- err = buildCLient . BuildExportDockerImage ( result . Context , result . DockerfilePath , result . TargetDirectory )
29+ err = rootFsClient . CreateFileDD ( 10 , "ops" )
3030 if err != nil {
31- log .Err (err ).Msg ("Error while running buildCLient.BuildExportDockerImage ()" )
31+ log .Err (err ).Msg ("Error while running rootFsClient.CreateFileDD ()" )
3232 }
3333
34- err = rootFsClient .CreateFileDD (10 , "ops" )
34+ fsErr := rootFsClient .FormatandMountFileSystem ("ops" , result .TargetDirectory )
35+ if fsErr != nil {
36+ log .Err (fsErr ).Msg ("Error while running rootFsClient.FormatFileSystem()" )
37+ }
38+
39+ err = buildCLient .BuildExportDockerImage (result .Context , result .DockerfilePath , result .TargetDirectory )
3540 if err != nil {
36- log .Err (err ).Msg ("Error while running rootFsClient.CreateFileDD ()" )
41+ log .Err (err ).Msg ("Error while running buildCLient.BuildExportDockerImage ()" )
3742 }
38- // Extract rootfs components now
3943
4044}
Original file line number Diff line number Diff line change 11package src
22
33import (
4+ "fmt"
45 "os"
6+ "os/exec"
57
68 "github.com/rs/zerolog/log"
79)
810
911type RootFS interface {
1012 CreateFileDD (size int64 , fileName string ) error
13+ FormatandMountFileSystem (path , targetDirectory string ) error
1114}
1215
1316type RootFSHandler struct {}
1417
18+ func (rootfs * RootFSHandler ) FormatandMountFileSystem (path , targetDirectory string ) error {
19+ cmd := exec .Command ("mkfs.ext4" , path )
20+ output , err := cmd .CombinedOutput ()
21+ if err != nil {
22+ log .Err (err ).Msg ("Error running mkfs.ext4:" )
23+ log .Info ().Msgf ("Output: %s" , string (output ))
24+ return err
25+ }
26+
27+ log .Info ().Msgf ("Output: %s" , string (output ))
28+
29+ cmd = exec .Command (fmt .Sprintf ("mount" , path , targetDirectory ))
30+ output , err = cmd .CombinedOutput ()
31+ if err != nil {
32+ log .Err (err ).Msg ("Error running mount" )
33+ log .Info ().Msgf ("Mount exec output: %s" , string (output ))
34+ return err
35+ }
36+
37+ log .Info ().Msgf ("Mount exec output: %s" , string (output ))
38+ return nil
39+ }
40+
1541func (rootfs * RootFSHandler ) CreateFileDD (size int64 , fileName string ) error {
1642
1743 size = int64 (size * 1024 * 1024 ) // in MiB files
You can’t perform that action at this time.
0 commit comments