Skip to content

Commit

Permalink
Rename additional_containers to sidecars
Browse files Browse the repository at this point in the history
Such containers are called "sidecars" nowadays.
  • Loading branch information
eagletmt committed Jul 25, 2018
1 parent 5722a51 commit e8b55f0
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion examples/hello-autoscaling.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ local provide(name) = fileProvider(std.toString({ path: 'hello.env' }), name);
MESSAGE: std.format('%s-san', provide('username')),
},
},
additional_containers: {
sidecars: {
front: {
image_tag: 'hako-nginx',
memory: 32,
Expand Down
2 changes: 1 addition & 1 deletion examples/hello-fargate.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ local awslogs = {
},
log_configuration: awslogs,
},
additional_containers: {
sidecars: {
front: {
image_tag: 'hako-nginx',
log_configuration: awslogs,
Expand Down
2 changes: 1 addition & 1 deletion examples/hello-lb-v2.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ local provide(name) = fileProvider(std.toString({ path: 'hello.env' }), name);
MESSAGE: std.format('%s-san', provide('username')),
},
},
additional_containers: {
sidecars: {
front: {
image_tag: 'hako-nginx',
memory: 32,
Expand Down
2 changes: 1 addition & 1 deletion examples/hello-lb.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ local provide(name) = fileProvider(std.toString({ path: 'hello.env' }), name);
MESSAGE: std.format('%s-san', provide('username')),
},
},
additional_containers: {
sidecars: {
front: {
image_tag: 'hako-nginx',
memory: 32,
Expand Down
2 changes: 1 addition & 1 deletion examples/hello.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ local provide(name) = fileProvider(std.toString({ path: 'hello.env' }), name);
MESSAGE: std.format('%s-san', provide('username')),
},
},
additional_containers: {
sidecars: {
front: {
image_tag: 'hako-nginx',
memory: 32,
Expand Down
13 changes: 7 additions & 6 deletions lib/hako/definition_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,25 @@ def initialize(app, dry_run:)
# @param [Array<String>, nil] with
# @return [Hash<String, Container>]
def load(tag, with: nil)
additional_containers = @app.definition.fetch('additional_containers', {})
# XXX: Load additional_containers for compatibility
sidecars = @app.definition.fetch('sidecars', @app.definition.fetch('additional_containers', {}))
container_names = ['app']
if with
container_names.concat(with)
else
container_names.concat(additional_containers.keys)
container_names.concat(sidecars.keys)
end

load_containers_from_name(tag, container_names, additional_containers)
load_containers_from_name(tag, container_names, sidecars)
end

private

# @param [String] tag
# @param [Array<String>] container_names
# @param [Hash<String, Hash>] additional_containers
# @param [Hash<String, Hash>] sidecars
# @return [Hash<String, Container>]
def load_containers_from_name(tag, container_names, additional_containers)
def load_containers_from_name(tag, container_names, sidecars)
names = Set.new(container_names)
containers = {}
while containers.size < names.size
Expand All @@ -45,7 +46,7 @@ def load_containers_from_name(tag, container_names, additional_containers)
when 'app'
AppContainer.new(@app, @app.definition['app'].merge('tag' => tag), dry_run: @dry_run)
else
Container.new(@app, additional_containers.fetch(name), dry_run: @dry_run)
Container.new(@app, sidecars.fetch(name), dry_run: @dry_run)
end

containers[name].links.each do |link|
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/yaml/default.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
app:
image: app-image
additional_containers:
sidecars:
front:
type: nginx
image_tag: front-image
2 changes: 1 addition & 1 deletion spec/fixtures/yaml/default_with_links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ app:
image: app-image
links:
- redis
additional_containers:
sidecars:
redis:
image_tag: redis
links:
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/yaml/default_with_volumes_from.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ app:
image: app-image
volumes_from:
- source_container: redis
additional_containers:
sidecars:
redis:
image_tag: redis
volumes_from:
Expand Down

0 comments on commit e8b55f0

Please sign in to comment.