From a54280ea7f866229651a033758b18546fc12d04d Mon Sep 17 00:00:00 2001 From: Ray Krishardi Layadi Date: Wed, 24 Jul 2024 16:58:01 +1000 Subject: [PATCH] Fix/image sub (#16) * fix: image repo * test files --- ecs-task.cfndsl.rb | 4 ++-- spec/depends_on_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ecs-task.cfndsl.rb b/ecs-task.cfndsl.rb index caad7fd..94cf39e 100644 --- a/ecs-task.cfndsl.rb +++ b/ecs-task.cfndsl.rb @@ -30,7 +30,7 @@ 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 @@ -38,7 +38,7 @@ # 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: { diff --git a/spec/depends_on_spec.rb b/spec/depends_on_spec.rb index 5ac28db..22df506 100644 --- a/spec/depends_on_spec.rb +++ b/spec/depends_on_spec.rb @@ -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