improve doc

This commit is contained in:
Mikaël Cluseau 2019-02-04 15:06:02 +11:00
parent bef898bc3f
commit 976977ca23
3 changed files with 45 additions and 9 deletions

View File

@ -5,6 +5,8 @@ import (
"path"
restful "github.com/emicklei/go-restful"
"novit.nc/direktil/local-server/pkg/mime"
)
type wsHost struct {
@ -19,23 +21,45 @@ func (ws *wsHost) register(rws *restful.WebService, alterRB func(*restful.RouteB
for _, rb := range []*restful.RouteBuilder{
// raw configuration
b("config").Doc("Get the host's configuration"),
b("config").
Produces(mime.YAML).
Doc("Get the host's configuration"),
// metal/local HDD install
b("boot.img").Doc("Get the host's boot disk image"),
b("boot.img.gz").Doc("Get the host's boot disk image (gzip compressed)"),
b("boot.img.lz4").Doc("Get the host's boot disk image (lz4 compressed)"),
b("boot.img").
Produces(mime.DISK).
Doc("Get the host's boot disk image"),
b("boot.img.gz").
Produces(mime.DISK + "+gzip").
Doc("Get the host's boot disk image (gzip compressed)"),
b("boot.img.lz4").
Produces(mime.DISK + "+lz4").
Doc("Get the host's boot disk image (lz4 compressed)"),
// metal/local HDD upgrades
b("boot.tar").Doc("Get the host's /boot archive (ie: for metal upgrades)"),
b("boot.tar").
Produces(mime.TAR).
Doc("Get the host's /boot archive (ie: for metal upgrades)"),
// read-only ISO support
b("boot.iso").Doc("Get the host's boot CD-ROM image"),
b("boot.iso").
Produces(mime.ISO).
Doc("Get the host's boot CD-ROM image"),
// netboot support
b("ipxe").Doc("Get the host's IPXE code (for netboot)"),
b("kernel").Doc("Get the host's kernel (ie: for netboot)"),
b("initrd").Doc("Get the host's initial RAM disk (ie: for netboot)"),
b("ipxe").
Produces(mime.IPXE).
Doc("Get the host's IPXE code (for netboot)"),
b("kernel").
Produces(mime.OCTET).
Doc("Get the host's kernel (ie: for netboot)"),
b("initrd").
Produces(mime.OCTET).
Doc("Get the host's initial RAM disk (ie: for netboot)"),
} {
alterRB(rb)
rws.Route(rb)

View File

@ -7,6 +7,7 @@ import (
"strings"
"github.com/emicklei/go-restful"
"novit.nc/direktil/local-server/pkg/mime"
"novit.nc/direktil/pkg/localconfig"
)
@ -23,6 +24,7 @@ func buildWS() *restful.WebService {
ws.Route(ws.GET("/clusters/{cluster-name}").Filter(adminAuth).To(wsCluster).
Doc("Get cluster details"))
ws.Route(ws.GET("/clusters/{cluster-name}/addons").Filter(adminAuth).To(wsClusterAddons).
Produces(mime.YAML).
Doc("Get cluster addons").
Returns(http.StatusOK, "OK", nil).
Returns(http.StatusNotFound, "The cluster does not exists or does not have addons defined", nil))

10
pkg/mime/mime.go Normal file
View File

@ -0,0 +1,10 @@
package mime
const (
YAML = "text/vnd.yaml"
TAR = "application/tar"
DISK = "application/x-diskimage"
ISO = "application/x-iso9660-image"
IPXE = "application/x-ipxe"
OCTET = "application/octet-stream"
)