Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Commit

Permalink
Missing monit configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
svrc committed Jul 12, 2020
1 parent a68f29f commit 87c4035
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
24 changes: 24 additions & 0 deletions jobs/docker-windows/monit
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"processes": [
{
"name": "dockerd",
"executable": "/var/vcap/packages/docker-windows/docker/dockerd",
"args": ["--config-file", "/var/vcap/jobs/docker-windows/config/daemon.json"],
"env": {
<% if_link('docker') do |docker| %>
<% docker.if_p('env.http_proxy') do |http_proxy| %>
"HTTP_PROXY": "<%= http_proxy %>",
<% end %>
<% docker.if_p('env.https_proxy') do |https_proxy| %>
"HTTPS_PROXY": "<%= https_proxy %>",
<% end %>
<% docker.if_p('env.no_proxy') do |no_proxy| %>
"NO_PROXY": "<%= no_proxy %>",
<% end %>
<% end %>
"ENSURE_NO_TRAILING_COMMA": "foobar"
}
}
]
}

30 changes: 30 additions & 0 deletions spec/docker_windows_monit_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

require 'rspec'
require 'spec_helper'

describe 'docker_pre-start' do
let(:link_spec) do {
'docker' => {
'instances' => [],
'properties' => {
'env' => {
'http_proxy' => "http://user:[email protected]:1234",
'https_proxy' => "https://user:[email protected]:1234",
}
}
},
}
end

let(:rendered_template) do
compiled_monit_template('docker-windows', 'monit', {}, link_spec, {}, 'z1', 'fake-bosh-ip', 'fake-bosh-id')
end

it 'configures the proxy' do
expect(rendered_template).to include('"HTTP_PROXY": "http://user:[email protected]:1234",')
expect(rendered_template).to include('"HTTPS_PROXY": "https://user:[email protected]:1234",')
end

end

8 changes: 8 additions & 0 deletions spec/support/template_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ def compiled_template(job_name, template_name, manifest_properties = {}, links =
renderer.render("jobs/#{job_name}/templates/#{template_name}.erb")
end


def compiled_monit_template(job_name, template_name, manifest_properties = {}, links = {}, network_properties = [], az = '', ip = '', id = '', instance_name: '')
manifest = emulate_bosh_director_merge(job_name, manifest_properties, links, network_properties, az, ip, id, instance_name)

renderer = Bosh::Template::Renderer.new(context: manifest)
renderer.render("jobs/#{job_name}/#{template_name}")
end

# Trying to emulate bosh director Bosh::Director::DeploymentPlan::Job#extract_template_properties
def emulate_bosh_director_merge(job_name, manifest_properties, links, network_properties, az, ip, id, instance_name)
job_spec = YAML.load_file("jobs/#{job_name}/spec")
Expand Down

0 comments on commit 87c4035

Please sign in to comment.