TykTechnologies / tyk

Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols
Other
9.75k stars 1.09k forks source link

Add gateway edition to healthcheck response #6679

Open jeffy-mathew opened 3 weeks ago

jeffy-mathew commented 3 weeks ago

User description

Description

Related Issue

Motivation and Context

How This Has Been Tested

Screenshots (if appropriate)

Types of changes

Checklist


PR Type

enhancement


Description


PRDescriptionHeader.CHANGES_WALKTHROUGH

Relevant files
Enhancement
health_check.go
Add Edition field to HealthCheckResponse struct                   

apidef/health_check.go - Added `Edition` field to `HealthCheckResponse` struct.
+1/-0     
health_check.go
Include Edition information in health check response         

gateway/health_check.go
  • Imported edition package.
  • Set Edition field in HealthCheckResponse using edition.GetEdition().
  • +2/-0     
    edition_ce.go
    Define GetEdition function for Community edition                 

    internal/edition/edition_ce.go - Added `GetEdition` function returning "Community".
    +7/-0     
    edition_ee.go
    Define GetEdition function for Enterprise edition               

    internal/edition/edition_ee.go - Added `GetEdition` function returning "Enterprise".
    +7/-0     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    buger commented 3 weeks ago

    A JIRA Issue ID is missing from your branch name, PR title and PR description! 🦄

    Your branch: exp/add-edition-info-to-healthcheck

    Your PR title: Add gateway edition to healthcheck response

    Your PR description: ## Description ## 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

    If this is your first time contributing to this repository - welcome!


    Please refer to jira-lint to get started.

    Without the JIRA Issue ID in your branch name you would lose out on automatic updates to JIRA via SCM; some GitHub status checks might fail.

    Valid sample branch names: ‣ feature/shiny-new-feature--mojo-10' ‣ 'chore/changelogUpdate_mojo-123' ‣ 'bugfix/fix-some-strange-bug_GAL-2345'
    github-actions[bot] commented 3 weeks ago

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ No major issues detected
    github-actions[bot] commented 3 weeks ago

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Validate the Edition value to ensure it meets expected criteria before use ___ **Validate the Edition value retrieved from edition.GetEdition() to ensure it is not
    empty or unexpected before assigning it to the HealthCheckResponse.** [gateway/health_check.go [187]](https://github.com/TykTechnologies/tyk/pull/6679/files#diff-978a2d1427d9209765e541618af10683944c6396df1a6fb8b5221e4f16658a6aR187-R187) ```diff -Edition: edition.GetEdition(), +editionValue := edition.GetEdition() +if editionValue != "Community" && editionValue != "Enterprise" { + logrus.Error("Invalid edition value") + editionValue = "Unknown" +} +Edition: editionValue, ```
    Suggestion importance[1-10]: 9 Why: This suggestion addresses a potential bug by ensuring that the `Edition` value is validated before use, which is crucial for preventing unexpected behavior. It significantly enhances the robustness of the code.
    9
    github-actions[bot] commented 3 weeks ago

    API Changes

    --- prev.txt    2024-10-29 07:41:57.696286096 +0000
    +++ current.txt 2024-10-29 07:41:51.312279831 +0000
    @@ -1862,6 +1862,7 @@
        Output      string                     `json:"output,omitempty"`
        Description string                     `json:"description,omitempty"`
        Details     map[string]HealthCheckItem `json:"details,omitempty"`
    +   Edition     string                     `json:"edition,omitempty"`
     }
    
     type HealthCheckStatus string
    sonarcloud[bot] commented 3 weeks ago

    Quality Gate Failed Quality Gate failed

    Failed conditions
    0.0% Coverage on New Code (required ≥ 80%)

    See analysis details on SonarCloud