Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Commit

Permalink
only use local cache if the cache env var is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Schrodi committed Jul 13, 2021
1 parent 79cae9c commit 1477906
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions pkg/commands/imagevector/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,11 @@ func (o *AddOptions) Run(ctx context.Context, log logr.Logger, fs vfs.FileSystem
if err != nil {
return err
}
compCache := components.NewLocalComponentCache(fs)
compResolver := cdoci.NewResolver(ociClient).
WithLog(log).
WithCache(compCache)
WithLog(log)
if len(os.Getenv(constants.ComponentRepositoryCacheDirEnvVar)) != 0 {
compResolver.WithCache(components.NewLocalComponentCache(fs))
}

// add the input to the ctf format
cd := &cdv2.ComponentDescriptor{}
Expand Down
7 changes: 4 additions & 3 deletions pkg/commands/imagevector/generateoverwrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,11 @@ func (o *GenerateOverwriteOptions) Run(ctx context.Context, log logr.Logger, fs
if err != nil {
return err
}
compCache := components.NewLocalComponentCache(fs)
compResolver := cdoci.NewResolver(ociClient).
WithLog(log).
WithCache(compCache)
WithLog(log)
if len(os.Getenv(constants.ComponentRepositoryCacheDirEnvVar)) != 0 {
compResolver.WithCache(components.NewLocalComponentCache(fs))
}

root, main, err := o.getComponentDescriptor(ctx, fs, compResolver)
if err != nil {
Expand Down

0 comments on commit 1477906

Please sign in to comment.