@@ -73,6 +73,7 @@ type File struct {
7373
7474type Scroll struct {
7575 File
76+ filePath string
7677}
7778
7879type Procedure struct {
@@ -110,7 +111,9 @@ func NewScroll(scrollDir string) (*Scroll, error) {
110111 if err != nil {
111112 return nil , fmt .Errorf ("failed to read scroll.yaml - %w" , err )
112113 }
113- scroll := Scroll {}
114+ scroll := Scroll {
115+ filePath : filePath ,
116+ }
114117 if _ , err = scroll .ParseFile (file ); err != nil {
115118 return nil , err
116119 }
@@ -130,7 +133,7 @@ func (sc *Scroll) ParseFile(file []byte) (*Scroll, error) {
130133 return sc , nil
131134}
132135
133- func (sc * Scroll ) Validate () error {
136+ func (sc * Scroll ) Validate (strict bool ) error {
134137 if sc .Name == "" {
135138 return fmt .Errorf ("scroll name is required" )
136139 }
@@ -174,6 +177,28 @@ func (sc *Scroll) Validate() error {
174177 ids [* p .Id ] = true
175178 }
176179 }
180+ //scan for files in sc.filePath
181+ entries , err := os .ReadDir (sc .filePath )
182+ if err != nil {
183+ return fmt .Errorf ("failed to read scroll directory - %w" , err )
184+ }
185+ for _ , entry := range entries {
186+ var found = false
187+ for fileName := range ScrollFiles {
188+ if entry .Name () == fileName {
189+ found = true
190+ break
191+ }
192+ }
193+ if ! found {
194+ if ! strict {
195+ logger .Log ().Warn ("Directory contains file that is not defined in ScrollFiles" , zap .String ("file" , entry .Name ()))
196+ } else {
197+ return fmt .Errorf ("directory contains file that is not defined in ScrollFiles: %s" , entry .Name ())
198+ }
199+ }
200+ }
201+
177202 return nil
178203}
179204
@@ -184,3 +209,12 @@ func (sc *Scroll) CanColdStart() bool {
184209func (sc * Scroll ) GetColdStartPorts () []Port {
185210 return sc .Ports
186211}
212+
213+ var ScrollFiles = map [string ]ArtifactType {
214+ "update" : ArtifactTypeScrollFs ,
215+ "scroll.yaml" : ArtifactTypeScrollFs ,
216+ "packet_handler" : ArtifactTypeScrollFs ,
217+ "public" : ArtifactTypeScrollFs ,
218+ "private" : ArtifactTypeScrollFs ,
219+ "data" : ArtifactTypeScrollData ,
220+ }
0 commit comments