MCPcopy
hub / github.com/smallstep/cli / processDNSValue

Function processDNSValue

command/ca/init.go:827–847  ·  view source on GitHub ↗

processDNSValue reads DNS names from user supplied DNS value and transforms it into DNS names and IP addresses.

(dnsValue string)

Source from the content-addressed store, hash-verified

825// processDNSValue reads DNS names from user supplied DNS value
826// and transforms it into DNS names and IP addresses.
827func processDNSValue(dnsValue string) ([]string, error) {
828 var (
829 dnsValidator = ui.DNS()
830 dnsNames []string
831 )
832 dnsValue = strings.ReplaceAll(dnsValue, " ", ",")
833 parts := strings.Split(dnsValue, ",")
834 if allEmpty(parts) {
835 return nil, stderrors.New("dns must not be empty")
836 }
837 for _, name := range parts {
838 if name == "" { // skip empty name
839 continue
840 }
841 if err := dnsValidator(name); err != nil {
842 return nil, err
843 }
844 dnsNames = append(dnsNames, normalize(strings.TrimSpace(name)))
845 }
846 return dnsNames, nil
847}
848
849// normalize ensures an IPv6 hostname (i.e. [::1]) representation is
850// converted to its IP representation (::1).

Callers 2

initActionFunction · 0.85
Test_processDNSValueFunction · 0.85

Calls 2

allEmptyFunction · 0.85
normalizeFunction · 0.85

Tested by 1

Test_processDNSValueFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…