Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate configuration #387

Open
DoctorFTB opened this issue Dec 3, 2023 · 3 comments
Open

Validate configuration #387

DoctorFTB opened this issue Dec 3, 2023 · 3 comments
Labels
feature New feature or request

Comments

@DoctorFTB
Copy link

Is your feature request related to a problem? Please describe

I have a problem with configuration by validation

Describe the solution you'd like

If my configuration is invalid (based on the current handlers code), an error is thrown

Describe alternatives you've considered

Nope

Additional context

For example I have a config:

nginx_config_http_template_enable: true
nginx_config_http_template:
  - template_file: http/default.conf.j2
    deployment_location: /etc/nginx/conf.d/path-to.conf
    config:
      servers:
        - core:
            server_name1: some.example.com
            locations:
              - location: /
                proxy:
                  pass: http://127.0.0.1:8080

And in this case:
First mistake is that "server_name1" is not a valid name (cuz 1 at the end)
Second mistake is is the number of indents (need left for 2 spaces)
After applying this configuration I received an empty /etc/nginx/conf.d/path-to.conf file

@alessfg
Copy link
Collaborator

alessfg commented Dec 4, 2023

Hey @DoctorFTB -- there is indeed no parameter validation built into the role. I'll try to investigate the best way to do it as soon as I can.

Question, what do you mean with the second mistake? I am not entirely sure I can identify the issue.

@alessfg alessfg added enhancement Enhance an existing feature feature New feature or request and removed enhancement Enhance an existing feature labels Dec 4, 2023
@DoctorFTB
Copy link
Author

DoctorFTB commented Dec 4, 2023

Hey. Thanks. About question, check the screenshot, I added a blue line.
image
Key "locations" must be part of the "servers" element, not "core". I translate config into json:
Variant for bad config:

{
  "servers": [
    {
      "core": {
        "server_name1": "some.example.com",
        "locations": [ // <<<
          {
            "location": "/",
            "proxy": {
              "pass": "http://127.0.0.1:8080"
            }
          }
        ]
      }
    }
  ]
}

And variant for correct config:

{
  "servers": [
    {
      "core": {
        "server_name1": "some.example.com"
      },
      "locations": [ // <<<
        {
          "location": "/",
          "proxy": {
            "pass": "http://127.0.0.1:8080"
          }
        }
      ]
    }
  ]
}

@alessfg
Copy link
Collaborator

alessfg commented Dec 5, 2023

Ah, right, I see. Thanks for the extra info!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
Development

No branches or pull requests

2 participants