@@ -2,7 +2,7 @@ import { v1 } from "@docker/extension-api-client-types";
22import { CatalogItem , CatalogItemRichened , CatalogItemWithName } from '../types/catalog' ;
33import { getRegistry , syncRegistryWithConfig } from '../Registry' ;
44import Secrets from '../Secrets' ;
5- import { parse } from ' yaml' ;
5+ import { parse , stringify } from " yaml" ;
66import { CATALOG_URL , POLL_INTERVAL , UNASSIGNED_SECRET_PLACEHOLDER } from '../Constants' ;
77import { useQuery , useMutation , useQueryClient } from '@tanstack/react-query' ;
88import { getTemplateForItem } from './useConfig' ;
@@ -183,12 +183,14 @@ function useRegistry(client: v1.DockerDesktopClient) {
183183
184184 const mutateRegistry = useMutation ( {
185185 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 ) ;
190192
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 ] ) ;
192194
193195 return newRegistry ;
194196 }
@@ -226,12 +228,14 @@ export function useCatalogOperations(client: v1.DockerDesktopClient) {
226228 [ item . name ] : { ref : item . ref }
227229 } ;
228230
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 ) ;
233237
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 ] ) ;
235239
236240 if ( showNotification ) {
237241 client . desktopUI . toast . success ( `${ item . name } registered successfully.` ) ;
@@ -271,12 +275,14 @@ export function useCatalogOperations(client: v1.DockerDesktopClient) {
271275 delete currentRegistry [ item . name ] ;
272276 }
273277
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 ) ;
278284
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 ] ) ;
280286
281287 client . desktopUI . toast . success ( `${ item . name } unregistered successfully.` ) ;
282288 return { success : true , newRegistry : currentRegistry } ;
0 commit comments