(c *cli.Context, log *zerolog.Logger)
| 243 | } |
| 244 | |
| 245 | func buildArgsForConfig(c *cli.Context, log *zerolog.Logger) ([]string, error) { |
| 246 | if err := ensureConfigDirExists(serviceConfigDir); err != nil { |
| 247 | return nil, err |
| 248 | } |
| 249 | |
| 250 | src, _, err := config.ReadConfigFile(c, log) |
| 251 | if err != nil { |
| 252 | return nil, err |
| 253 | } |
| 254 | |
| 255 | // can't use context because this command doesn't define "credentials-file" flag |
| 256 | configPresent := func(s string) bool { |
| 257 | val, err := src.String(s) |
| 258 | return err == nil && val != "" |
| 259 | } |
| 260 | if src.TunnelID == "" || !configPresent(tunnel.CredFileFlag) { |
| 261 | return nil, fmt.Errorf(`Configuration file %s must contain entries for the tunnel to run and its associated credentials: |
| 262 | tunnel: TUNNEL-UUID |
| 263 | credentials-file: CREDENTIALS-FILE |
| 264 | `, src.Source()) |
| 265 | } |
| 266 | if src.Source() != serviceConfigPath { |
| 267 | if exists, err := config.FileExists(serviceConfigPath); err != nil || exists { |
| 268 | return nil, fmt.Errorf("Possible conflicting configuration in %[1]s and %[2]s. Either remove %[2]s or run `cloudflared --config %[2]s service install`", src.Source(), serviceConfigPath) |
| 269 | } |
| 270 | |
| 271 | if err := copyFile(src.Source(), serviceConfigPath); err != nil { |
| 272 | return nil, fmt.Errorf("failed to copy %s to %s: %w", src.Source(), serviceConfigPath, err) |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | return []string{ |
| 277 | "--config", "/etc/cloudflared/config.yml", "tunnel", "run", |
| 278 | }, nil |
| 279 | } |
| 280 | |
| 281 | func installSystemd(templateArgs *ServiceTemplateArgs, autoUpdate bool, log *zerolog.Logger) error { |
| 282 | var systemdTemplates []ServiceTemplate |
nothing calls this directly
no test coverage detected