Skip to content
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

Adds concept of kibanaVersion to plugin installer #8222

Merged
merged 2 commits into from
Sep 12, 2016

Conversation

BigFunger
Copy link
Contributor

@BigFunger BigFunger commented Sep 12, 2016

Closes #7343

The plugin installer checks the package.json file of the plugin in the archive. It compares the version property defined there against the version property defined in Kibana's package.json file.
If the two do not match down to the patch level, the plugin will not be installed. (ignoring everything after a hyphen in the comparison)

This PR keeps that functionality the same.

Now, however, the installer looks for a explicitly defined kibana.version property and uses that in the comparison if it exists. It falls back to the version property if kibana.version is not defined.

Example

{
  "version": "1.0.4"
}

will result in the plugin installer comparing 1.0.4 during the version check against the Kibana version.

{
  "version": "1.0.4",
  "kibana": {
    "version": "5.0.1"
  }
}

will result in the plugin installer comparing 5.0.1 during the version check against the Kibana version.

@cjcenizal
Copy link
Contributor

I'm working on some similar version-comparison logic, but the rules for satisfying the version requirements are slightly more complex. Because of that, I don't think it's worth reusing my code here, but I thought I should cross-link anyway in case you're interested: #8229

@epixa
Copy link
Contributor

epixa commented Sep 12, 2016

@cjcenizal Yeah, we draw a much harder line for plugin versions than we do with ES/Kibana since we don't necessarily control the code of the plugin itself, so we can't make assumptions about compatibility.

@@ -46,14 +46,14 @@ export async function rebuildCache(settings, logger) {
}

export function assertVersion(settings) {
if (!settings.plugins[0].version) {
if (!settings.plugins[0].kibanaVersion) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error can also be solved by adding a kibana.version property, right? We should probably update the Error to state something along these lines: "Plugin package.json is missing both a version property (required) and a kibana.version property (optional)."

@cjcenizal
Copy link
Contributor

This is looking good! I have a few comments:

  1. __tests__/kibana.js has a typo on line 62: It says "does" but it should say "doesn't".
  2. Same file, typo on line 75: it says "does does" (has an extra word).
  3. Maybe the versionSatisfies function should be renamed to versionsMatch to be more explicit. Without a clearer name, you have to open up that file and read its implementation to understand the requirements we're enforcing.

@BigFunger
Copy link
Contributor Author

I still think that versionSatisfies better describes the functionality than versionsMatch because it ignores all data after the hyphen... And will continue to describe it correctly as our comparison loosens in the future (to be Major/Minor) instead of (Major/Minor/Patch).

@BigFunger BigFunger force-pushed the plugin-installer-kibana-version branch from 99f2737 to 89db806 Compare September 12, 2016 20:45
@cjcenizal
Copy link
Contributor

LGTM!

@BigFunger BigFunger force-pushed the plugin-installer-kibana-version branch from 89db806 to 901fde5 Compare September 12, 2016 21:19
@@ -45,7 +45,7 @@ describe('kibana cli', function () {
tempArchiveFile: tempArchiveFilePath,
plugin: 'test-plugin',
version: '5.0.0-SNAPSHOT',
plugins: [ { name: 'foo', path: join(testWorkingPath, 'foo'), version: '5.0.0-SNAPSHOT' } ]
plugins: [ { name: 'foo', path: join(testWorkingPath, 'foo'), kibanaVersion: '5.0.0-SNAPSHOT' } ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the tests be checking both version and kibanaVersion? As in, one set for only kibanaVersion and another for version?

Copy link
Contributor Author

@BigFunger BigFunger Sep 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slightly confusing....

const settings = {
  workingPath: testWorkingPath,
  tempArchiveFile: tempArchiveFilePath,
  plugin: 'test-plugin',
  version: '5.0.0-SNAPSHOT',
  plugins: [ { name: 'foo', path: join(testWorkingPath, 'foo'), kibanaVersion: '5.0.0-SNAPSHOT' } ]
};

the version property here refers to Kibana's actual version as defined by kibana's package.json

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So apparently kibanaVersion is derived, and I should have spent more time digging into the changes here. So this is fine.

@w33ble w33ble self-assigned this Sep 12, 2016
@w33ble
Copy link
Contributor

w33ble commented Sep 12, 2016

Tested with x-plugins:

$ ./bin/kibana-plugin install file:../x-plugins/kibana/target/x-pack-6.0.0-alpha1.zip
Attempting to transfer from file:../x-plugins/kibana/target/x-pack-6.0.0-alpha1.zip
Transferring 68453372 bytes....................
Transfer complete
Retrieving metadata from plugin archive
Extracting plugin archive
Extraction complete
Optimizing and caching browser bundles...
Plugin installation complete

Then added a mismatched kibana.version to the package:

$ ./bin/kibana-plugin install file:../x-plugins/kibana/target/x-pack-6.0.0-alpha1.zip
Attempting to transfer from file:../x-plugins/kibana/target/x-pack-6.0.0-alpha1.zip
Transferring 68453385 bytes....................
Transfer complete
Retrieving metadata from plugin archive
Extracting plugin archive
Extraction complete
Plugin installation was unsuccessful due to error "Incorrect Kibana version in plugin [x-pack]. Expected [6.0.0]; found [7.0.0-failing-test]"

Functionality looks good.

// the version of kibana down to the patch level. If these two versions need
// to diverge, they can specify a kibana.version to indicate the version of
// kibana the plugin is intended to work with.
pkg.kibanaVersion = _.get(packageInfo, 'kibana.version');
Copy link
Contributor

@w33ble w33ble Sep 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use pkg.kibanaVersion = _.get(packageInfo, 'kibana.version', pkg.version); and get rid of the check below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sweet.

@w33ble
Copy link
Contributor

w33ble commented Sep 12, 2016

Small change, otherwise LGTM!

@BigFunger BigFunger force-pushed the plugin-installer-kibana-version branch from 901fde5 to 29f58a1 Compare September 12, 2016 22:35
@BigFunger BigFunger merged commit 90ad531 into elastic:master Sep 12, 2016
epixa pushed a commit that referenced this pull request Sep 12, 2016
@epixa
Copy link
Contributor

epixa commented Sep 12, 2016

Backported to 5.x and 5.0, though I forgot to amend the commit on 5.0 to link back up to this PR: a691874

@epixa epixa added the v5.0.0 label Oct 26, 2016
airow pushed a commit to airow/kibana that referenced this pull request Feb 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants