Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Dynamic license terms #124

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kiruthi006
Copy link

🛠️ Description

  • Updated hasLicense function to dynamically load license terms from ../LicenceTerms.json.
  • Falls back to default terms if the file is missing or has invalid JSON.
  • Ensures no additional functions are introduced for simplicity and maintainability.

🔗 External Links

👍 Definition of Done

  • New functionality works?
  • Tests added?

🤔 Can be merged upon approval?

Make license detection configurable via LicenceTerms.json  

- Updated `hasLicense` function to dynamically load license terms from `../LicenceTerms.json`.  
- Falls back to default terms if the file is missing or has invalid JSON.  
- Ensures no additional functions are introduced for simplicity and maintainability.
 Updated `hasLicense` function to dynamically load license terms from `../LicenceTerms.json`.
Make license detection configurable via LicenceTerms.json  

- Updated `hasLicense` function to dynamically load license terms from `../LicenceTerms.json`.  
- Falls back to default terms if the file is missing or has invalid JSON.  
- Ensures no additional functions are introduced for simplicity and maintainability.
@kiruthi006 kiruthi006 requested a review from a team as a code owner March 13, 2025 12:28
Copy link

@sonamtenzin2 sonamtenzin2 left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this. Added some comments

@@ -0,0 +1,5 @@
[
"hashicorp, inc.",

Choose a reason for hiding this comment

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

Question: Why do we need hashicorp, inc. in this file now ?

Also "copyright" is missing in this list. Can you also move this file under addlicense directory ?

bytes.Contains(bytes.ToLower(b[:n]), []byte("spdx-license-identifier"))

// Default conditions
defaultTerms := []string{"hashicorp, inc.", "mozilla public", "spdx-license-identifier"}

Choose a reason for hiding this comment

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

Suggestion: We should now be iterating only on the list present in the json file

We can keep the default terms in the LicenseTerms.json

defaultTerms := []string{"hashicorp, inc.", "mozilla public", "spdx-license-identifier"}

// Load conditions from config file
configPath := "../LicenceCopywrite.json"

Choose a reason for hiding this comment

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

Suggestion: Having the file path hardcoded over here prevents users from adding any new licenses in the cli
Maybe we can have the file path as a parameter in the hcl config

// Load conditions from config file
configPath := "../LicenceCopywrite.json"
file, err := os.ReadFile(configPath)
if err == nil {

Choose a reason for hiding this comment

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

Suggestion: We should add the capability for this function to return errors

Instead of having the function silently failing and using default terms, we should let the user know that the Readfile function failed

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