[TT-11217] Improve docs and linter
User description
Description
Improve config docs Reorder configs Improve schema linter test in linter passed
~/src/github.com/tykTechnologies/tyk/cli/linter (letz-imporve-config-docs*) » go test 1 ↵ yaaraletz@Yaaras-MacBook-Pro
PASS
ok github.com/TykTechnologies/tyk/cli/linter 0.343s
Related Issue
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality)
Checklist
- [ ] I ensured that the documentation is up to date
- [ ] I explained why this PR updates go.mod in detail with reasoning why it's required
- [ ] I would like a code coverage CI quality gate exception and have explained why
Type
enhancement, documentation
Description
- Updated linter tests to accommodate new valid values for
policy_source. - Enhanced and reorganized the
PoliciesConfigstructure inconfig.gofor better clarity and documentation. - Updated the JSON schema to include "file" as a valid option for
policy_source, aligning with the changes inconfig.go.
Changes walkthrough
| Relevant files | |||||
|---|---|---|---|---|---|
| Tests |
| ||||
| Enhancement |
|
✨ PR-Agent usage: Comment
/helpon the PR to get a list of all available PR-Agent tools and their descriptions
API Changes
--- prev.txt 2024-04-17 12:26:48.065857836 +0000
+++ current.txt 2024-04-17 12:26:44.989866344 +0000
@@ -5535,30 +5535,35 @@
functionalities
type PoliciesConfig struct {
- // Set this value to `file` to look in the file system for a definition file. Set to `service` to use the Dashboard service.
+ // Sets the location for the definitions of the policies. Optional vaules are `file`, `service` or `rpc`.
+ // `file` - to look in the file system of the gateway for a definition file. Used in OSS deployment only.
+ // `service` - to use Tyk Dashboard to get policy definitions. Used in Pro deployment only.
+ // `rpc` - to use MDCB service to get policy definitions. Used in Pro deployment only.
PolicySource string `json:"policy_source"`
- // This option is required if `policies.policy_source` is set to `service`.
- // Set this to the URL of your Tyk Dashboard installation. The URL needs to be formatted as: http://dashboard_host:port.
- PolicyConnectionString string `json:"policy_connection_string"`
+ // Tyk OSS deployment only
+ // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
+ // Tyk will load policies from all the JSON files located in the directory defined by `policies.policy_path`.
+ // With this configuration, policy management through the Gateway API is enabled in the Tyk Gateway.
+ PolicyPath string `json:"policy_path"`
- // This option only applies in OSS deployment when the `policies.policy_source` is either set
- // to `file` or an empty string. If `policies.policy_path` is not set, then Tyk will load policies
- // from the JSON file specified by `policies.policy_record_name`.
+ // Tyk OSS deployment only
+ // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
+ // If `policies.policy_path` is not set, then Tyk will load policies from the JSON file specified by `policy_record_name`.
+ // If `policy_record_name` is not set or is an empty string, the gateway will assume there are no policies to load and continues.
PolicyRecordName string `json:"policy_record_name"`
- // In a Pro installation, Tyk will load Policy IDs and use the internal object-ID as the ID of the policy.
+ // Tyk Pro deployment only.
+ // Required when `policies.policy_source` is set to `service`.
+ // Set this to the URL of your Tyk Dashboard installation. The URL needs to be formatted as: http://dashboard_host:port.
+ PolicyConnectionString string `json:"policy_connection_string"`
+
+ // Tyk Pro deployment only.
+ // Tyk will load Policy IDs and use the internal object-ID as the ID of the policy.
// This is not portable in cases where the data needs to be moved from installation to installation.
- //
- // If you set this value to `true`, then the id parameter in a stored policy (or imported policy using the Dashboard API), will be used instead of the internal ID.
- //
- // This option should only be used when moving an installation to a new database.
+ // If you set this value to `true`, then the id field in a stored policy (or imported policy using the Dashboard API), will be used instead of the internal ID.
+ // This option is useful only when moving an installation to a new database and you want to retain the same IDs.
AllowExplicitPolicyID bool `json:"allow_explicit_policy_id"`
- // This option only applies in OSS deployment when the `policies.policy_source` is either set
- // to `file` or an empty string. If `policies.policy_path` is set, then Tyk will load policies
- // from all the JSON files under the directory specified by the `policies.policy_path` option.
- // In this configuration, Tyk Gateway will allow policy management through the Gateway API.
- PolicyPath string `json:"policy_path"`
}
type PortRange struct {
PR Description updated to latest commit (https://github.com/TykTechnologies/tyk/commit/08e997c706b5a4448df3f40f6178b2a2b2db4c51)
:boom: CI tests failed :see_no_evil:
git-state
diff --git a/config/config.go b/config/config.go
index 6d9092b..9f878b3 100644
--- a/config/config.go
+++ b/config/config.go
@@ -76,13 +76,13 @@ type PoliciesConfig struct {
PolicySource string `json:"policy_source"`
// Tyk OSS deployment only
- // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
+ // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
// Tyk will load policies from all the JSON files located in the directory defined by `policies.policy_path`.
// With this configuration, policy management through the Gateway API is enabled in the Tyk Gateway.
PolicyPath string `json:"policy_path"`
// Tyk OSS deployment only
- // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
+ // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
// If `policies.policy_path` is not set, then Tyk will load policies from the JSON file specified by `policy_record_name`.
// If `policy_record_name` is not set or is an empty string, the gateway will assume there are no policies to load and continues.
PolicyRecordName string `json:"policy_record_name"`
Please look at the run or in the Checks tab.
Fixing PR: track the progress here.
I'm currently fixing this PR to address the following:
[Sweep GHA Fix] The GitHub Actions run failed on 08e997c (master) with the following error logs:
✨ Created Pull Request: https://github.com/TykTechnologies/tyk/pull/6020
PR Analysis
- 🎯 Main theme: Improving documentation and linter for configuration
- 📝 PR summary: This PR improves the documentation in the config.go file and updates the linter test and schema to reflect these changes. The changes mainly involve reordering and elaborating on the PoliciesConfig struct fields.
- 📌 Type of PR: Documentation
- 🧪 Relevant tests added: No
- ⏱️ Estimated effort to review [1-5]: 2, because the changes are mostly related to documentation and minor updates in the linter test and schema.
- 🔒 Security concerns: No security concerns found
PR Feedback
💡 General suggestions: The PR is well-structured and the changes are clearly explained in the documentation. However, it would be beneficial to add tests that validate the new linter rules and ensure that the updated documentation does not mislead the users.
🤖 Code feedback:
| relevant file | cli/linter/linter_test.go |
| suggestion | Consider adding more test cases to validate the new linter rules, especially for the 'file' option in 'policy_source'. [important]
|
| relevant line | policies.policy_source: policies.policy_source must be one of the following: "", "file", "service", "rpc", |
| relevant file | config/config.go |
| suggestion | It would be helpful to add more context or examples in the documentation for the 'policy_source' field to make it clear how each option ('file', 'service', 'rpc') affects the behavior of the application. [medium]
|
| relevant line | // Sets the location for the definitions of the policies. Optional vaules are file, service or rpc. |
✨ Usage guide:
Overview:
The review tool scans the PR code changes, and generates a PR review. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
With a configuration file, use the following template:
[pr_reviewer]
some_config1=...
some_config2=...
Utilizing extra instructionsThe Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify the relevant sub-tool, and the relevant aspects of the PR that you want to emphasize. Examples for extra instructions:
Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable. |
How to enable\disable automation
meaning the |
Auto-labelsThe
|
Extra sub-toolsThe |
More PR-Agent commands
|
See the review usage page for a comprehensive guide on using this tool.
PR Code Suggestions
| Suggestions | ||
|---|---|---|
| enhancement |
| |
| maintainability |
| |
| possible issue |
| |
| best practice |
| |
| documentation |
|
✨ Usage guide:
Overview:
The improve tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.
When commenting, to edit configurations related to the improve tool (pr_code_suggestions section), use the following template:
/improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
With a configuration file, use the following template:
[pr_code_suggestions]
some_config1=...
some_config2=...
Enabling\disabling automationWhen you first install the app, the default mode for the improve tool is:
meaning the |
Utilizing extra instructionsExtra instructions are very important for the Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify relevant aspects that you want the model to focus on. Examples for extra instructions:
Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable. |
A note on code suggestions quality
|
More PR-Agent commands
|
See the improve usage page for a more comprehensive guide on using this tool.
API tests result - postgres15-sha256 env: success :white_check_mark: Branch used: refs/pull/6019/merge Commit: 06d2dfc674d44eaf415ca41bd14b1350394c2ef3 Triggered by: pull_request (@letzya) Execution page
API tests result - mongo44-sha256 env: success :white_check_mark: Branch used: refs/pull/6019/merge Commit: 06d2dfc674d44eaf415ca41bd14b1350394c2ef3 Triggered by: pull_request (@letzya) Execution page
:boom: CI tests failed :see_no_evil:
git-state
diff --git a/config/config.go b/config/config.go
index fc9fd71..e16791b 100644
--- a/config/config.go
+++ b/config/config.go
@@ -76,13 +76,13 @@ type PoliciesConfig struct {
PolicySource string `json:"policy_source"`
// Tyk OSS deployment only
- // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
+ // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
// Tyk will load policies from all the JSON files located in the directory defined by `policies.policy_path`.
// With this configuration, policy management through the Gateway API is enabled in the Tyk Gateway.
PolicyPath string `json:"policy_path"`
// Tyk OSS deployment only
- // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
+ // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
// If `policies.policy_path` is not set, then Tyk will load policies from the JSON file specified by `policy_record_name`.
// If `policy_record_name` is not set or is an empty string, the gateway will assume there are no policies to load and continues.
PolicyRecordName string `json:"policy_record_name"`
Please look at the run or in the Checks tab.
:boom: CI tests failed :see_no_evil:
git-state
diff --git a/config/config.go b/config/config.go
index fc9fd71..e16791b 100644
--- a/config/config.go
+++ b/config/config.go
@@ -76,13 +76,13 @@ type PoliciesConfig struct {
PolicySource string `json:"policy_source"`
// Tyk OSS deployment only
- // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
+ // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
// Tyk will load policies from all the JSON files located in the directory defined by `policies.policy_path`.
// With this configuration, policy management through the Gateway API is enabled in the Tyk Gateway.
PolicyPath string `json:"policy_path"`
// Tyk OSS deployment only
- // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
+ // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
// If `policies.policy_path` is not set, then Tyk will load policies from the JSON file specified by `policy_record_name`.
// If `policy_record_name` is not set or is an empty string, the gateway will assume there are no policies to load and continues.
PolicyRecordName string `json:"policy_record_name"`
Please look at the run or in the Checks tab.
:boom: CI tests failed :see_no_evil:
git-state
diff --git a/config/config.go b/config/config.go
index fc9fd71..e16791b 100644
--- a/config/config.go
+++ b/config/config.go
@@ -76,13 +76,13 @@ type PoliciesConfig struct {
PolicySource string `json:"policy_source"`
// Tyk OSS deployment only
- // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
+ // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
// Tyk will load policies from all the JSON files located in the directory defined by `policies.policy_path`.
// With this configuration, policy management through the Gateway API is enabled in the Tyk Gateway.
PolicyPath string `json:"policy_path"`
// Tyk OSS deployment only
- // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
+ // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
// If `policies.policy_path` is not set, then Tyk will load policies from the JSON file specified by `policy_record_name`.
// If `policy_record_name` is not set or is an empty string, the gateway will assume there are no policies to load and continues.
PolicyRecordName string `json:"policy_record_name"`
Please look at the run or in the Checks tab.
/describe
@letzya Sorry, but I do not understand!
@letzya Sorry, but I do not understand!
PR Description updated to latest commit (https://github.com/TykTechnologies/tyk/commit/a9d1b716cd4bf8c079289c84bc5f45e2cfbef02a)
PR Description updated to latest commit (https://github.com/TykTechnologies/tyk/commit/a9d1b716cd4bf8c079289c84bc5f45e2cfbef02a)
:boom: CI tests failed :see_no_evil:
git-state
diff --git a/config/config.go b/config/config.go
index f7e0ac3..a763570 100644
--- a/config/config.go
+++ b/config/config.go
@@ -79,13 +79,13 @@ type PoliciesConfig struct {
PolicySource string `json:"policy_source"`
// Tyk OSS deployment only
- // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
+ // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
// Tyk will load policies from all the JSON files located in the directory defined by `policies.policy_path`.
// With this configuration, policy management through the Gateway API is enabled in the Tyk Gateway.
PolicyPath string `json:"policy_path"`
// Tyk OSS deployment only
- // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
+ // Used with OSS when `policies.policy_source` is either set to `file` (or an empty string).
// If `policies.policy_path` is not set, then Tyk will load policies from the JSON file specified by `policy_record_name`.
// If `policy_record_name` is not set or is an empty string, the gateway will assume there are no policies to load and continues.
PolicyRecordName string `json:"policy_record_name"`
Please look at the run or in the Checks tab.
@titpetric could you please review