Skip to content

Commit

Permalink
Pass deployment context through opaquely
Browse files Browse the repository at this point in the history
[#132773055]
  • Loading branch information
Rob Day-Reynolds committed Nov 5, 2016
1 parent bd1f237 commit 1786eb2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 2 additions & 6 deletions director/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,8 @@ func (c Client) UpdateDeployment(manifest []byte, opts UpdateOpts) error {
if len(opts.Diff.context) != 0 {
context := map[string]interface{}{}

if opts.Diff.context["cloud_config_id"] != nil {
context["cloud_config_id"] = opts.Diff.context["cloud_config_id"]
}

if opts.Diff.context["runtime_config_id"] != nil {
context["runtime_config_id"] = opts.Diff.context["runtime_config_id"]
for key, value := range opts.Diff.context {
context[key] = value
}

contextJson, err := json.Marshal(context)
Expand Down
8 changes: 5 additions & 3 deletions director/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,13 +655,15 @@ var _ = Describe("Deployment", func() {

It("succeeds updating deployment with diff context values", func() {
context := map[string]interface{}{
"cloud_config_id": "2",
"runtime_config_id": 4,
"cloud_config_id": "2",
"runtime_config_id": 4,
"some_other_context_field": "value",
}

requestParams := "context=%7B%22cloud_config_id%22%3A%222%22%2C%22runtime_config_id%22%3A4%2C%22some_other_context_field%22%3A%22value%22%7D"
ConfigureTaskResult(
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/deployments", "context=%7B%22cloud_config_id%22%3A%222%22%2C%22runtime_config_id%22%3A4%7D"),
ghttp.VerifyRequest("POST", "/deployments", requestParams),
ghttp.VerifyBasicAuth("username", "password"),
ghttp.VerifyHeader(http.Header{
"Content-Type": []string{"text/yaml"},
Expand Down

0 comments on commit 1786eb2

Please sign in to comment.