Skip to content

Commit

Permalink
Read associated resources content
Browse files Browse the repository at this point in the history
  • Loading branch information
nesmabadr committed Jul 10, 2024
1 parent 0dff458 commit 7eeab44
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/module/parse/template_to_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/kyma-project/lifecycle-manager/pkg/log"
"github.com/kyma-project/lifecycle-manager/pkg/module/common"
"github.com/kyma-project/lifecycle-manager/pkg/templatelookup"
"io"

Check failure on line 19 in pkg/module/parse/template_to_module.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/kyma-project/lifecycle-manager) -s blank -s dot --custom-order (gci)
machineryruntime "k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"
Expand Down Expand Up @@ -273,19 +274,19 @@ func ReadAssociatedResourcesField(ctx context.Context, layer img.Layer) ([]strin
return nil, fmt.Errorf("failed to pull associated resources layer, %w", err)
}

blobReadCompressed, err := imgLayer.Compressed()
blobReader, err := imgLayer.Uncompressed()
if err != nil {
return nil, fmt.Errorf("failed fetching blob for layer %s: %w", imageRef, err)
}
logf.FromContext(ctx).V(log.InfoLevel).Info(fmt.Sprintf("Compressed: %v", blobReadCompressed))
defer blobReadCompressed.Close()
logf.FromContext(ctx).V(log.InfoLevel).Info(fmt.Sprintf("Uncompressed====: %v", blobReader))
defer blobReader.Close()

blobReadUncompressed, err := imgLayer.Uncompressed()
associatedResourcesContent, err := io.ReadAll(blobReader)
if err != nil {
return nil, fmt.Errorf("failed fetching blob for layer %s: %w", imageRef, err)
logf.FromContext(ctx).V(log.InfoLevel).Info("failed to read associated resources")
return nil, fmt.Errorf("failed reading associated resources: %w", err)
}
logf.FromContext(ctx).V(log.InfoLevel).Info(fmt.Sprintf("Uncompressed====: %v", blobReadUncompressed))
defer blobReadUncompressed.Close()
logf.FromContext(ctx).V(log.InfoLevel).Info(fmt.Sprintf("CONTENT: %s", string(associatedResourcesContent)))

Check failure on line 289 in pkg/module/parse/template_to_module.go

View workflow job for this annotation

GitHub Actions / lint

fmt.Sprintf can be replaced with string addition (perfsprint)

// filePath := fmt.Sprintf("%s/%s:%s/%s", associatedResources.Repo, associatedResources.Name, descriptorVersion,
// img.AssociatedResourcesLayer)
Expand Down

0 comments on commit 7eeab44

Please sign in to comment.