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

Update plugin listings to use install receipts #276

Merged
merged 2 commits into from
Jul 18, 2019

Conversation

ahmetb
Copy link
Member

@ahmetb ahmetb commented Jul 17, 2019

  • Changed the way we determine the list of "installed plugins" by looking at
    install receipts directory.
  • Added a receipt.Load() method for reading saved install receipts.

/assign @corneliusweig

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 17, 2019
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 17, 2019
- Changed the way we determine the list of "installed plugins" by looking at
  install receipts directory.
- Added a receipt.Load() method for reading saved install receipts.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
@codecov-io
Copy link

codecov-io commented Jul 18, 2019

Codecov Report

Merging #276 into master will increase coverage by 1.39%.
The diff coverage is 16.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #276      +/-   ##
==========================================
+ Coverage   53.94%   55.34%   +1.39%     
==========================================
  Files          18       19       +1     
  Lines         862      880      +18     
==========================================
+ Hits          465      487      +22     
+ Misses        341      337       -4     
  Partials       56       56
Impacted Files Coverage Δ
pkg/installation/util.go 48.88% <0%> (+3.99%) ⬆️
pkg/receipt/receipt.go 75% <100%> (+8.33%) ⬆️
pkg/installation/semver/version.go 100% <0%> (ø)
pkg/index/validate.go 95% <0%> (+0.26%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d8409b5...d670c16. Read the comment docs.

Copy link
Contributor

@corneliusweig corneliusweig left a comment

Choose a reason for hiding this comment

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

The code looks great, but I'm not completely happy with the tests.

plugins, err := ioutil.ReadDir(installDir)
// ListInstalledPlugins returns a list of all install plugins in a
// name:version format based on the install receipts at the specified dir.
func ListInstalledPlugins(receiptsDir string) (map[string]string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, that just got a lot simpler 👍
Would be a good time to also add some tests for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since adding tests to this requires me to Store() some manifests by serializing the in-memory Plugin objects (#270) to a tempdir, I will need #270 to happen first.

To unblock here, I'm adding a TODO to the code explaining this situation.

pkg/receipt/receipt.go Outdated Show resolved Hide resolved
@@ -68,3 +70,20 @@ func TestStore(t *testing.T) {
t.Fatal(diff)
}
}

func TestLoad(t *testing.T) {
p, err := Load(filepath.Join("..", "..", "integration_test", "testdata", "foo.yaml"))
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't feel right. Depending on test data in another package looks like headache in the future.
What about writing the plugin manifest to disk and read with Load? For that it could be helpful to have a testutil.ValidPluginManifest global value which can be used by other tests as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

What about writing the plugin manifest to disk and read with Load?

this is a good idea.

For that it could be helpful to have a testutil.ValidPluginManifest global value

this is mentioned in #270

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm let's keep it as is, I'll add a TODO here. I have two concerns:

  1. I don't want to do minor: duplicate test object cleanup #270 in this PR.
  2. Ideally I don't want Load()’s tests to fail because of a fault in Store(). But I think we can live with it.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
@corneliusweig
Copy link
Contributor

Looks great!
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 18, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahmetb, corneliusweig

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [ahmetb,corneliusweig]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants