Skip to content

Commit

Permalink
fold up - add efibootmgr to demo-rootfs, add hidden yaml verifier, fi…
Browse files Browse the repository at this point in the history
…x network spec

Signed-off-by: Serge Hallyn <[email protected]>
  • Loading branch information
hallyn committed Oct 25, 2023
1 parent 417b3c6 commit 056c569
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
30 changes: 30 additions & 0 deletions cmd/mosb/main.go
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -16,6 +18,7 @@ func main() {
manifestCmd,
mkBootCmd,
mkProvisionCmd,
readSpec,
}
app.Flags = []cli.Flag{
cli.BoolFlag{
Expand All @@ -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
}
1 change: 1 addition & 0 deletions layers/install/stacker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ install-rootfs-pkg:
cryptsetup \
dosfstools \
e2fsprogs \
efibootmgr \
iproute2 \
isc-dhcp-client \
keyutils \
Expand Down
8 changes: 4 additions & 4 deletions pkg/mosconfig/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions pkg/mosconfig/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/kvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 056c569

Please sign in to comment.