Skip to content

CLI to install a package#250

Merged
mtojek merged 13 commits intoelastic:masterfrom
mtojek:87-install-package
Feb 17, 2021
Merged

CLI to install a package#250
mtojek merged 13 commits intoelastic:masterfrom
mtojek:87-install-package

Conversation

@mtojek
Copy link
Copy Markdown
Contributor

@mtojek mtojek commented Feb 15, 2021

Fixes: #87
Fixes: #8

This PR exposes CLI action to install the current package (work dir), available in the Package Registry.

It introduces also the "check package conditions" feature to verify if the package meets Elastic stack conditions. It will be used by elastic/integrations#537 (comment) to check in advance whether the stack can expose the package.

How to test the PR:

  1. Go to the test/packages/kubernetes.
  2. elastic-package build
  3. elastic-package stack up -d (to include the package)
  4. elastic-package install (to install the package)

Check constraints (Kibana is not required to be up):

➜  apache git:(87-install-package) elastic-package install -c kibana.version=7.8.0 -v
2021/02/16 13:00:00 DEBUG Enable verbose logging
Check conditions for package
2021/02/16 13:00:00 DEBUG Verify Kibana version (constraint: ^7.9.0, requirement: 7.8.0)
Error: checking conditions failed: Kibana constraint unsatisfied: [0] 7.8.0 does not have same major version as 7.9.0
➜  apache git:(87-install-package) elastic-package install -c kibana.version=7.11.0 -v
2021/02/16 13:00:04 DEBUG Enable verbose logging
Check conditions for package
2021/02/16 13:00:04 DEBUG Verify Kibana version (constraint: ^7.9.0, requirement: 7.11.0)
2021/02/16 13:00:04 DEBUG Constraint kibana.version = ^7.9.0 is satisfied
Done

@mtojek mtojek self-assigned this Feb 15, 2021
@elasticmachine
Copy link
Copy Markdown
Collaborator

elasticmachine commented Feb 15, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #250 updated

  • Start Time: 2021-02-17T13:52:39.956+0000

  • Duration: 19 min 35 sec

  • Commit: 8a8f654

Test stats 🧪

Test Results
Failed 0
Passed 292
Skipped 1
Total 293

Trends 🧪

Image of Build Times

Image of Tests

@mtojek mtojek marked this pull request as ready for review February 15, 2021 16:37
@mtojek mtojek requested a review from ycombinator February 15, 2021 16:37
@mtojek mtojek marked this pull request as draft February 16, 2021 11:21
@mtojek mtojek marked this pull request as ready for review February 16, 2021 12:20
cmd/install.go Outdated
Long: installLongDescription,
RunE: installCommandAction,
}
cmd.Flags().BoolP(cobraext.UninstallPackageFlagName, "u", false, cobraext.UninstallPackageFlagDescription)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It feels a little odd (to me) that we use elastic-package install -u to uninstall a package. I think it would be clearer to create an elastic-package uninstall command instead. Even in terms of implementation this would be cleaner IMO — for example, it doesn't really make sense to check any compatibility conditions when uninstalling a package.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree with uninstall.

Regarding the compatibility conditions... I need this feature somewhere in elastic-package, so that I can implement the support matrix between packages and stacks (elastic/integrations#537 (comment)). I planned to use the tool to check if the CI should spawn the stack, because the package should be compatible.

If you have other ideas for the support check or a better place to put it, feel free to share them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No no, I think the compatibility check the way you have it implemented for elastic-package install is just fine. I was saying it is not needed for elastic-package uninstall, that's all.

Copy link
Copy Markdown
Contributor

@ycombinator ycombinator Feb 16, 2021

Choose a reason for hiding this comment

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

This might help clarify my suggestion: I would remove the -u option from this PR and make it just about installing a package. Then put up a separate PR that implements elastic-package uninstall (and in that PR I think we don't need the compatibility checks).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed uninstallation from this PR.

@mtojek mtojek requested a review from ycombinator February 17, 2021 13:52

// CheckConditions method compares the given values with conditions in manifest.
// The method is useful to check in advance if the package is compatible with particular stack version.
func CheckConditions(manifest PackageManifest, keyValuePairs []string) error {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I really like how generic this function is. I have been thinking of adding more conditions as part of elastic/package-registry#670 and I think something like what you have here will come in very handy!

Copy link
Copy Markdown
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

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

LGTM.

@mtojek mtojek merged commit 298797f into elastic:master Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[System test runner] Install package? Command: install the integration

3 participants