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

Add User Definable Variable Substitution #675

Merged
merged 14 commits into from
Nov 8, 2024
Merged

Add User Definable Variable Substitution #675

merged 14 commits into from
Nov 8, 2024

Conversation

Gavinok
Copy link
Contributor

@Gavinok Gavinok commented Oct 30, 2024

This PR resolves #649

I have documented and added a user definable way to add new variable substitutions. A simple API for defining regex based variable matching. Here is a simple example usage.

def sub_days_plus_one(days: str) -> int:
    """Strings like '$sub_days_plus_one_4' will be replaced with the
    final number incremented by one. In this case 5.
    $sub_days_plus_one_4 -> 5
    $sub_days_plus_one_10 -> 11"""
    return int(days) + 1


variable_substitution_map.add_variable_substitution(
    r"\$sub_days_plus_one_(\d+)", sub_days_plus_one
)
variable_substitution_map["$sub_days_plus_one_1"] # -> 2

@Gavinok Gavinok requested review from esune and loneil and removed request for esune October 30, 2024 19:11
Copy link
Member

@esune esune left a comment

Choose a reason for hiding this comment

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

I do like how this is turning out. We need to add the override file bits to the Helm chart as well, maybe with a basic empty file definition that could be customized?

@loneil
Copy link
Contributor

loneil commented Oct 30, 2024

Think this works for me, good idea to have sample functions in there that would be in effect for a deployment. Yeah same question about what helm setup would be

@Gavinok
Copy link
Contributor Author

Gavinok commented Oct 31, 2024

I am going with Emilano's idea for now. I will setup the project with an empty python file that will be loaded allowing the users to extend it as they please

@Gavinok Gavinok requested a review from esune October 31, 2024 22:32
charts/vc-authn-oidc/templates/deployment.yaml Outdated Show resolved Hide resolved
docs/ConfigurationGuide.md Show resolved Hide resolved
Copy link
Member

@esune esune left a comment

Choose a reason for hiding this comment

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

I think this works, thanks @Gavinok

@loneil if you want to give it a review in case I missed anything I think we could merge after that.

@Gavinok Gavinok marked this pull request as draft November 5, 2024 22:41
@Gavinok Gavinok marked this pull request as ready for review November 5, 2024 22:44
Copy link
Contributor

@loneil loneil left a comment

Choose a reason for hiding this comment

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

I think this will work deployment-wise. Probably just put it through it's paces on a dev deploy and make sure

@esune esune merged commit 078e47e into main Nov 8, 2024
7 checks passed
@esune esune deleted the variable-substitution branch November 8, 2024 18:40
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.

Custom variable substitutions from external file
3 participants