-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Check license x-pack #11296
Merged
Merged
Check license x-pack #11296
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f21f88b
Check License for basic or better
ph 1ccea00
move licenser in libbeat
ph 333afa7
Update x-pack/libbeat/licenser/es_callback.go
tsg 8541a65
Run make fmt add a mutex.
ph a227633
lowercase
ph e630c54
reviews changes
ph 02bd7ca
handle 400 bad request and return OSS
ph 0993bd1
add a test for global connect
ph 2bfade9
fix message
ph 19751d4
typo
ph 4539541
adjust
ph e5c780f
make the test pass quickly than refactor
ph 15d3941
changelog
ph 5a83e27
typo
ph d65d8a3
ok for space in changelog..
ph 2ff3af8
attempting to connect
ph 29964a8
new wording
ph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package licenser | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/pkg/errors" | ||
|
||
"github.com/elastic/beats/libbeat/logp" | ||
"github.com/elastic/beats/libbeat/outputs/elasticsearch" | ||
) | ||
|
||
// Enforce setups the corresponding callbacks in libbeat to verify the license on the | ||
// remote elasticsearch cluster. | ||
func Enforce(log *logp.Logger, checks ...CheckFunc) { | ||
cb := func(client *elasticsearch.Client) error { | ||
fetcher := NewElasticFetcher(client) | ||
license, err := fetcher.Fetch() | ||
|
||
if err != nil { | ||
return errors.Wrapf(err, "cannot retrieve the elasticsearch license") | ||
} | ||
|
||
if license == OSSLicense { | ||
return errors.New("this Elastic licensed beat requires an Elasticsearch server with X-Pack " + | ||
"and a free basic license. Please use the Elasticsearch distribution that includes " + | ||
"X-Pack or download the Apache 2.0 licensed beat distribution that does not include " + | ||
"X-Pack features") | ||
} | ||
|
||
if !Validate(log, *license, checks...) { | ||
return fmt.Errorf( | ||
"invalid license found, requires a basic or a valid trial license and received %s", | ||
ph marked this conversation as resolved.
Show resolved
Hide resolved
|
||
license.Get(), | ||
) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
elasticsearch.RegisterGlobalCallback(cb) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@tsg, @andrewkroh I will do a followup on this, I didn't want to waste time on docker-compose environment variable and slow the merge. Since we need to add integration test for this new scenario we can fix it at the same time.