MCPcopy
hub / github.com/cloudflare/cloudflared / buildArgsForConfig

Function buildArgsForConfig

cmd/cloudflared/linux_service.go:245–279  ·  view source on GitHub ↗
(c *cli.Context, log *zerolog.Logger)

Source from the content-addressed store, hash-verified

243}
244
245func 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:
262tunnel: TUNNEL-UUID
263credentials-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
281func installSystemd(templateArgs *ServiceTemplateArgs, autoUpdate bool, log *zerolog.Logger) error {
282 var systemdTemplates []ServiceTemplate

Callers

nothing calls this directly

Calls 7

ReadConfigFileFunction · 0.92
FileExistsFunction · 0.92
ensureConfigDirExistsFunction · 0.85
copyFileFunction · 0.85
ErrorfMethod · 0.80
SourceMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected