(envs map[string]interface{})
| 1897 | } |
| 1898 | |
| 1899 | func getAppCommonConfig(envs map[string]interface{}) request.AppContainerConfig { |
| 1900 | config := request.AppContainerConfig{} |
| 1901 | |
| 1902 | if hostIp, ok := envs[constant.HostIP]; ok { |
| 1903 | config.AllowPort = hostIp.(string) != "127.0.0.1" |
| 1904 | config.SpecifyIP = hostIp.(string) |
| 1905 | } else { |
| 1906 | config.AllowPort = true |
| 1907 | } |
| 1908 | if cpuCore, ok := envs[constant.CPUS]; ok { |
| 1909 | numStr, ok := cpuCore.(string) |
| 1910 | if ok { |
| 1911 | num, err := strconv.ParseFloat(numStr, 64) |
| 1912 | if err == nil { |
| 1913 | config.CpuQuota = num |
| 1914 | } |
| 1915 | } else { |
| 1916 | num64, flOk := cpuCore.(float64) |
| 1917 | if flOk { |
| 1918 | config.CpuQuota = num64 |
| 1919 | } |
| 1920 | } |
| 1921 | } else { |
| 1922 | config.CpuQuota = 0 |
| 1923 | } |
| 1924 | if memLimit, ok := envs[constant.MemoryLimit]; ok { |
| 1925 | matches := re.GetRegex(re.NumberAlphaPattern).FindStringSubmatch(memLimit.(string)) |
| 1926 | if len(matches) == 3 { |
| 1927 | num, err := strconv.ParseFloat(matches[1], 64) |
| 1928 | if err == nil { |
| 1929 | unit := matches[2] |
| 1930 | config.MemoryLimit = num |
| 1931 | config.MemoryUnit = unit |
| 1932 | } |
| 1933 | } |
| 1934 | } else { |
| 1935 | config.MemoryLimit = 0 |
| 1936 | config.MemoryUnit = "M" |
| 1937 | } |
| 1938 | |
| 1939 | if containerName, ok := envs[constant.ContainerName]; ok { |
| 1940 | config.ContainerName = containerName.(string) |
| 1941 | } |
| 1942 | |
| 1943 | return config |
| 1944 | } |
| 1945 | |
| 1946 | func isHostModel(dockerCompose string) bool { |
| 1947 | composeMap := make(map[string]interface{}) |
no outgoing calls
no test coverage detected