@@ -14,6 +14,7 @@ import (
14
14
"time"
15
15
16
16
"github.com/zarf-dev/zarf/src/pkg/logger"
17
+ "github.com/zarf-dev/zarf/src/pkg/utils"
17
18
18
19
"github.com/defenseunicorns/pkg/helpers/v2"
19
20
"github.com/defenseunicorns/pkg/oci"
@@ -206,7 +207,7 @@ func compatibleComponent(c v1alpha1.ZarfComponent, arch, flavor string) bool {
206
207
}
207
208
208
209
// TODO (phillebaba): Refactor package structure so that pullOCI can be used instead.
209
- func fetchOCISkeleton (ctx context.Context , component v1alpha1.ZarfComponent , packagePath string ) (string , error ) {
210
+ func fetchOCISkeleton (ctx context.Context , component v1alpha1.ZarfComponent , packagePath string ) (_ string , err error ) {
210
211
if component .Import .URL == "" {
211
212
return component .Import .Path , nil
212
213
}
@@ -216,14 +217,13 @@ func fetchOCISkeleton(ctx context.Context, component v1alpha1.ZarfComponent, pac
216
217
name = component .Import .Name
217
218
}
218
219
219
- absCachePath , err := config . GetAbsCachePath ( )
220
+ skeletonDataDir , err := utils . MakeTempDir ( config . CommonOptions . CachePath )
220
221
if err != nil {
221
222
return "" , err
222
223
}
223
- cache := filepath .Join (absCachePath , "oci" )
224
- if err := helpers .CreateDirectory (cache , helpers .ReadWriteExecuteUser ); err != nil {
225
- return "" , err
226
- }
224
+ defer func () {
225
+ err = errors .Join (err , os .RemoveAll (skeletonDataDir ))
226
+ }()
227
227
228
228
// Get the descriptor for the component.
229
229
remote , err := zoci .NewRemote (ctx , component .Import .URL , zoci .PlatformForSkeleton ())
@@ -247,11 +247,11 @@ func fetchOCISkeleton(ctx context.Context, component v1alpha1.ZarfComponent, pac
247
247
h .Write ([]byte (component .Import .URL + name ))
248
248
id := fmt .Sprintf ("%x" , h .Sum (nil ))
249
249
250
- dir = filepath .Join (cache , "dirs" , id )
250
+ dir = filepath .Join (skeletonDataDir , "dirs" , id )
251
251
} else {
252
- tarball = filepath .Join (cache , "blobs" , "sha256" , componentDesc .Digest .Encoded ())
253
- dir = filepath .Join (cache , "dirs" , componentDesc .Digest .Encoded ())
254
- store , err := ocistore .New (cache )
252
+ tarball = filepath .Join (skeletonDataDir , "blobs" , "sha256" , componentDesc .Digest .Encoded ())
253
+ dir = filepath .Join (skeletonDataDir , "dirs" , componentDesc .Digest .Encoded ())
254
+ store , err := ocistore .New (skeletonDataDir )
255
255
if err != nil {
256
256
return "" , err
257
257
}
0 commit comments