diff --git a/cmd/mosb/main.go b/cmd/mosb/main.go index a776e1a..04f82c7 100644 --- a/cmd/mosb/main.go +++ b/cmd/mosb/main.go @@ -1,11 +1,13 @@ package main import ( + "fmt" "os" "github.com/apex/log" "github.com/project-machine/mos/pkg/mosconfig" "github.com/urfave/cli" + "gopkg.in/yaml.v2" ) func main() { @@ -16,6 +18,7 @@ func main() { manifestCmd, mkBootCmd, mkProvisionCmd, + readSpec, } app.Flags = []cli.Flag{ cli.BoolFlag{ @@ -35,3 +38,30 @@ func main() { log.Fatalf("%v\n", err) } } + +var readSpec = cli.Command{ + Name: "readspec", + Usage: "read a manifest.yaml and print out resulting struct", + Action: doReadSpec, + Hidden: true, + UsageText: `in-file + in-file: file to read`, +} + +func doReadSpec(ctx *cli.Context) error { + args := ctx.Args() + if len(args) < 1 { + return fmt.Errorf("input file is a required positional argument") + } + + bytes, err := os.ReadFile(args[0]) + if err != nil { + return err + } + var manifest mosconfig.ImportFile + if err = yaml.Unmarshal(bytes, &manifest); err != nil { + return err + } + fmt.Printf("result: %#v", manifest) + return nil +} diff --git a/layers/install/stacker.yaml b/layers/install/stacker.yaml index ceaa712..84e1b68 100644 --- a/layers/install/stacker.yaml +++ b/layers/install/stacker.yaml @@ -15,6 +15,7 @@ install-rootfs-pkg: cryptsetup \ dosfstools \ e2fsprogs \ + efibootmgr \ iproute2 \ isc-dhcp-client \ keyutils \ diff --git a/pkg/mosconfig/files.go b/pkg/mosconfig/files.go index 9384325..24ce049 100644 --- a/pkg/mosconfig/files.go +++ b/pkg/mosconfig/files.go @@ -62,10 +62,10 @@ const ( // nics, like lxc.net.[i].*. But for now let's just // support one type TargetNetwork struct { - Type TargetNetworkType `json:"type"` - Address string `json:"ipv4"` - Address6 string `json:"ipv6"` - Ports []SimplePort `json:"ports"` + Type TargetNetworkType `json:"type" yaml:"type"` + Address string `json:"ipv4" yaml:"ipv4"` + Address6 string `json:"ipv6" yaml:"ipv6"` + Ports []SimplePort `json:"ports" yaml:"ports"` } // Service type defines how a service is run. diff --git a/pkg/mosconfig/network.go b/pkg/mosconfig/network.go index 07533a1..cdaa659 100644 --- a/pkg/mosconfig/network.go +++ b/pkg/mosconfig/network.go @@ -35,8 +35,8 @@ func (t Target) ValidateNetwork() bool { } type SimplePort struct { - HostPort uint `json:"host-port"` - ContainerPort uint `json:"container-port"` + HostPort uint `json:"host" yaml:"host"` + ContainerPort uint `json:"container" yaml:"container"` } // Pick a lxcbr0 address which is not yet in use. diff --git a/pkg/provider/kvm.go b/pkg/provider/kvm.go index de192f5..f2abbd9 100644 --- a/pkg/provider/kvm.go +++ b/pkg/provider/kvm.go @@ -315,7 +315,7 @@ func waitForUnix(sockPath, good, bad string) error { return nil } if strings.Contains(s, bad) { - return errors.Errorf("Action failed, as %q was found", bad) + return errors.Errorf("Action failed, as %q was found in %q", bad, s) } return errors.Errorf("Action timed out, did not find %q nor %q, in %q", good, bad, s)