@@ -41,6 +41,7 @@ func (a *Application) IsValid(options ...ValidationOption) []gojsonschema.Result
4141 violations = append (violations , a .checkNoEnvVarCollisions ()... )
4242 violations = append (violations , a .checkAccessPermissions ()... )
4343 violations = append (violations , a .checkNoRedundantEntrypointRoutes ()... )
44+ violations = append (violations , a .checkEntrypointTargetsExist ()... )
4445
4546 if opts .RequireSubtypes {
4647 violations = append (violations , a .checkSubtypesRequired ()... )
@@ -49,6 +50,31 @@ func (a *Application) IsValid(options ...ValidationOption) []gojsonschema.Result
4950 return violations
5051}
5152
53+ func (a * Application ) checkEntrypointTargetsExist () []gojsonschema.ResultError {
54+ violations := []gojsonschema.ResultError {}
55+
56+ for entrypointName , intent := range a .EntrypointIntents {
57+ for routePath , route := range intent .Routes {
58+ _ , serviceExists := a .ServiceIntents [route .TargetName ]
59+ _ , bucketExists := a .BucketIntents [route .TargetName ]
60+
61+ _ , resourceExists := a .GetResourceIntent (route .TargetName )
62+
63+ if ! serviceExists && ! bucketExists {
64+ key := fmt .Sprintf ("entrypoints.%s.routes.%s.name" , entrypointName , routePath )
65+ var err = fmt .Sprintf ("Route %s targets non-existent resource %s" , routePath , route .TargetName )
66+ if resourceExists {
67+ err = fmt .Sprintf ("Route %s targets resource %s which is not a service or bucket" , routePath , route .TargetName )
68+ }
69+
70+ violations = append (violations , newValidationError (key , err ))
71+ }
72+ }
73+ }
74+
75+ return violations
76+ }
77+
5278func (a * Application ) checkAccessPermissions () []gojsonschema.ResultError {
5379 violations := []gojsonschema.ResultError {}
5480
0 commit comments