Skip to content

Commit

Permalink
diego: pass environment variables as array of hashes, not array of ar…
Browse files Browse the repository at this point in the history
…rays
  • Loading branch information
onsi committed Apr 18, 2014
1 parent 56e1d13 commit 5df7ed3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions lib/cloud_controller/diego_stager_task.rb
Expand Up @@ -85,12 +85,12 @@ def staging_request

def environment
env = []
env << ["VCAP_APPLICATION", app.vcap_application.to_json]
env << ["VCAP_SERVICES", app.system_env_json["VCAP_SERVICES"].to_json]
env << {key:"VCAP_APPLICATION", value:app.vcap_application.to_json}
env << {key:"VCAP_SERVICES", value: app.system_env_json["VCAP_SERVICES"].to_json}
db_uri = app.database_uri
env << ["DATABASE_URL", db_uri] if db_uri
env << ["MEMORY_LIMIT", "#{app.memory}m"]
app.environment_json.each { |k, v| env << [k, v] }
env << {key:"DATABASE_URL", value:db_uri} if db_uri
env << {key:"MEMORY_LIMIT", value:"#{app.memory}m"}
app.environment_json.each { |k, v| env << {key:k, value:v} }
env
end

Expand Down
10 changes: 5 additions & 5 deletions spec/diego_stager_task_spec.rb
Expand Up @@ -285,14 +285,14 @@ def perform_stage

describe "environment" do
it "contains user defined environment variables" do
expect(diego_stager_task.staging_request[:environment].last).to eq(["USER_DEFINED","OK"])
expect(diego_stager_task.staging_request[:environment].last).to eq({key:"USER_DEFINED", value:"OK"})
end

it "contains VCAP_APPLICATION from application" do
expect(app.vcap_application).to be
expect(
diego_stager_task.staging_request[:environment]
).to include(["VCAP_APPLICATION", app.vcap_application.to_json])
).to include({key:"VCAP_APPLICATION", value:app.vcap_application.to_json})
end

it "contains VCAP_SERVICES" do
Expand All @@ -318,19 +318,19 @@ def perform_stage
}
expect(
diego_stager_task.staging_request[:environment]
).to include(["VCAP_SERVICES", expected_hash.to_json])
).to include({key:"VCAP_SERVICES", value:expected_hash.to_json})
end

it "contains DATABASE_URL" do
expect(
diego_stager_task.staging_request[:environment]
).to include(["DATABASE_URL", "mysql2://giraffes.rock"])
).to include({key:"DATABASE_URL", value:"mysql2://giraffes.rock"})
end

it "contains MEMORY_LIMIT" do
expect(
diego_stager_task.staging_request[:environment]
).to include(["MEMORY_LIMIT", "259m"])
).to include({key:"MEMORY_LIMIT", value:"259m"})
end

it "contains app build artifact cache download uri" do
Expand Down

0 comments on commit 5df7ed3

Please sign in to comment.