-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: main
Are you sure you want to change the base?
Conversation
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.
There was a problem hiding this 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.", |
There was a problem hiding this comment.
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"} |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
🛠️ Description
hasLicense
function to dynamically load license terms from../LicenceTerms.json
.🔗 External Links
👍 Definition of Done
🤔 Can be merged upon approval?
✅