Format implements the fmt.Formatter interface to ensure that Hosts is printed correctly (i.e. not as a bunch of pointers). Fixes https://github.com/tailscale/tailscale/issues/5669
(f fmt.State, verb rune)
| 158 | // |
| 159 | // Fixes https://github.com/tailscale/tailscale/issues/5669 |
| 160 | func (a OSConfig) Format(f fmt.State, verb rune) { |
| 161 | logger.ArgWriter(func(w *bufio.Writer) { |
| 162 | if !buildfeatures.HasDNS { |
| 163 | w.WriteString(`{DNS-unlinked}`) |
| 164 | return |
| 165 | } |
| 166 | w.WriteString(`{Nameservers:[`) |
| 167 | for i, ns := range a.Nameservers { |
| 168 | if i != 0 { |
| 169 | w.WriteString(" ") |
| 170 | } |
| 171 | fmt.Fprintf(w, "%+v", ns) |
| 172 | } |
| 173 | w.WriteString(`] SearchDomains:[`) |
| 174 | for i, domain := range a.SearchDomains { |
| 175 | if i != 0 { |
| 176 | w.WriteString(" ") |
| 177 | } |
| 178 | fmt.Fprintf(w, "%+v", domain) |
| 179 | } |
| 180 | w.WriteString(`] MatchDomains:[`) |
| 181 | for i, domain := range a.MatchDomains { |
| 182 | if i != 0 { |
| 183 | w.WriteString(" ") |
| 184 | } |
| 185 | fmt.Fprintf(w, "%+v", domain) |
| 186 | } |
| 187 | w.WriteString(`] Hosts:[`) |
| 188 | for i, host := range a.Hosts { |
| 189 | if i != 0 { |
| 190 | w.WriteString(" ") |
| 191 | } |
| 192 | fmt.Fprintf(w, "%+v", host) |
| 193 | } |
| 194 | w.WriteString(`]}`) |
| 195 | }).Format(f, verb) |
| 196 | } |
| 197 | |
| 198 | // ErrGetBaseConfigNotSupported is the error |
| 199 | // OSConfigurator.GetBaseConfig returns when the OSConfigurator |