@@ -45,12 +45,12 @@ func PullFileFromRegistry(ctx context.Context, workdir string, dst io.Writer, so
4545
4646 repo , ref , err := parseOCIURL (sourceURL )
4747 if err != nil {
48- return fmt .Errorf ("could not parse OCI URL %s (%w) " , sourceURL , err )
48+ return fmt .Errorf ("could not parse OCI URL %s: %w " , sourceURL , err )
4949 }
5050
5151 r , err := remote .NewRepository (repo )
5252 if err != nil {
53- return fmt .Errorf ("could not create repository (%w)" , err )
53+ return fmt .Errorf ("could not create repository %s: %w" , repo , err )
5454 }
5555
5656 r .PlainHTTP = options .insecure
@@ -72,13 +72,13 @@ func PullFileFromRegistry(ctx context.Context, workdir string, dst io.Writer, so
7272
7373 d , err := os .MkdirTemp (workdir , "oci-pull" )
7474 if err != nil {
75- return fmt .Errorf ("could not create temporary directory (%w) " , err )
75+ return fmt .Errorf ("could not create temporary directory: %w " , err )
7676 }
7777 defer os .RemoveAll (d )
7878
7979 store , err := file .New (d )
8080 if err != nil {
81- return fmt .Errorf ("could not create file system (%w) " , err )
81+ return fmt .Errorf ("could not create file system: %w " , err )
8282 }
8383 defer store .Close ()
8484
@@ -87,7 +87,7 @@ func PullFileFromRegistry(ctx context.Context, workdir string, dst io.Writer, so
8787
8888 desc , err := oras .Copy (ctx , r , ref , store , "" , oras .DefaultCopyOptions )
8989 if err != nil {
90- return fmt .Errorf ("could not copy OCI image (%w) " , err )
90+ return fmt .Errorf ("could not copy OCI image: %w " , err )
9191 }
9292
9393 return copyOCIArtifact (ctx , dst , desc , store , options .targetOS , options .targetArch , options .mediaType , options .artifactType )
@@ -97,7 +97,7 @@ func PullFileFromRegistry(ctx context.Context, workdir string, dst io.Writer, so
9797func parseOCIURL (sourceURL string ) (repo string , ref string , _ error ) {
9898 u , err := url .Parse (sourceURL )
9999 if err != nil {
100- return "" , "" , fmt .Errorf ("could not parse URL %s (%w) " , sourceURL , err )
100+ return "" , "" , fmt .Errorf ("could not parse URL %s: %w " , sourceURL , err )
101101 }
102102
103103 if u .Scheme != "oci" {
@@ -137,13 +137,13 @@ func copyOCIArtifact(ctx context.Context, dst io.Writer, desc ocispec.Descriptor
137137 case ocispec .MediaTypeImageIndex :
138138 r , err := fetcher .Fetch (ctx , desc )
139139 if err != nil {
140- return fmt .Errorf ("could not fetch OCI image index (%w) " , err )
140+ return fmt .Errorf ("could not fetch OCI image index: %w " , err )
141141 }
142142 defer r .Close ()
143143
144144 var idx ocispec.Index
145145 if err := json .NewDecoder (r ).Decode (& idx ); err != nil {
146- return fmt .Errorf ("could not decode OCI image index (%w) " , err )
146+ return fmt .Errorf ("could not decode OCI image index: %w " , err )
147147 }
148148
149149 for _ , m := range idx .Manifests {
@@ -161,13 +161,13 @@ func copyOCIArtifact(ctx context.Context, dst io.Writer, desc ocispec.Descriptor
161161 case ocispec .MediaTypeImageManifest :
162162 r , err := fetcher .Fetch (ctx , desc )
163163 if err != nil {
164- return fmt .Errorf ("could not fetch OCI image manifest (%w) " , err )
164+ return fmt .Errorf ("could not fetch OCI image manifest: %w " , err )
165165 }
166166 defer r .Close ()
167167
168168 var manifest ocispec.Manifest
169169 if err := json .NewDecoder (r ).Decode (& manifest ); err != nil {
170- return fmt .Errorf ("could not decode OCI image manifest (%w) " , err )
170+ return fmt .Errorf ("could not decode OCI image manifest: %w " , err )
171171 }
172172
173173 if artifactType != "" && artifactType != manifest .ArtifactType {
@@ -181,12 +181,12 @@ func copyOCIArtifact(ctx context.Context, dst io.Writer, desc ocispec.Descriptor
181181
182182 r , err = fetcher .Fetch (ctx , layer )
183183 if err != nil {
184- return fmt .Errorf ("could not fetch OCI layer (%w) " , err )
184+ return fmt .Errorf ("could not fetch OCI layer: %w " , err )
185185 }
186186 defer r .Close ()
187187
188188 if _ , err := io .Copy (dst , r ); err != nil {
189- return fmt .Errorf ("could not copy OCI layer (%w) " , err )
189+ return fmt .Errorf ("could not copy OCI layer: %w " , err )
190190 }
191191 }
192192
0 commit comments