Skip to content

Run sidecars referenced by depends_on on hako oneshot #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/hako/definition_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def load_containers_from_name(tag, container_names, sidecars)
containers[name].volumes_from.each do |volumes_from|
names << volumes_from[:source_container]
end

containers[name].depends_on&.each do |depends_on|
names << depends_on[:container_name]
end
end
end
containers
Expand Down
25 changes: 25 additions & 0 deletions spec/fixtures/jsonnet/default_with_depends_on.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
app: {
image: 'app-image',
depends_on: [
{ container_name: 'redis', condition: 'STARTED' },
],
},
sidecars: {
redis: {
image_tag: 'redis',
depends_on: [
{ container_name: 'memcached', condition: 'STARTED' },
],
},
memcached: {
image_tag: 'memcached',
},
fluentd: {
image_tag: 'fluentd',
depends_on: [
{ container_name: 'redis', condition: 'STARTED' },
],
},
},
}
17 changes: 17 additions & 0 deletions spec/hako/definition_loader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,22 @@
end
end
end

context 'with depends_on' do
let(:fixture_name) { 'default_with_depends_on.jsonnet' }

it 'loads all containers' do
containers = definition_loader.load
expect(containers.keys).to match_array(%w[app redis memcached fluentd])
expect(containers.values).to all(be_a(Hako::Container))
end

context 'with `with`' do
it 'loads specified definition and referenced containers' do
containers = definition_loader.load(with: [])
expect(containers.keys).to match_array(%w[app redis memcached])
end
end
end
end
end