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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

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.34%. Comparing base (1a84008) to head (8380e37).
Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master   #42978   +/-   ##
=========================================
  Coverage     77.34%   77.34%           
- Complexity    58233    58236    +3     
=========================================
  Files          3450     3450           
  Lines        218919   218920    +1     
  Branches      28726    28726           
=========================================
+ Hits         169315   169316    +1     
  Misses        40281    40281           
  Partials       9323     9323           

☔ 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
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