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

chore: Add WithAcceptLicenseAgreement(bool) to container builder #1370

Conversation

HofmeisterAn
Copy link
Collaborator

@HofmeisterAn HofmeisterAn commented Feb 14, 2025

What does this PR do?

This PR introduces a new container builder method WithAcceptLicenseAgreement(bool), which provides a base implementation and makes it easier for developers to implement modules that require license agreements.

Basically, modules need to override the following and call ValidateLicenseAgreement() in their Build() method. I expect modules to override WithAcceptLicenseAgreement(bool) and include proper documentation that references the relevant license information.

protected override string AcceptLicenseAgreementEnvVar { get; } = "ACCEPT_EULA";

protected override string AcceptLicenseAgreement { get; } = "Y";

protected override string DeclineLicenseAgreement { get; } = "N";

public override ServiceBusBuilder WithAcceptLicenseAgreement(bool acceptLicenseAgreement)
{
    var licenseAgreement = acceptLicenseAgreement ? AcceptLicenseAgreement : DeclineLicenseAgreement;
    return WithEnvironment(AcceptLicenseAgreementEnvVar, licenseAgreement);
}

public override ServiceBusContainer Build()
{
    ValidateLicenseAgreement();
}

Why is it important?

Recent module PRs include more and more modules that require license agreements. Previously, the code to check license acceptance was always copied manually. This PR simplifies the implementation of license acceptance, reduces code duplication, and ensures a consistent pattern across all modules.

Related issues

-

@HofmeisterAn HofmeisterAn added the chore A change that doesn't impact the existing functionality, e.g. internal refactorings or cleanups label Feb 14, 2025
Copy link

netlify bot commented Feb 14, 2025

Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit 1f7915d
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-dotnet/deploys/67af8eb050ca9a0008f6d5ba
😎 Deploy Preview https://deploy-preview-1370--testcontainers-dotnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@HofmeisterAn HofmeisterAn merged commit fa65855 into develop Feb 14, 2025
113 checks passed
@HofmeisterAn HofmeisterAn deleted the feature/move-license-agreement-to-module-container-builder branch February 14, 2025 19:13
@0xced
Copy link
Contributor

0xced commented Feb 15, 2025

Should this be implemented in the MsSql module too?

Currently, ACCEPT_EULA=Y is hardcoded so it would be a breaking change.

.WithEnvironment("ACCEPT_EULA", "Y")

@HofmeisterAn
Copy link
Collaborator Author

HofmeisterAn commented Feb 15, 2025

@0xced Yes, I know the MSSQL module is still left. I did not change it because I am uncertain of the best way to transition to the new API without causing a breaking change (interfering with developers; ensuring that developers are aware of the change in advance).

@TheConstructor
Copy link

@HofmeisterAn how about toggeling an internal flag with the license-acceptance method and writing warnings on build, if the flag suggests, that the license was not explicitly accepted or declined. Of course thr plan to enforce explicit license acceptance should go into the changelog, too.

I don't see, that there is a 100% option, but this should reach most

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore A change that doesn't impact the existing functionality, e.g. internal refactorings or cleanups
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants