Skip to content

Commit 6528e88

Browse files
Fix clie requirements
1 parent 6704de1 commit 6528e88

File tree

4 files changed

+45
-6
lines changed

4 files changed

+45
-6
lines changed

go.mod

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ replace github.com/WoodProgrammer/firecracker-vmbuilder/src => ./src
44

55
go 1.24.1
66

7-
require github.com/WoodProgrammer/firecracker-vmbuilder/src v0.0.0-00010101000000-000000000000
7+
require (
8+
github.com/WoodProgrammer/firecracker-vmbuilder/src v0.0.0-00010101000000-000000000000
9+
github.com/rs/zerolog v1.33.0
10+
github.com/spf13/cobra v1.9.1
11+
)
812

913
require (
14+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
1015
github.com/mattn/go-colorable v0.1.13 // indirect
1116
github.com/mattn/go-isatty v0.0.19 // indirect
12-
github.com/rs/zerolog v1.33.0 // indirect
17+
github.com/spf13/pflag v1.0.6 // indirect
1318
golang.org/x/sys v0.12.0 // indirect
1419
gopkg.in/yaml.v2 v2.4.0 // indirect
1520
)

go.sum

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
2+
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
23
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
4+
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
5+
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
36
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
47
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
58
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
@@ -9,6 +12,11 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
912
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
1013
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
1114
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
15+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
16+
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
17+
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
18+
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
19+
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
1220
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1321
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1422
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
@@ -17,3 +25,4 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+
1725
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1826
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
1927
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
28+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

main.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
package main
22

33
import (
4+
"os"
5+
46
src "github.com/WoodProgrammer/firecracker-vmbuilder/src"
57
"github.com/rs/zerolog/log"
8+
"github.com/spf13/cobra"
9+
)
10+
11+
var (
12+
configFile string
613
)
714

815
func newBuildClient() src.Builder {
@@ -16,12 +23,13 @@ func newParserClient() src.Parser {
1623
func newRootFSClient() src.RootFS {
1724
return &src.RootFSHandler{}
1825
}
19-
func main() {
26+
27+
func HandleRootFS() {
2028
parserClient := newParserClient()
2129
buildCLient := newBuildClient()
2230
rootFsClient := newRootFSClient()
2331

24-
result, err := parserClient.ParseYamlFile("config.yaml")
32+
result, err := parserClient.ParseYamlFile(configFile)
2533
if err != nil {
2634
log.Err(err).Msg("Error while running parserCli.ParseYamlFile()")
2735
}
@@ -42,3 +50,21 @@ func main() {
4250
}
4351

4452
}
53+
54+
func main() {
55+
var rootCmd = &cobra.Command{
56+
Use: "rootfsCreator",
57+
Short: "CLI tool to manage RootFS for firecracker micro VMs",
58+
Run: func(cmd *cobra.Command, args []string) {
59+
HandleRootFS()
60+
},
61+
}
62+
rootCmd.Flags().StringVarP(&configFile, "config", "C", "config.yaml", "Config file of RootFS creation")
63+
64+
rootCmd.MarkFlagRequired("config")
65+
66+
if err := rootCmd.Execute(); err != nil {
67+
log.Err(err).Msg("rootfsCreator execution failed")
68+
os.Exit(1)
69+
}
70+
}

src/rootfs.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package src
22

33
import (
4-
"fmt"
54
"os"
65
"os/exec"
76

@@ -26,7 +25,7 @@ func (rootfs *RootFSHandler) FormatandMountFileSystem(path, targetDirectory stri
2625

2726
log.Info().Msgf("Output: %s", string(output))
2827

29-
cmd = exec.Command(fmt.Sprintf("mount", path, targetDirectory))
28+
cmd = exec.Command("mount", path, targetDirectory)
3029
output, err = cmd.CombinedOutput()
3130
if err != nil {
3231
log.Err(err).Msg("Error running mount")

0 commit comments

Comments
 (0)