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

Allow not providing values to selected configurable variables through CLI #42978

Merged
merged 11 commits into from
Jul 22, 2024

Conversation

ravinperera00
Copy link
Contributor

@ravinperera00 ravinperera00 commented Jun 25, 2024

Purpose

A bug in the CLI does not allow users to leave out values (by not providing values) for configurable variables that have an unsupported type and causes an error. This PR fixes that issue.
Additionally, the CLI does not support accepting values for configurable variables with a union type that has null as a member type (ex: int?). This PR adds that support.

Fixes #42859

Approach

Bug fix

When considering unsupported configurable values in the CLI, there could be two cases:

Case 1
A type that is not supported through the CLI is used as a configurable variable but the value is not provided through the CLI. This should not be a problem and the CLI should allow leaving the value for that out as long as a default values is provided through other methods.

Case 2
A type that is not supported through the CLI is used as a configurable variable but the value for that is provided through the CLI. This should cause and error stopping the program.

Checking whether the variable value is null before executing the checks regarding the type can produce the expected outcome.

Improvement

The Ballerina spec mentions the following regarding the supported types for configurable values.

Configurable values can be supplied with the built-in command-line option -C,

-Ckey=value

Key syntax:
key:= [[org .] module .] variable

Define S as:
type S boolean | int | float | decimal | string | xml

In the first phase, only the configurable variables with type S? are supported. We can support anydata[], map<anydata> and table<map<anydata>> later as needed.

Therefore types such as int? should be supported through the CLI. This can be achieved by accepting the () type as a valid member type within union types.

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

Fix a bug that didn't allow to enter values for configurable variables
through CLI when values for some variables are left empty.
Add an improvement that allows providing configurable values for types
such as int? through the CLI.
@HindujaB
Copy link
Contributor

Let's shorten the PR title as well. We can elaborate on it inside the description and approach.

@ravinperera00 ravinperera00 changed the title Allow not providing values to selected configurable variables through CLI and add support to union types that has null as a member type Allow not providing values to selected configurable variables through CLI Jun 25, 2024
Copy link

codecov bot commented Jun 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.44%. Comparing base (137e93d) to head (8380e37).
Report is 64 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #42978      +/-   ##
============================================
+ Coverage     77.34%   77.44%   +0.09%     
- Complexity    58253    58447     +194     
============================================
  Files          3450     3453       +3     
  Lines        218954   219927     +973     
  Branches      28741    28986     +245     
============================================
+ Hits         169356   170318     +962     
- Misses        40270    40292      +22     
+ Partials       9328     9317      -11     

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

@ravinperera00 ravinperera00 marked this pull request as ready for review June 28, 2024 02:02
Copy link
Contributor

@warunalakshitha warunalakshitha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@HindujaB HindujaB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@warunalakshitha warunalakshitha merged commit 240ef31 into ballerina-platform:master Jul 22, 2024
30 of 32 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
3 participants