@@ -148,27 +148,8 @@ func translateResource(from Resource, options common.TranslateOptions) (to types
148148 r .AddOnError (c , err )
149149 return
150150 }
151- // Validating the contents of the local file from here since there is no way to
152- // get both the filename and filedirectory in the Validate context
153- if strings .HasPrefix (c .String (), "$.ignition.config" ) {
154- rp , err := ValidateIgnitionConfig (c , contents )
155- r .Merge (rp )
156- if err != nil {
157- return
158- }
159- }
160151
161- src , compression , err := baseutil .MakeDataURL (contents , to .Compression , ! options .NoResourceAutoCompression )
162- if err != nil {
163- r .AddOnError (c , err )
164- return
165- }
166- to .Source = & src
167- tm .AddTranslation (c , path .New ("json" , "source" ))
168- if compression != nil {
169- to .Compression = compression
170- tm .AddTranslation (c , path .New ("json" , "compression" ))
171- }
152+ handleIgnitionResource (contents , c , & r , & to , & tm , options )
172153 }
173154
174155 if from .Inline != nil {
@@ -509,3 +490,27 @@ func mountUnitFromFS(fs Filesystem, remote bool) types.Unit {
509490 Contents : util .StrToPtr (contents .String ()),
510491 }
511492}
493+
494+ func handleIgnitionResource (contents []byte , c path.ContextPath , r * report.Report , to * types.Resource , tm * translate.TranslationSet , options common.TranslateOptions ) {
495+ // Validating the contents of the local file from here since there is no way to
496+ // get both the filename and filedirectory in the Validate context
497+ if strings .HasPrefix (c .String (), "$.ignition.config" ) {
498+ rp , err := ValidateIgnitionConfig (c , contents )
499+ r .Merge (rp )
500+ if err != nil {
501+ return
502+ }
503+ }
504+
505+ src , compression , err := baseutil .MakeDataURL (contents , to .Compression , ! options .NoResourceAutoCompression )
506+ if err != nil {
507+ r .AddOnError (c , err )
508+ return
509+ }
510+ to .Source = & src
511+ tm .AddTranslation (c , path .New ("json" , "source" ))
512+ if compression != nil {
513+ to .Compression = compression
514+ tm .AddTranslation (c , path .New ("json" , "compression" ))
515+ }
516+ }
0 commit comments