From 9c4a9acb5626574ba13424d110b2fb65c24587a4 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Wed, 30 Sep 2015 14:55:15 -0700 Subject: [PATCH] ability to add Docker CA, Cert, Key via the user interface --- controller/node.go | 16 ++++++++++++++-- static/scripts/nodes.js | 9 +++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/controller/node.go b/controller/node.go index 7adcf30d..b7a1f815 100644 --- a/controller/node.go +++ b/controller/node.go @@ -38,12 +38,24 @@ func PostNode(c *gin.Context) { db := context.Database(c) engine := context.Engine(c) - node := &model.Node{} - err := c.Bind(node) + in := struct { + 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 { c.AbortWithStatus(http.StatusBadRequest) return } + + node := &model.Node{} + node.Addr = in.Addr + node.Cert = in.Cert + node.Key = in.Key + node.CA = in.CA node.Arch = "linux_amd64" err = model.InsertNode(db, node) diff --git a/static/scripts/nodes.js b/static/scripts/nodes.js index cc059ea7..74b7ec2c 100644 --- a/static/scripts/nodes.js +++ b/static/scripts/nodes.js @@ -4,8 +4,13 @@ function NodeViewModel() { // handle requests to create a new node. $(".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({ url: "/api/nodes",