pixiecore/cli: pass Ipxe firmwares as a package global.

The cli package is meant for single-shot execution anyway, so
instead of plumbing everything through reentrantly, let's just
have a global you can seed before calling CLI().
This commit is contained in:
David Anderson 2016-08-11 23:48:04 -07:00
parent b43c25904b
commit 62e2f4bee3
4 changed files with 14 additions and 12 deletions

View File

@ -17,5 +17,5 @@ package main
import "go.universe.tf/netboot/pixiecore/cli" import "go.universe.tf/netboot/pixiecore/cli"
func main() { func main() {
cli.CLI(nil) cli.CLI()
} }

View File

@ -21,13 +21,8 @@ import (
) )
func main() { func main() {
pxe := ipxe.MustAsset("undionly.kpxe") cli.Ipxe[pixiecore.FirmwareX86PC] = ipxe.MustAsset("undionly.kpxe")
efi32 := ipxe.MustAsset("ipxe-i386.efi") cli.Ipxe[pixiecore.FirmwareEFI32] = ipxe.MustAsset("ipxe-i386.efi")
efi64 := ipxe.MustAsset("ipxe-x86_64.efi") cli.Ipxe[pixiecore.FirmwareEFI64] = ipxe.MustAsset("ipxe-x86_64.efi")
cli.CLI()
cli.CLI(map[pixiecore.Firmware][]byte{
pixiecore.FirmwareX86PC: pxe,
pixiecore.FirmwareEFI32: efi32,
pixiecore.FirmwareEFI64: efi64,
})
} }

View File

@ -50,7 +50,7 @@ var bootCmd = &cobra.Command{
s := &pixiecore.Server{ s := &pixiecore.Server{
Booter: pixiecore.StaticBooter(spec), Booter: pixiecore.StaticBooter(spec),
Ipxe: nil, // TODO Ipxe: Ipxe,
Log: func(msg string) { fmt.Println(msg) }, Log: func(msg string) { fmt.Println(msg) },
} }
fmt.Println(s.Serve()) fmt.Println(s.Serve())

View File

@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// Package cli implements the commandline interface for Pixiecore.
package cli package cli
import ( import (
@ -23,10 +24,16 @@ import (
"go.universe.tf/netboot/pixiecore" "go.universe.tf/netboot/pixiecore"
) )
// Ipxe is the set of ipxe binaries for supported firmwares.
//
// Can be set externally before calling CLI(), and set/extended by
// commandline processing in CLI().
var Ipxe = map[pixiecore.Firmware][]byte{}
// CLI runs the Pixiecore commandline. // CLI runs the Pixiecore commandline.
// //
// Takes a map of ipxe bootloader binaries for various architectures. // Takes a map of ipxe bootloader binaries for various architectures.
func CLI(ipxe map[pixiecore.Firmware][]byte) { func CLI() {
if err := rootCmd.Execute(); err != nil { if err := rootCmd.Execute(); err != nil {
fmt.Println(err) fmt.Println(err)
os.Exit(-1) os.Exit(-1)