@@ -17,6 +17,7 @@ import (
1717 cloudmap "github.com/awslabs/goformation/v4/cloudformation/servicediscovery"
1818 "github.com/awslabs/goformation/v4/cloudformation/tags"
1919 "github.com/compose-spec/compose-go/compatibility"
20+ "github.com/compose-spec/compose-go/errdefs"
2021 "github.com/compose-spec/compose-go/types"
2122 "github.com/docker/ecs-plugin/pkg/compose"
2223 "github.com/sirupsen/logrus"
@@ -39,8 +40,7 @@ func (c *FargateCompatibilityChecker) CheckPortsPublished(p *types.ServicePortCo
3940 p .Published = p .Target
4041 }
4142 if p .Published != p .Target {
42- c .Error ("published port can't be set to a distinct value than container port" )
43- p .Published = p .Target
43+ c .Incompatible ("published port can't be set to a distinct value than container port" )
4444 }
4545}
4646
@@ -51,7 +51,7 @@ func (c *FargateCompatibilityChecker) CheckCapAdd(service *types.ServiceConfig)
5151 case "SYS_PTRACE" :
5252 add = append (add , cap )
5353 default :
54- c .Error ( "service.cap_add = %s" , cap )
54+ c .Incompatible ( "ECS doesn't allow to add capability %s" , cap )
5555 }
5656 }
5757 service .CapAdd = add
@@ -86,7 +86,14 @@ func (b Backend) Convert(project *types.Project) (*cloudformation.Template, erro
8686 }
8787 compatibility .Check (project , checker )
8888 for _ , err := range checker .Errors () {
89- logrus .Warn (err .Error ())
89+ if errdefs .IsIncompatibleError (err ) {
90+ logrus .Error (err .Error ())
91+ } else {
92+ logrus .Warn (err .Error ())
93+ }
94+ }
95+ if ! compatibility .IsCompatible (checker ) {
96+ return nil , fmt .Errorf ("compose file is incompatible with Amazon ECS" )
9097 }
9198
9299 template := cloudformation .NewTemplate ()
0 commit comments