Skip to content

Commit

Permalink
Fix/image sub (#16)
Browse files Browse the repository at this point in the history
* fix: image repo

* test files
  • Loading branch information
raykrishardi authored Jul 24, 2024
1 parent 2cd8b4a commit a54280e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ecs-task.cfndsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@

name = task.has_key?('name') ? task['name'] : task_name

image_repo = task.has_key?('repo') ? "#{task['repo']}" : ''
image_repo = task.has_key?('repo') ? "#{task['repo']}/" : ''
image_name = task.has_key?('image') ? task['image'] : task_name
image_tag = task.has_key?('tag') ? "#{task['tag']}" : 'latest'
image_tag = task.has_key?('tag_param') ? Ref("#{task['tag_param']}") : image_tag

# create main definition
task_def = {
Name: name,
Image: FnJoin('', [FnSub("#{image_repo}/#{image_name}"), ":", image_tag]),
Image: FnJoin('', [FnSub("#{image_repo}#{image_name}"), ":", image_tag]),
LogConfiguration: {
LogDriver: 'awslogs',
Options: {
Expand Down
2 changes: 1 addition & 1 deletion spec/depends_on_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
end

it "to have property ContainerDefinitions" do
expect(resource["Properties"]["ContainerDefinitions"]).to eq([{"Name"=>"nginx", "Image"=>{"Fn::Join"=>["", [{"Fn::Sub"=>"nginx/nginx"}, ":", "latest"]]}, "LogConfiguration"=>{"LogDriver"=>"awslogs", "Options"=>{"awslogs-group"=>{"Ref"=>"LogGroup"}, "awslogs-region"=>{"Ref"=>"AWS::Region"}, "awslogs-stream-prefix"=>"nginx"}}, "DependsOn"=>[{"ContainerName"=>"db", "Condition"=>"START"}]}, {"Name"=>"db", "Image"=>{"Fn::Join"=>["", [{"Fn::Sub"=>"/postgres"}, ":", "latest"]]}, "LogConfiguration"=>{"LogDriver"=>"awslogs", "Options"=>{"awslogs-group"=>{"Ref"=>"LogGroup"}, "awslogs-region"=>{"Ref"=>"AWS::Region"}, "awslogs-stream-prefix"=>"db"}}, "Essential"=>false, "PortMappings"=>[{"ContainerPort"=>5432}]}])
expect(resource["Properties"]["ContainerDefinitions"]).to eq([{"Name"=>"nginx", "Image"=>{"Fn::Join"=>["", [{"Fn::Sub"=>"nginx/nginx"}, ":", "latest"]]}, "LogConfiguration"=>{"LogDriver"=>"awslogs", "Options"=>{"awslogs-group"=>{"Ref"=>"LogGroup"}, "awslogs-region"=>{"Ref"=>"AWS::Region"}, "awslogs-stream-prefix"=>"nginx"}}, "DependsOn"=>[{"ContainerName"=>"db", "Condition"=>"START"}]}, {"Name"=>"db", "Image"=>{"Fn::Join"=>["", [{"Fn::Sub"=>"postgres"}, ":", "latest"]]}, "LogConfiguration"=>{"LogDriver"=>"awslogs", "Options"=>{"awslogs-group"=>{"Ref"=>"LogGroup"}, "awslogs-region"=>{"Ref"=>"AWS::Region"}, "awslogs-stream-prefix"=>"db"}}, "Essential"=>false, "PortMappings"=>[{"ContainerPort"=>5432}]}])
end

it "to have property RequiresCompatibilities" do
Expand Down

0 comments on commit a54280e

Please sign in to comment.