TUN-3522: ingress validate checks that the config file exists

This commit is contained in:
Adam Chalmers 2020-11-09 11:15:10 -06:00
parent 87e2679744
commit 64d3836645
1 changed files with 4 additions and 0 deletions

View File

@ -70,6 +70,10 @@ func buildTestURLCommand() *cli.Command {
// validateIngressCommand check the syntax of the ingress rules in the cloudflared config file // validateIngressCommand check the syntax of the ingress rules in the cloudflared config file
func validateIngressCommand(c *cli.Context) error { func validateIngressCommand(c *cli.Context) error {
conf := config.GetConfiguration() conf := config.GetConfiguration()
if conf.Source() == "" {
fmt.Println("No configuration file was found. Please create one, or use the --config flag to specify its filepath. You can use the help command to learn more about configuration files")
return nil
}
fmt.Println("Validating rules from", conf.Source()) fmt.Println("Validating rules from", conf.Source())
if _, err := ingress.ParseIngress(conf); err != nil { if _, err := ingress.ParseIngress(conf); err != nil {
return errors.Wrap(err, "Validation failed") return errors.Wrap(err, "Validation failed")