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

Function parseTimeString

agent/app/service/website_utils.go:1764–1783  ·  view source on GitHub ↗
(input string)

Source from the content-addressed store, hash-verified

1762}
1763
1764func parseTimeString(input string) (int, string, error) {
1765 input = strings.TrimSpace(input)
1766
1767 matches := re.GetRegex(re.DurationWithOptionalUnitPattern).FindStringSubmatch(input)
1768
1769 if len(matches) < 2 {
1770 return 0, "", fmt.Errorf("invalid time format: %s", input)
1771 }
1772
1773 value, err := strconv.Atoi(matches[1])
1774 if err != nil {
1775 return 0, "", fmt.Errorf("invalid number: %s", matches[1])
1776 }
1777
1778 unit := matches[2]
1779 if unit == "" {
1780 unit = "s"
1781 }
1782 return value, unit, nil
1783}
1784
1785func parseUpstreamServers(reqServers []dto.NginxUpstreamServer) []*components.UpstreamServer {
1786 var servers []*components.UpstreamServer

Callers 1

getNginxUpstreamServersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected