-
Notifications
You must be signed in to change notification settings - Fork 231
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
licensetool: embed license DB, update for more modules #3665
Conversation
ab6b674
to
6b8fd87
Compare
6b8fd87
to
406d91e
Compare
We now embed some licenses using go:embed, so we don't need to set up a modules DB in every project. A local modules folder is still checked first, and TODO files are still written locally to a local modules folder.
406d91e
to
000a6b1
Compare
Update a bunch of licenses from different places I've been running the licensetool.
000a6b1
to
c3bfa19
Compare
@@ -35,6 +36,9 @@ import ( | |||
"sigs.k8s.io/yaml" | |||
) | |||
|
|||
//go:embed modules/* | |||
var modulesFS embed.FS |
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.
interesting: eventually we can have it in its own Go package that will make this DB portable across all the tools :)
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.
I hope so :-)
if err != nil && os.IsNotExist(err) { | ||
b2, err2 := modulesFS.ReadFile(p) | ||
if err2 == nil { | ||
b = b2 |
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.
so this will ensure license info from the moduleFS gets written back to local FS.
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.
Yes, ish. The workflow I use is to run it against the binary. Then I search for license: TODO
go through and fill in any missing licenses that are generated. The link to the go package DB makes this easy, if a little tedious. Then I commit the files, and then yes the go:embed
ensures that (once merged) they are automatically embedded in as part of go build.
if err2 == nil { | ||
b = b2 | ||
err = err2 | ||
} |
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.
err2 != nil is being ignored and I believe that's intentional because err is what we care about in that case.
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.
Yes, it is deliberate (I think), but I think I'll take a second look and maybe log a V(4)
message to make the code at least more self-explanatory.
We now embed some licenses using
go:embed
, so we don't need to set up amodules
DB in every project. A local modules folder is still checked first, and TODO files are still written locally to a local modules folder.Also add a bunch more module license information from different places I've been running the tool.