From 976977ca23b1b8493aa928cb0a7398ca0a072aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Cluseau?= Date: Mon, 4 Feb 2019 15:06:02 +1100 Subject: [PATCH] improve doc --- cmd/dkl-local-server/ws-host.go | 42 ++++++++++++++++++++++++++------- cmd/dkl-local-server/ws.go | 2 ++ pkg/mime/mime.go | 10 ++++++++ 3 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 pkg/mime/mime.go diff --git a/cmd/dkl-local-server/ws-host.go b/cmd/dkl-local-server/ws-host.go index bdb6a22..7eebc99 100644 --- a/cmd/dkl-local-server/ws-host.go +++ b/cmd/dkl-local-server/ws-host.go @@ -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) diff --git a/cmd/dkl-local-server/ws.go b/cmd/dkl-local-server/ws.go index 926ec7c..ca74cb8 100644 --- a/cmd/dkl-local-server/ws.go +++ b/cmd/dkl-local-server/ws.go @@ -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)) diff --git a/pkg/mime/mime.go b/pkg/mime/mime.go new file mode 100644 index 0000000..3a2696b --- /dev/null +++ b/pkg/mime/mime.go @@ -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" +)