Conversation
check.go
Outdated
| return false | ||
| } | ||
|
|
||
| func getSupportedLicenseNames() []string { |
There was a problem hiding this comment.
Curious, why do we need this list?
There was a problem hiding this comment.
I didn't find a method in github.com/google/licenseclassifier to get all defined license names.
It is used here to validate the input of flag allowed_license_names.
There was a problem hiding this comment.
Is there a strong need to do this validation? If there is a typo, the check command fails and reports the correct license name in error message.
An extraneous invalid license name seems not much harm either.
There was a problem hiding this comment.
You have a valid point! I removed the validation.
|
Thank you for the contribution! Let me start with high level questions. Can you clarify the use case for allowed licenses? That seems too flexible as interface, it's probably only useful when very limited license types are allowed. Would it be simpler asking someone with such flexible use case to directly parse the license CSV file and write custom validation? |
|
Currently, only the list of forbidden licenses, defined in Personally, I don't think it would be simpler to parse the report. |
|
To explain why I'm asking, this tool was built primarily for Google's own use-cases for open source go projects, so I am seeking a balance between maintenance cost vs use-case coverage. I'm asking to learn more about why this feature is useful to you. I think your use-case convinces me it may be useful to more people. Thank you for explaining that! |
|
Regarding the interface, do the following changes make it slightly simpler and more consistent?
Also, I think we should add validation and description that, the two flags cannot be used at the same time. |
|
I changed the interface. I did name it |
|
nit: update PR description? |
README.md
Outdated
| * See supported license names: [github.com/google/licenseclassifier](https://github.com/google/licenseclassifier/blob/e6a9bb99b5a6f71d5a34336b8245e305f5430f99/license_type.go#L28) | ||
|
|
||
|
|
||
| Typically, specify the Go package that builds your Go binary. |
There was a problem hiding this comment.
Can you move this paragraph above? It's more important than exlude options I feel.
There was a problem hiding this comment.
Added it to the top of the usage block as it is helpful for all comments.
check.go
Outdated
|
|
||
| func init() { | ||
| checkCmd.Flags().StringSliceVar(&allowedLicenses, "allowed_licenses", []string{}, "list of allowed license names, can't be used in combination with disallowed_types") | ||
| checkCmd.Flags().StringSliceVar(&disallowedTypes, "disallowed_types", []string{}, "list of disallowed license types, can't be used in combination with allowed_licenses") |
There was a problem hiding this comment.
Add comment about default behavior?
check.go
Outdated
| case "unencumbered": | ||
| excludedLicenseTypes = append(excludedLicenseTypes, licenses.Unencumbered) | ||
| default: | ||
| fmt.Fprintf(os.Stderr, "Unknown license type '%s' provided", v) |
There was a problem hiding this comment.
Also print the list of supported types?
| found = true | ||
| } | ||
|
|
||
| if hasLicenseType && isDisallowedLicenseType(licenseType, disallowedLicenseTypes) { |
There was a problem hiding this comment.
See previous unmerged PR for a reference of how to handle unknown types: #44
There was a problem hiding this comment.
Added support for unknown and added it to the default set.
Didn't implement different exit codes.
In the past, it stopped as soon as one forbidden license was found. In the meantime, it reports all forbidden licenses.
|
|
||
| ```shell | ||
| go-licenses check <package> [package...] | ||
| go-licenses check <package> [package...] |
There was a problem hiding this comment.
Also comment default behavior is disallow forbidden and unknown licenses?
There was a problem hiding this comment.
Added it to the title
|
hey thank you for this PR and hopefully this gets merged soon, b/c we need to maintain a fork of license checker and it causes trouble with replace directives and deprecated go get / go install behaviour. basically soft-forks of "go install"-ed things are no longer a supported use-case since a few go versions so I'd really appreciate it if this goes upstream |
Bobgy
left a comment
There was a problem hiding this comment.
Awesome 👍!
Thank you for the great contribution!
Allow to configure the check action.
Added flags:
Keeping the default behaviour of just checking the forbidden licenses.