ValidateWorkspaceHostnameSuffix validates a deployment-provided SSH hostname suffix before it is made available to clients.
(suffix string)
| 734 | // ValidateWorkspaceHostnameSuffix validates a deployment-provided SSH hostname |
| 735 | // suffix before it is made available to clients. |
| 736 | func ValidateWorkspaceHostnameSuffix(suffix string) error { |
| 737 | // The suffix is implicitly prefixed with a dot when matching, so a leading |
| 738 | // dot is a config error: it forces the suffix to be a separate DNS label |
| 739 | // rather than an ordinary string suffix. E.g. "coder" matches "en.coder" |
| 740 | // but not "encoder". |
| 741 | if strings.HasPrefix(suffix, ".") { |
| 742 | return xerrors.Errorf("workspace hostname suffix %q must not start with a leading dot", suffix) |
| 743 | } |
| 744 | if strings.ContainsAny(suffix, "*?") { |
| 745 | return xerrors.Errorf("workspace hostname suffix %q must not contain glob characters", suffix) |
| 746 | } |
| 747 | if !isSingleHostPatternToken(suffix) { |
| 748 | return xerrors.Errorf("workspace hostname suffix %q must not contain whitespace or control characters", suffix) |
| 749 | } |
| 750 | return nil |
| 751 | } |
| 752 | |
| 753 | // ValidateWorkspaceHostnamePrefix validates a deployment-provided SSH hostname |
| 754 | // prefix before it is made available to clients. Unlike the suffix, a prefix |