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

Use special "detached" index for manifest plugins #568

Merged
merged 3 commits into from
Mar 30, 2020

Conversation

chriskim06
Copy link
Member

Let me know if you want me to move this out to a package level variable, figured it would be ok like this since this situation is only encountered in this file.

Related issue: #483

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 29, 2020
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Mar 29, 2020
@chriskim06
Copy link
Member Author

/area multi-index

@ahmetb
Copy link
Member

ahmetb commented Mar 29, 2020

Let me know if you want me to move this out to a package level variable, figured it would be ok like this since this situation is only encountered in this file.

I think it’s fine.

@ahmetb
Copy link
Member

ahmetb commented Mar 29, 2020

Since we introduce a behavior, we should test.

Maybe add a test to integ tests of krewinstallmanifest ones loading receipt and checking source==detached.

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.

I prefer keeping such magic strings behind a constant. In this case, it doesn't hurt much, but as soon as we need to add a condition on "detached", we would inline another magic string. So let's extract it to constants.DetachedIndexName or similar.

@ahmetb
Copy link
Member

ahmetb commented Mar 29, 2020

So let's extract it to constants.DetachedIndexName or similar.

But technically we’re offering these libraries as part of our API. Would anyone build tooling/automation around this const? If not, better not expose?

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 30, 2020
@chriskim06
Copy link
Member Author

chriskim06 commented Mar 30, 2020

The integration test failed for some reason (worked locally), I think I vaguely remember seeing this in other PRs. I'll investigate further later tonight.

@ahmetb
Copy link
Member

ahmetb commented Mar 30, 2020

The integration test failed for some reason (worked locally), I think I vaguely remember seeing this in other PRs. I'll investigate further later tonight.

Seems like it was a flake (somehow), re-running the workflow worked. It happened at least once before. I'm suspecting GitHub's endpoint sending us an error response somehow. Need to look at download code to see if it's checking for non-200 codes.

@@ -216,3 +220,14 @@ func localTestServer() (string, func()) {
s := httptest.NewServer(http.FileServer(http.Dir("testdata")))
return s.URL, s.Close
}

func assertManifestPluginIndex(t *testing.T, test *ITest, plugin string) {
Copy link
Member

Choose a reason for hiding this comment

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

assertPluginFromIndex is a better name potentially?
also why is this not defined on test (like assertExecutableInPath)? that way you don't have to pass it t.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can add it there. I added this to just check "detached" and thought that would be a little too specific to install --manifest to add to testutil_test.go.

@@ -216,3 +220,14 @@ func localTestServer() (string, func()) {
s := httptest.NewServer(http.FileServer(http.Dir("testdata")))
return s.URL, s.Close
}

func assertManifestPluginIndex(t *testing.T, test *ITest, plugin string) {
receiptPath := test.TempDir().Path("receipts/" + plugin + constants.ManifestExtension)
Copy link
Member

Choose a reason for hiding this comment

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

don't guess filesystem layout; use environment.Paths (unless you're actually testing user-visible behavior, breaking behavior between versions, or Paths type).

@chriskim06
Copy link
Member Author

@corneliusweig @ahmetb let me know what you guys think about "detached". There's now a few usages of it in the integration test so would a good compromise be to make it a public const in the cmd package so that its not exposed but still available within the code? Although I think that might be a little strange seeing cmd.DetachedIndexName.

@ahmetb
Copy link
Member

ahmetb commented Mar 30, 2020

@chriskim06 nothing wrong with actually duplicating those in integration_test.

In fact, tests should rely on consts less and less. Because we want to test "behavior". If someone changes the value of the const, that should break the tests to notify us of behavior change, so please refrain from using the const in the tests.

@ahmetb
Copy link
Member

ahmetb commented Mar 30, 2020

/lgtm
/approve

Thanks!

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

[APPROVALNOTIFIER] This PR is APPROVED

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

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:

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 30, 2020
@k8s-ci-robot k8s-ci-robot merged commit e7104f2 into kubernetes-sigs:master Mar 30, 2020
@chriskim06 chriskim06 deleted the manifest-plugin-index branch June 11, 2020 15:05
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. area/multi-index 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/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants