ability to add Docker CA, Cert, Key via the user interface

This commit is contained in:
Brad Rydzewski 2015-09-30 14:55:15 -07:00
parent 5d586582c8
commit 9c4a9acb56
2 changed files with 21 additions and 4 deletions

View file

@ -38,12 +38,24 @@ func PostNode(c *gin.Context) {
db := context.Database(c) db := context.Database(c)
engine := context.Engine(c) engine := context.Engine(c)
node := &model.Node{} in := struct {
err := c.Bind(node) Addr string `json:"address"`
Arch string `json:"architecture"`
Cert string `json:"cert"`
Key string `json:"key"`
CA string `json:"ca"`
}{}
err := c.Bind(&in)
if err != nil { if err != nil {
c.AbortWithStatus(http.StatusBadRequest) c.AbortWithStatus(http.StatusBadRequest)
return return
} }
node := &model.Node{}
node.Addr = in.Addr
node.Cert = in.Cert
node.Key = in.Key
node.CA = in.CA
node.Arch = "linux_amd64" node.Arch = "linux_amd64"
err = model.InsertNode(db, node) err = model.InsertNode(db, node)

View file

@ -4,8 +4,13 @@ function NodeViewModel() {
// handle requests to create a new node. // handle requests to create a new node.
$(".modal-node button").click(function(e) { $(".modal-node button").click(function(e) {
var addr = $(".modal-node input").val();
var node = { address: addr }; var node = {
address : $("#addr").val(),
key : $("#key").val(),
cert : $("#cert").val(),
ca : $("#ca").val()
};
$.ajax({ $.ajax({
url: "/api/nodes", url: "/api/nodes",