-
Notifications
You must be signed in to change notification settings - Fork 117
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
Include repository license in package when available #920
Include repository license in package when available #920
Conversation
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 know that some packages are using NOTICE.txt to carry license and Kibana shows that file. I don't know what's the difference between NOTICE.txt and LICENSE.txt, but maybe this is something we need to sort out too.
internal/builder/packages.go
Outdated
return errors.Wrap(err, "failure while looking for license in repository") | ||
} | ||
|
||
logger.Debugf("License text found in %q will be included in package", sourceLicensePath) |
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.
maybe info?
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.
Ok.
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.
This is the only thing logged now for packages in the integrations repo. Is this so relevant that requires higher logging level than other things? 🙂
$ elastic-package build --zip
Build the package
README.md file rendered: /home/jaime/gocode/src/github.com/elastic/integrations/packages/apache/docs/README.md
2022/08/02 16:00:17 INFO License text found in "/home/jaime/gocode/src/github.com/elastic/integrations/LICENSE.txt" will be included in package
Package built: /home/jaime/gocode/src/github.com/elastic/integrations/build/packages/apache-1.5.0.zip
Done
dir, err := findRepositoryRootDirectory() | ||
if errors.Is(err, os.ErrNotExist) { | ||
return "", errors.New("package can be only built inside of a Git repository (.git folder is used as reference point)") | ||
} |
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.
Does it change the implementation logic or is it just refactoring?
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.
Just refactoring, this is basically a copy of what there was in the loop looking for .git
.
@@ -157,6 +159,11 @@ func BuildPackage(options BuildOptions) (string, error) { | |||
return "", errors.Wrap(err, "copying package contents failed") | |||
} | |||
|
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.
Please leave logger.Debugf
here for consistency with other steps (clear target, encode dashboards, resolve fields).
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.
Here it does different things depending on the situation, so it will log two messages for the same thing, do we still want the log message here?
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.
Ok, message added, now it looks like this:
When copied from the repo:
2022/08/02 15:59:57 DEBUG Copy license file if needed
2022/08/02 15:59:57 INFO License text found in "/home/jaime/gocode/src/github.com/elastic/integrations/LICENSE.txt" will be included in package
When already available in the package:
2022/08/02 16:01:32 DEBUG Copy license file if needed
2022/08/02 16:01:32 DEBUG License file in the package will be used
internal/builder/packages.go
Outdated
func copyLicenseTextFile(licensePath string) error { | ||
_, err := os.Stat(licensePath) | ||
if err == nil { | ||
// License is already there, nothing to do. |
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.
Debug message?
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.
Even if it does nothing? 🙂
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.
Added.
@@ -233,7 +240,53 @@ func signZippedPackage(options BuildOptions, zippedPackagePath string) error { | |||
return nil | |||
} | |||
|
|||
func copyLicenseTextFile(licensePath string) error { |
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 guess that you don't check if the license content has changed?
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.
What do you mean? The file is copied as is (as any other file in the package).
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.
For example, the check
command fails if README.md is outdated due to changed fields.
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.
But this content in the README is generated and has to be kept on sync with the fields definitions. Nothing is generated in the license files, they are copied as they are, as other files in packages.
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.
Ok 👍
🌐 Coverage report
|
There was a discussion about this here: elastic/package-spec#298 (comment) |
If the package doesn't include a
LICENSE.txt
file, look for one in the repository, and include it if found.Implements elastic/package-spec#298 (comment).