MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / cloneContainerConfig

Function cloneContainerConfig

agent/app/service/backup_container.go:803–832  ·  view source on GitHub ↗
(config *container.Config)

Source from the content-addressed store, hash-verified

801}
802
803func cloneContainerConfig(config *container.Config) *container.Config {
804 if config == nil {
805 return &container.Config{}
806 }
807 item := *config
808 if len(config.Env) != 0 {
809 item.Env = append([]string(nil), config.Env...)
810 }
811 if len(config.Cmd) != 0 {
812 item.Cmd = append([]string(nil), config.Cmd...)
813 }
814 if len(config.Entrypoint) != 0 {
815 item.Entrypoint = append([]string(nil), config.Entrypoint...)
816 }
817 if len(config.Labels) != 0 {
818 labels := make(map[string]string, len(config.Labels))
819 for key, val := range config.Labels {
820 labels[key] = val
821 }
822 item.Labels = labels
823 }
824 if len(config.Volumes) != 0 {
825 volumes := make(map[string]struct{}, len(config.Volumes))
826 for key, val := range config.Volumes {
827 volumes[key] = val
828 }
829 item.Volumes = volumes
830 }
831 return &item
832}
833
834func cloneContainerHostConfig(hostConfig *container.HostConfig) *container.HostConfig {
835 if hostConfig == nil {

Callers 1

stepRecreateContainerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected