You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/12/11 21:08:04 UTC

[GitHub] [airflow] SamWheating opened a new pull request #13025: Adding schema validation for config.yml

SamWheating opened a new pull request #13025:
URL: https://github.com/apache/airflow/pull/13025


   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of existing issue, reference it using one of the following:
   
   closes: https://github.com/apache/airflow/issues/12357
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   Re: https://github.com/apache/airflow/issues/12357
   
   Adding a schema for config.yml and a schema validation test to the pre-commit hook. I also had to fix up this file in a few spots where the schema validation exposed errors.
   
   Tested this by adding invalid data to config.yml and trying to commit. 
   
   ---
   
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] mik-laj commented on a change in pull request #13025: Adding schema validation for config.yml

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #13025:
URL: https://github.com/apache/airflow/pull/13025#discussion_r543645478



##########
File path: airflow/config_templates/config.yml.schema.json
##########
@@ -0,0 +1,61 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema#",
+  "type": "array",
+  "items": {
+    "type": "object",
+    "properties": {
+      "name": {
+        "type": "string"
+      },
+      "description": {
+        "type": ["string", "null"]
+      },
+      "options": {
+        "type": "array",
+        "items": {
+          "type": "object",
+          "properties": {
+            "name": {
+              "type": "string"
+            },
+            "description": {
+              "type": ["string", "null"]
+            },
+            "version_added": {
+              "type": ["string", "null"]
+            },
+            "type": {
+              "type": "string",
+              "enum": ["string", "boolean", "integer", "float"]
+            },
+            "example": {
+              "type": ["string", "null", "number"]
+            },
+            "default": {
+              "type": ["string", "null", "number"]
+            },
+            "sensitive": {
+              "type": "boolean",
+              "description": "'true' is this value is sensitive and can be specified using {section}___{name}__SECRET or {section}___{name}__CMD environment variables."

Review comment:
       ```suggestion
                 "description": "When true, this option is sensitive and can be specified using AIRFLOW__{section}___{name}__SECRET or AIRFLOW__{section}___{name}__CMD environment variables. See: airflow.configuration.AirflowConfigParser.sensitive_config_values"
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] mik-laj commented on pull request #13025: Adding schema validation for config.yml

Posted by GitBox <gi...@apache.org>.
mik-laj commented on pull request #13025:
URL: https://github.com/apache/airflow/pull/13025#issuecomment-745618674


   @ashb Would you like to add anything?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb commented on a change in pull request #13025: Adding schema validation for config.yml

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #13025:
URL: https://github.com/apache/airflow/pull/13025#discussion_r541312786



##########
File path: airflow/config_templates/config.yml.schema.json
##########
@@ -0,0 +1,57 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema#",
+  "type": "array",
+  "items": {
+    "type": "object",
+    "properties": {
+      "name": {
+        "type": "string"
+      },
+      "description": {
+        "type": ["string", "null"]
+      },
+      "options": {
+        "type": "array",
+        "items": {
+          "type": "object",
+          "properties": {
+            "name": {
+              "type": "string"
+            },
+            "description": {
+              "type": ["string", "null"]
+            },
+            "version_added": {
+              "type": ["string", "null"]
+            },
+            "type": {
+              "type": "string"
+            },
+            "example": {
+              "type": ["string", "null"]
+            },
+            "default": {
+              "type": ["string", "null"]
+            },
+            "sensitive": {
+              "type": "boolean"
+            }
+          },
+          "required": [
+            "name",
+            "description",
+            "version_added",
+            "type",
+            "example",
+            "default"
+          ]

Review comment:
       ```suggestion
             ],
             "additional_properties": false
   ```

##########
File path: airflow/config_templates/config.yml.schema.json
##########
@@ -0,0 +1,57 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema#",
+  "type": "array",
+  "items": {
+    "type": "object",
+    "properties": {
+      "name": {
+        "type": "string"
+      },
+      "description": {
+        "type": ["string", "null"]
+      },
+      "options": {
+        "type": "array",
+        "items": {
+          "type": "object",
+          "properties": {
+            "name": {
+              "type": "string"
+            },
+            "description": {
+              "type": ["string", "null"]
+            },
+            "version_added": {
+              "type": ["string", "null"]
+            },
+            "type": {
+              "type": "string"
+            },
+            "example": {
+              "type": ["string", "null"]
+            },
+            "default": {
+              "type": ["string", "null"]
+            },
+            "sensitive": {
+              "type": "boolean"
+            }
+          },
+          "required": [
+            "name",
+            "description",
+            "version_added",
+            "type",
+            "example",
+            "default"
+          ]
+        }
+      }
+    },
+    "required": [
+      "name",
+      "description",
+      "options"
+    ]

Review comment:
       ```suggestion
       ],
       "additional_properties": false
   ```

##########
File path: airflow/config_templates/config.yml.schema.json
##########
@@ -0,0 +1,57 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema#",
+  "type": "array",
+  "items": {
+    "type": "object",
+    "properties": {
+      "name": {
+        "type": "string"
+      },
+      "description": {
+        "type": ["string", "null"]
+      },
+      "options": {
+        "type": "array",
+        "items": {
+          "type": "object",
+          "properties": {
+            "name": {
+              "type": "string"
+            },
+            "description": {
+              "type": ["string", "null"]
+            },
+            "version_added": {
+              "type": ["string", "null"]
+            },
+            "type": {
+              "type": "string"
+            },
+            "example": {
+              "type": ["string", "null"]
+            },
+            "default": {
+              "type": ["string", "null"]

Review comment:
       This should allow numbers too I think

##########
File path: airflow/config_templates/config.yml.schema.json
##########
@@ -0,0 +1,57 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema#",
+  "type": "array",
+  "items": {
+    "type": "object",
+    "properties": {
+      "name": {
+        "type": "string"
+      },
+      "description": {
+        "type": ["string", "null"]
+      },
+      "options": {
+        "type": "array",
+        "items": {
+          "type": "object",
+          "properties": {
+            "name": {
+              "type": "string"
+            },
+            "description": {
+              "type": ["string", "null"]
+            },
+            "version_added": {
+              "type": ["string", "null"]
+            },
+            "type": {
+              "type": "string"

Review comment:
       Might be worth making this an enum type?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] SamWheating commented on a change in pull request #13025: Adding schema validation for config.yml

Posted by GitBox <gi...@apache.org>.
SamWheating commented on a change in pull request #13025:
URL: https://github.com/apache/airflow/pull/13025#discussion_r541335345



##########
File path: airflow/config_templates/config.yml.schema.json
##########
@@ -0,0 +1,57 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema#",
+  "type": "array",
+  "items": {
+    "type": "object",
+    "properties": {
+      "name": {
+        "type": "string"
+      },
+      "description": {
+        "type": ["string", "null"]
+      },
+      "options": {
+        "type": "array",
+        "items": {
+          "type": "object",
+          "properties": {
+            "name": {
+              "type": "string"
+            },
+            "description": {
+              "type": ["string", "null"]
+            },
+            "version_added": {
+              "type": ["string", "null"]
+            },
+            "type": {
+              "type": "string"
+            },
+            "example": {
+              "type": ["string", "null"]
+            },
+            "default": {
+              "type": ["string", "null"]

Review comment:
       Yeah you're right, I think `example` probably should as well.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] mik-laj commented on a change in pull request #13025: Adding schema validation for config.yml

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #13025:
URL: https://github.com/apache/airflow/pull/13025#discussion_r542045680



##########
File path: airflow/config_templates/config.yml.schema.json
##########
@@ -0,0 +1,60 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema#",
+  "type": "array",
+  "items": {
+    "type": "object",
+    "properties": {
+      "name": {
+        "type": "string"
+      },
+      "description": {
+        "type": ["string", "null"]
+      },
+      "options": {
+        "type": "array",
+        "items": {
+          "type": "object",
+          "properties": {
+            "name": {
+              "type": "string"
+            },
+            "description": {
+              "type": ["string", "null"]
+            },
+            "version_added": {
+              "type": ["string", "null"]
+            },
+            "type": {
+              "type": "string",
+              "enum": ["string", "boolean", "integer", "float"]
+            },
+            "example": {
+              "type": ["string", "null", "number"]
+            },
+            "default": {
+              "type": ["string", "null", "number"]
+            },
+            "sensitive": {

Review comment:
       Can you add description to this field?  It is not obvious when this field should be set.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] github-actions[bot] commented on pull request #13025: Adding schema validation for config.yml

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #13025:
URL: https://github.com/apache/airflow/pull/13025#issuecomment-745626886


   The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest master at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] mik-laj merged pull request #13025: Adding schema validation for config.yml

Posted by GitBox <gi...@apache.org>.
mik-laj merged pull request #13025:
URL: https://github.com/apache/airflow/pull/13025


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] mik-laj commented on a change in pull request #13025: Adding schema validation for config.yml

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #13025:
URL: https://github.com/apache/airflow/pull/13025#discussion_r543645478



##########
File path: airflow/config_templates/config.yml.schema.json
##########
@@ -0,0 +1,61 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema#",
+  "type": "array",
+  "items": {
+    "type": "object",
+    "properties": {
+      "name": {
+        "type": "string"
+      },
+      "description": {
+        "type": ["string", "null"]
+      },
+      "options": {
+        "type": "array",
+        "items": {
+          "type": "object",
+          "properties": {
+            "name": {
+              "type": "string"
+            },
+            "description": {
+              "type": ["string", "null"]
+            },
+            "version_added": {
+              "type": ["string", "null"]
+            },
+            "type": {
+              "type": "string",
+              "enum": ["string", "boolean", "integer", "float"]
+            },
+            "example": {
+              "type": ["string", "null", "number"]
+            },
+            "default": {
+              "type": ["string", "null", "number"]
+            },
+            "sensitive": {
+              "type": "boolean",
+              "description": "'true' is this value is sensitive and can be specified using {section}___{name}__SECRET or {section}___{name}__CMD environment variables."

Review comment:
       ```suggestion
                 "description": "When true, this option is sensitive and can be specified using AIRFLOW__{section}___{name}__SECRET or AIRFLOW__{section}___{name}__CMD environment variables."
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org