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

Include configurable variables in imported packages to the schema #42908

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

Dilhasha
Copy link
Contributor

Purpose

Add support to configure configurable variables in imported packages to the schema

Fixes https://github.com/wso2-enterprise/internal-support-ballerina/issues/690

Approach

Extend existing implementation to get the configurable variables for the imports as well.

Samples

  • Create a ballerina package
  • Update the content in default module with the following.

main.bal

import ballerina/log;

configurable string itemCode = "item12393";

public function main() {
    log:printInfo("hello");
    log:printInfo("hello debug");
}

The generated config-schema.json

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "ballerina": {
      "type": "object",
      "properties": {
        "log": {
          "type": "object",
          "properties": {
            "format": {
              "type": "string",
              "description": ""
            },
            "level": {
              "type": "string",
              "description": ""
            },
            "modules": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "level": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "name",
                  "level"
                ],
                "name": "ballerina/log:2.9.0:Module"
              },
              "description": ""
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "dilhashanazeer": {
      "type": "object",
      "properties": {
        "simpleconfigs": {
          "type": "object",
          "properties": {
            "itemCode": {
              "type": "string",
              "description": ""
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}

Remarks

TODO:
Add test cases in the distribution repository - ballerina-platform/ballerina-distribution#5445

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

@Dilhasha Dilhasha force-pushed the configs-imported branch 2 times, most recently from 7d37bd2 to 76ea8ba Compare June 12, 2024 06:02
Copy link

codecov bot commented Jun 12, 2024

Codecov Report

Attention: Patch coverage is 79.01235% with 17 lines in your changes missing coverage. Please review.

Project coverage is 77.30%. Comparing base (6874aa0) to head (553bcc9).
Report is 24 commits behind head on master.

Files Patch % Lines
.../main/java/io/ballerina/projects/ConfigReader.java 79.22% 3 Missing and 13 partials ⚠️
...cts/internal/configschema/ConfigSchemaBuilder.java 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #42908   +/-   ##
=========================================
  Coverage     77.29%   77.30%           
- Complexity    51351    51353    +2     
=========================================
  Files          2932     2932           
  Lines        204511   204572   +61     
  Branches      26693    26706   +13     
=========================================
+ Hits         158081   158143   +62     
+ Misses        37838    37835    -3     
- Partials       8592     8594    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Dilhasha Dilhasha merged commit be10952 into ballerina-platform:master Jun 19, 2024
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants