@@ -35,6 +35,7 @@ import (
3535	"github.com/e2b-dev/infra/packages/shared/pkg/storage" 
3636	"github.com/e2b-dev/infra/packages/shared/pkg/storage/header" 
3737	"github.com/e2b-dev/infra/packages/shared/pkg/telemetry" 
38+ 	"github.com/e2b-dev/infra/packages/shared/pkg/templates" 
3839	"github.com/e2b-dev/infra/packages/shared/pkg/utils" 
3940)
4041
@@ -101,7 +102,7 @@ type Result struct {
101102// 
102103// 8. Snapshot 
103104// 9. Upload template (and all not yet uploaded layers) 
104- func  (b  * Builder ) Build (ctx  context.Context , template  storage.TemplateFiles , config  config.TemplateConfig , logsCore  zapcore.Core ) (r  * Result , e  error ) {
105+ func  (b  * Builder ) Build (ctx  context.Context , template  storage.TemplateFiles , cfg  config.TemplateConfig , logsCore  zapcore.Core ) (r  * Result , e  error ) {
105106	ctx , childSpan  :=  tracer .Start (ctx , "build" )
106107	defer  childSpan .End ()
107108
@@ -113,20 +114,20 @@ func (b *Builder) Build(ctx context.Context, template storage.TemplateFiles, con
113114		b .metrics .RecordBuildDuration (ctx , duration , success )
114115
115116		if  success  {
116- 			b .metrics .RecordBuildResult (ctx , config .TeamID , true )
117+ 			b .metrics .RecordBuildResult (ctx , cfg .TeamID , true )
117118			b .metrics .RecordRootfsSize (ctx , r .RootfsSizeMB << constants .ToMBShift )
118119		} else  if  ! errors .Is (e , context .Canceled ) {
119120			// Skip reporting failure metrics only on explicit cancellation 
120- 			b .metrics .RecordBuildResult (ctx , config .TeamID , false )
121+ 			b .metrics .RecordBuildResult (ctx , cfg .TeamID , false )
121122		}
122123	}()
123124
124- 	cacheScope  :=  config .CacheScope 
125+ 	cacheScope  :=  cfg .CacheScope 
125126
126127	// Validate template, update force layers if needed 
127- 	config  =  forceSteps (config )
128+ 	cfg  =  forceSteps (cfg )
128129
129- 	isV1Build  :=  utils .IsVersion (config .Version , "v1.0.0" ) ||  (config .FromImage  ==  ""  &&  config .FromTemplate  ==  nil )
130+ 	isV1Build  :=  utils .IsVersion (cfg .Version , templates . TemplateV1Version ) ||  (cfg .FromImage  ==  ""  &&  cfg .FromTemplate  ==  nil )
130131
131132	logger  :=  zap .New (logsCore )
132133	defer  func () {
@@ -143,7 +144,7 @@ func (b *Builder) Build(ctx context.Context, template storage.TemplateFiles, con
143144
144145	defer  func () {
145146		if  r  :=  recover (); r  !=  nil  {
146- 			telemetry .ReportCriticalError (ctx , "recovered from panic in template build" , nil , attribute .String ("panic" , fmt .Sprintf ("%v" , r )), telemetry .WithTemplateID (config .TemplateID ), telemetry .WithBuildID (template .BuildID ))
147+ 			telemetry .ReportCriticalError (ctx , "recovered from panic in template build" , nil , attribute .String ("panic" , fmt .Sprintf ("%v" , r )), telemetry .WithTemplateID (cfg .TemplateID ), telemetry .WithBuildID (template .BuildID ))
147148			e  =  errors .New ("fatal error occurred during template build, please contact us" )
148149		}
149150	}()
@@ -154,7 +155,7 @@ func (b *Builder) Build(ctx context.Context, template storage.TemplateFiles, con
154155		logger  =  zap .New (hookedCore )
155156	}
156157
157- 	logger .Info (fmt .Sprintf ("Building template %s/%s" , config .TemplateID , template .BuildID ))
158+ 	logger .Info (fmt .Sprintf ("Building template %s/%s" , cfg .TemplateID , template .BuildID ))
158159
159160	defer  func (ctx  context.Context ) {
160161		if  e  ==  nil  {
@@ -183,13 +184,13 @@ func (b *Builder) Build(ctx context.Context, template storage.TemplateFiles, con
183184	}()
184185
185186	buildContext  :=  buildcontext.BuildContext {
186- 		Config :         config ,
187+ 		Config :         cfg ,
187188		Template :       template ,
188189		UploadErrGroup : & uploadErrGroup ,
189190		EnvdVersion :    envdVersion ,
190191		CacheScope :     cacheScope ,
191192		IsV1Build :      isV1Build ,
192- 		Version :        config .Version ,
193+ 		Version :        cfg .Version ,
193194	}
194195
195196	return  runBuild (ctx , logger , buildContext , b )
@@ -269,7 +270,7 @@ func runBuild(
269270		baseBuilder ,
270271	}
271272	// Default user is only set for version TemplateDefaultUserVersion 
272- 	ok , err  :=  utils .IsGTEVersion (bc .Version , config .TemplateDefaultUserVersion )
273+ 	ok , err  :=  utils .IsGTEVersion (bc .Version , templates .TemplateDefaultUserVersion )
273274	if  err  !=  nil  {
274275		return  nil , fmt .Errorf ("error checking build version: %w" , err )
275276	}
0 commit comments