@@ -2,7 +2,7 @@ import { v1 } from "@docker/extension-api-client-types";
2
2
import { CatalogItem , CatalogItemRichened , CatalogItemWithName } from '../types/catalog' ;
3
3
import { getRegistry , syncRegistryWithConfig } from '../Registry' ;
4
4
import Secrets from '../Secrets' ;
5
- import { parse } from ' yaml' ;
5
+ import { parse , stringify } from " yaml" ;
6
6
import { CATALOG_URL , POLL_INTERVAL , UNASSIGNED_SECRET_PLACEHOLDER } from '../Constants' ;
7
7
import { useQuery , useMutation , useQueryClient } from '@tanstack/react-query' ;
8
8
import { getTemplateForItem } from './useConfig' ;
@@ -183,12 +183,14 @@ function useRegistry(client: v1.DockerDesktopClient) {
183
183
184
184
const mutateRegistry = useMutation ( {
185
185
mutationFn : async ( newRegistry : { [ key : string ] : { ref : string ; config ?: any } } ) => {
186
- const payload = escapeJSONForPlatformShell (
187
- { registry : newRegistry } ,
188
- client . host . platform
189
- ) ;
186
+ const payload = escapeJSONForPlatformShell ( {
187
+ files : [ {
188
+ path : 'registry.yaml' ,
189
+ content : stringify ( { registry : newRegistry } )
190
+ } ]
191
+ } , client . host . platform ) ;
190
192
191
- await tryRunImageSync ( client , [ '--rm' , '-v' , 'docker-prompts:/docker-prompts' , '--workdir' , '/docker-prompts' , 'vonwig/function_write_files:latest' , 'registry.yaml' , payload ] ) ;
193
+ await tryRunImageSync ( client , [ '--rm' , '-v' , 'docker-prompts:/docker-prompts' , '--workdir' , '/docker-prompts' , 'vonwig/function_write_files:latest' , payload ] ) ;
192
194
193
195
return newRegistry ;
194
196
}
@@ -226,12 +228,14 @@ export function useCatalogOperations(client: v1.DockerDesktopClient) {
226
228
[ item . name ] : { ref : item . ref }
227
229
} ;
228
230
229
- const payload = escapeJSONForPlatformShell (
230
- { registry : newRegistry } ,
231
- client . host . platform
232
- ) ;
231
+ const payload = escapeJSONForPlatformShell ( {
232
+ files : [ {
233
+ path : "registry.yaml" ,
234
+ content : stringify ( { registry : newRegistry } )
235
+ } ]
236
+ } , client . host . platform ) ;
233
237
234
- await tryRunImageSync ( client , [ '--rm' , '-v' , 'docker-prompts:/docker-prompts' , '--workdir' , '/docker-prompts' , 'vonwig/function_write_files:latest' , 'registry.yaml' , payload ] ) ;
238
+ await tryRunImageSync ( client , [ '--rm' , '-v' , 'docker-prompts:/docker-prompts' , '--workdir' , '/docker-prompts' , 'vonwig/function_write_files:latest' , payload ] ) ;
235
239
236
240
if ( showNotification ) {
237
241
client . desktopUI . toast . success ( `${ item . name } registered successfully.` ) ;
@@ -271,12 +275,14 @@ export function useCatalogOperations(client: v1.DockerDesktopClient) {
271
275
delete currentRegistry [ item . name ] ;
272
276
}
273
277
274
- const payload = escapeJSONForPlatformShell (
275
- { registry : currentRegistry } ,
276
- client . host . platform
277
- ) ;
278
+ const payload = escapeJSONForPlatformShell ( {
279
+ files : [ {
280
+ path : "registry.yaml" ,
281
+ content : stringify ( { registry : currentRegistry } )
282
+ } ]
283
+ } , client . host . platform ) ;
278
284
279
- await tryRunImageSync ( client , [ '--rm' , '-v' , 'docker-prompts:/docker-prompts' , '--workdir' , '/docker-prompts' , 'vonwig/function_write_files:latest' , 'registry.yaml' , payload ] ) ;
285
+ await tryRunImageSync ( client , [ '--rm' , '-v' , 'docker-prompts:/docker-prompts' , '--workdir' , '/docker-prompts' , 'vonwig/function_write_files:latest' , payload ] ) ;
280
286
281
287
client . desktopUI . toast . success ( `${ item . name } unregistered successfully.` ) ;
282
288
return { success : true , newRegistry : currentRegistry } ;
0 commit comments