From 86d768284303665bf137ac4766a623167a605c76 Mon Sep 17 00:00:00 2001 From: allencloud Date: Thu, 17 Nov 2016 10:51:16 +0800 Subject: [PATCH] update secret create url for consistency Signed-off-by: allencloud --- api/server/router/swarm/cluster.go | 2 +- client/secret_create.go | 2 +- client/secret_create_test.go | 4 ++-- integration-cli/daemon_swarm.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/server/router/swarm/cluster.go b/api/server/router/swarm/cluster.go index e7181a4d1b..53084f5df7 100644 --- a/api/server/router/swarm/cluster.go +++ b/api/server/router/swarm/cluster.go @@ -55,7 +55,7 @@ func (sr *swarmRouter) initRoutes() { router.NewGetRoute("/tasks", sr.getTasks), router.NewGetRoute("/tasks/{id}", sr.getTask), router.NewGetRoute("/secrets", sr.getSecrets), - router.NewPostRoute("/secrets", sr.createSecret), + router.NewPostRoute("/secrets/create", sr.createSecret), router.NewDeleteRoute("/secrets/{id}", sr.removeSecret), router.NewGetRoute("/secrets/{id}", sr.getSecret), router.NewPostRoute("/secrets/{id}/update", sr.updateSecret), diff --git a/client/secret_create.go b/client/secret_create.go index f92a3d1510..de8b041567 100644 --- a/client/secret_create.go +++ b/client/secret_create.go @@ -13,7 +13,7 @@ func (cli *Client) SecretCreate(ctx context.Context, secret swarm.SecretSpec) (t var headers map[string][]string var response types.SecretCreateResponse - resp, err := cli.post(ctx, "/secrets", nil, secret, headers) + resp, err := cli.post(ctx, "/secrets/create", nil, secret, headers) if err != nil { return response, err } diff --git a/client/secret_create_test.go b/client/secret_create_test.go index b7def89d0e..cb378c77ff 100644 --- a/client/secret_create_test.go +++ b/client/secret_create_test.go @@ -25,7 +25,7 @@ func TestSecretCreateError(t *testing.T) { } func TestSecretCreate(t *testing.T) { - expectedURL := "/secrets" + expectedURL := "/secrets/create" client := &Client{ client: newMockClient(func(req *http.Request) (*http.Response, error) { if !strings.HasPrefix(req.URL.Path, expectedURL) { @@ -41,7 +41,7 @@ func TestSecretCreate(t *testing.T) { return nil, err } return &http.Response{ - StatusCode: http.StatusOK, + StatusCode: http.StatusCreated, Body: ioutil.NopCloser(bytes.NewReader(b)), }, nil }), diff --git a/integration-cli/daemon_swarm.go b/integration-cli/daemon_swarm.go index 9a8de41d6c..cb364f0443 100644 --- a/integration-cli/daemon_swarm.go +++ b/integration-cli/daemon_swarm.go @@ -285,7 +285,7 @@ func (d *SwarmDaemon) listServices(c *check.C) []swarm.Service { } func (d *SwarmDaemon) createSecret(c *check.C, secretSpec swarm.SecretSpec) string { - status, out, err := d.SockRequest("POST", "/secrets", secretSpec) + status, out, err := d.SockRequest("POST", "/secrets/create", secretSpec) c.Assert(err, checker.IsNil, check.Commentf(string(out))) c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf("output: %q", string(out)))