diff --git a/actions/app.go b/actions/app.go index 80ea826..d664600 100644 --- a/actions/app.go +++ b/actions/app.go @@ -31,6 +31,7 @@ func App() *buffalo.App { app.GET("/hosts/create", HostsCreate) app.GET("/hosts/show", HostsShow) app.POST("/hosts/new", HostsNew) + app.GET("/hosts/{id}/edit", HostsEdit) app.ServeFiles("/assets", assetsPath()) } diff --git a/actions/hosts.go b/actions/hosts.go index a85f834..cea3425 100644 --- a/actions/hosts.go +++ b/actions/hosts.go @@ -3,6 +3,7 @@ package actions import ( "github.com/gobuffalo/buffalo" "github.com/bscott/rancher-wrangler/models" + ) // HostsShow default implementation. @@ -34,4 +35,39 @@ import ( return c.Render(200, r.String("Host Created")) } + + // HostEdit implements the edit of an Host entry + func HostsEdit(c buffalo.Context) error { + var hh models.Host + //models.DB.All(&hh) + var id = c.Param("id") + + err := models.DB.Find(&hh, id) + + if err != nil { + return c.Error(500, err) + } + + + c.Set("host", hh) + return c.Render(200, r.HTML("hosts/_edit.html")) + } + + // HostUpdate implements the update of an Host entry + func HostsUpdate(c buffalo.Context) error { + var hh models.Host + //models.DB.All(&hh) + var id = c.Param("id") + + err := models.DB.Find(&hh, id) + + if err != nil { + return c.Error(500, err) + } + + + c.Set("host", hh) + return c.Render(200, r.HTML("hosts/_edit.html")) + } + \ No newline at end of file diff --git a/templates/hosts/_edit.html b/templates/hosts/_edit.html new file mode 100644 index 0000000..03bea4f --- /dev/null +++ b/templates/hosts/_edit.html @@ -0,0 +1,15 @@ +
+

Wrangler - Edit host to inventory


 +

 +

 + Name for Host (e.g. My Rancher Server):
+ Description of Host (e.g. Rancher Server in AWS US West 2):
+ Rancher Server URL (e.g. https://rancher.domain.com:8080/): 
 +

 + Rancher API Access Key: 
 +

 + Rancher API Secret Key: 
 +
+ 


 + 
 +
\ No newline at end of file