Download data/packages/server/src/utils/docker/collision/root-network.ts from llama1/dokpl0y: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/datasets/llama1/dokpl0y/resolve/main/data/packages/server/src/utils/docker/collision/root-network.ts
- Command line
-
hf download hf://datasets/llama1/dokpl0y/data/packages/server/src/utils/docker/collision/root-network.ts
-
curl -L -o root-network.ts https://huggingface.co/datasets/llama1/dokpl0y/resolve/main/data/packages/server/src/utils/docker/collision/root-network.ts
1.48 kB
| import _ from "lodash"; | |
| import type { ComposeSpecification, DefinitionsService } from "../types"; | |
| export const addAppNameToRootNetwork = ( | |
| composeData: ComposeSpecification, | |
| appName: string, | |
| ): ComposeSpecification => { | |
| const updatedComposeData = { ...composeData }; | |
| // Initialize networks if it doesn't exist | |
| if (!updatedComposeData.networks) { | |
| updatedComposeData.networks = {}; | |
| } | |
| // Add the new network with the app name | |
| updatedComposeData.networks[appName] = { | |
| name: appName, | |
| external: true, | |
| }; | |
| return updatedComposeData; | |
| }; | |
| export const addAppNameToServiceNetworks = ( | |
| services: { [key: string]: DefinitionsService }, | |
| appName: string, | |
| ): { [key: string]: DefinitionsService } => { | |
| return _.mapValues(services, (service) => { | |
| if (!service.networks) { | |
| service.networks = [appName]; | |
| return service; | |
| } | |
| if (Array.isArray(service.networks)) { | |
| if (!service.networks.includes(appName)) { | |
| service.networks.push(appName); | |
| } | |
| } else { | |
| service.networks[appName] = {}; | |
| } | |
| return service; | |
| }); | |
| }; | |
| export const addAppNameToAllServiceNames = ( | |
| composeData: ComposeSpecification, | |
| appName: string, | |
| ): ComposeSpecification => { | |
| let updatedComposeData = { ...composeData }; | |
| updatedComposeData = addAppNameToRootNetwork(updatedComposeData, appName); | |
| if (updatedComposeData.services) { | |
| updatedComposeData.services = addAppNameToServiceNetworks( | |
| updatedComposeData.services, | |
| appName, | |
| ); | |
| } | |
| return updatedComposeData; | |
| }; | |