@@ -58,12 +58,12 @@ var (
5858
5959// Attach attaches user materials into the model artifact which follows the Model Spec.
6060func (b * backend ) Attach (ctx context.Context , filepath string , cfg * config.Attach ) error {
61- srcManifest , err := b .getManifest (ctx , cfg .Source , cfg )
61+ srcManifest , err := b .getManifest (ctx , cfg .Source , cfg . OutputRemote , cfg . PlainHTTP , cfg . Insecure )
6262 if err != nil {
6363 return fmt .Errorf ("failed to get source manifest: %w" , err )
6464 }
6565
66- srcModelConfig , err := b .getModelConfig (ctx , cfg .Source , srcManifest .Config , cfg )
66+ srcModelConfig , err := b .getModelConfig (ctx , cfg .Source , srcManifest .Config , cfg . OutputRemote , cfg . PlainHTTP , cfg . Insecure )
6767 if err != nil {
6868 return fmt .Errorf ("failed to get source model config: %w" , err )
6969 }
@@ -169,7 +169,7 @@ func (b *backend) Attach(ctx context.Context, filepath string, cfg *config.Attac
169169 return nil
170170}
171171
172- func (b * backend ) getManifest (ctx context.Context , reference string , cfg * config. Attach ) (* ocispec.Manifest , error ) {
172+ func (b * backend ) getManifest (ctx context.Context , reference string , fromRemote , plainHTTP , insecure bool ) (* ocispec.Manifest , error ) {
173173 ref , err := ParseReference (reference )
174174 if err != nil {
175175 return nil , fmt .Errorf ("failed to parse source reference: %w" , err )
@@ -181,7 +181,7 @@ func (b *backend) getManifest(ctx context.Context, reference string, cfg *config
181181 }
182182
183183 // Fetch from local storage if it is not remote.
184- if ! cfg . OutputRemote {
184+ if ! fromRemote {
185185 manifestRaw , _ , err := b .store .PullManifest (ctx , repo , tag )
186186 if err != nil {
187187 return nil , fmt .Errorf ("failed to pull manifest: %w" , err )
@@ -195,7 +195,7 @@ func (b *backend) getManifest(ctx context.Context, reference string, cfg *config
195195 return & manifest , nil
196196 }
197197
198- client , err := remote .New (repo , remote .WithPlainHTTP (cfg . PlainHTTP ), remote .WithInsecure (cfg . Insecure ))
198+ client , err := remote .New (repo , remote .WithPlainHTTP (plainHTTP ), remote .WithInsecure (insecure ))
199199 if err != nil {
200200 return nil , fmt .Errorf ("failed to create remote client: %w" , err )
201201 }
@@ -214,7 +214,7 @@ func (b *backend) getManifest(ctx context.Context, reference string, cfg *config
214214 return & manifest , nil
215215}
216216
217- func (b * backend ) getModelConfig (ctx context.Context , reference string , desc ocispec.Descriptor , cfg * config. Attach ) (* modelspec.Model , error ) {
217+ func (b * backend ) getModelConfig (ctx context.Context , reference string , desc ocispec.Descriptor , fromRemote , plainHTTP , insecure bool ) (* modelspec.Model , error ) {
218218 ref , err := ParseReference (reference )
219219 if err != nil {
220220 return nil , fmt .Errorf ("failed to parse reference: %w" , err )
@@ -226,7 +226,7 @@ func (b *backend) getModelConfig(ctx context.Context, reference string, desc oci
226226 }
227227
228228 // Fetch from local storage if it is not remote.
229- if ! cfg . OutputRemote {
229+ if ! fromRemote {
230230 reader , err := b .store .PullBlob (ctx , repo , desc .Digest .String ())
231231 if err != nil {
232232 return nil , fmt .Errorf ("failed to pull blob: %w" , err )
@@ -241,7 +241,7 @@ func (b *backend) getModelConfig(ctx context.Context, reference string, desc oci
241241 return & model , nil
242242 }
243243
244- client , err := remote .New (repo , remote .WithPlainHTTP (cfg . PlainHTTP ), remote .WithInsecure (cfg . Insecure ))
244+ client , err := remote .New (repo , remote .WithPlainHTTP (plainHTTP ), remote .WithInsecure (insecure ))
245245 if err != nil {
246246 return nil , fmt .Errorf ("failed to create remote client: %w" , err )
247247 }
0 commit comments