adapt ui to new assets
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
@@ -14,10 +13,36 @@ import (
|
||||
"novit.tech/direktil/local-server/pkg/mime"
|
||||
)
|
||||
|
||||
var (
|
||||
allowDetectedHost = flag.Bool("allow-detected-host", false, "Allow access to host assets from its IP (insecure but enables unattended netboot)")
|
||||
trustXFF = flag.Bool("trust-xff", false, "Trust the X-Forwarded-For header")
|
||||
)
|
||||
type AssetVariant struct {
|
||||
name string
|
||||
url string
|
||||
}
|
||||
|
||||
func hostAssetVariants(asset string) []AssetVariant {
|
||||
switch asset {
|
||||
case "uki":
|
||||
return []AssetVariant{
|
||||
{asset, asset},
|
||||
{asset + " (serial)", asset + "?serial=0"},
|
||||
}
|
||||
case "boot.img",
|
||||
"boot.img.gz",
|
||||
"boot.qcow2",
|
||||
"boot.qed",
|
||||
"boot.vdi",
|
||||
"boot.vmdk",
|
||||
"boot.vpc",
|
||||
"boot.iso",
|
||||
"boot.tar":
|
||||
return []AssetVariant{
|
||||
{asset, asset},
|
||||
{asset + " (UKI)", asset + "?uki"},
|
||||
{asset + " (UKI+serial)", asset + "?uki&serial=0"},
|
||||
}
|
||||
default:
|
||||
return []AssetVariant{{asset, asset}}
|
||||
}
|
||||
}
|
||||
|
||||
type wsHost struct {
|
||||
hostDoc string
|
||||
@@ -52,9 +77,6 @@ func (ws wsHost) register(rws *restful.WebService, alterRB func(*restful.RouteBu
|
||||
b("boot.img.gz").
|
||||
Produces(mime.DISK + "+gzip").
|
||||
Doc("Get the " + ws.hostDoc + "'s boot disk image, gzip compressed"),
|
||||
b("boot.img.lz4").
|
||||
Produces(mime.DISK + "+lz4").
|
||||
Doc("Get the " + ws.hostDoc + "'s boot disk image, lz4 compressed"),
|
||||
|
||||
// - other formats
|
||||
b("boot.qcow2").
|
||||
@@ -188,19 +210,12 @@ func renderHost(w http.ResponseWriter, r *http.Request, what string, host *local
|
||||
}
|
||||
|
||||
switch what {
|
||||
case "config":
|
||||
err = renderConfig(w, r, ctx, false)
|
||||
case "config.json":
|
||||
err = renderConfig(w, r, ctx, true)
|
||||
|
||||
case "ipxe":
|
||||
err = renderIPXE(w, ctx)
|
||||
|
||||
case "kernel":
|
||||
err = renderKernel(w, r, ctx)
|
||||
case "initrd":
|
||||
err = renderCtx(w, r, ctx, what, buildInitrd)
|
||||
case "uki":
|
||||
uki = true
|
||||
err = renderCtx(w, r, ctx, what, withUki(buildUki))
|
||||
|
||||
case "bootstrap.tar":
|
||||
@@ -230,6 +245,14 @@ func renderHost(w http.ResponseWriter, r *http.Request, what string, host *local
|
||||
case "bootstrap-config":
|
||||
err = renderBootstrapConfig(w, ctx)
|
||||
|
||||
case "config":
|
||||
err = renderConfig(w, r, ctx, false)
|
||||
case "config.json":
|
||||
err = renderConfig(w, r, ctx, true)
|
||||
|
||||
case "ipxe":
|
||||
err = renderIPXE(w, ctx)
|
||||
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user