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

pkg/installation: cleanup refactoring #296

Merged
merged 1 commit into from
Jul 23, 2019

Conversation

ahmetb
Copy link
Member

@ahmetb ahmetb commented Jul 23, 2019

  • getDownloadTarget(): removed, it didn't do anything interesting.

  • downloadAndMove():

    • renamed to downloadAndExtract() which better reflects the functionality
    • reduced methods from 7 to 4
    • refactored the "move" operation out of this method (decouples "move"
      from "download+extract") and we now call "move" from install().
    • added unit tests (both for downloading a file, and --archive override)
  • introduced installOperation which contains the minimal information to
    perform installation operation.

  • introduced InstallOpts type to scale out (in the future)

  • install():

    • accepts fewer arguments (2) than before (8)
    • no longer knows about index.Plugin, or environment.Paths
  • cmd/install: removed a redundant check detecting specifying plugin names
    along with --manifest option.

Fixes #293
/kind cleanup
/assign @corneliusweig

@k8s-ci-robot k8s-ci-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Jul 23, 2019
@k8s-ci-robot k8s-ci-robot added 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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 23, 2019
- `getDownloadTarget()`: removed, it didn't do anything interesting.
- `downloadAndMove()`:
    - renamed to `downloadAndExtract()` which better reflects the functionality
    - reduced methods from 7 to 4
    - refactored the "move" operation out of this method (decouples "move"
      from "download+extract") and we now call "move" from install().
    - added unit tests (both for downloading a file, and --archive override)

- introduced `installOperation` which contains the minimal information to
  perform installation operation.

- introduced `InstallOpts` type to scale out (in the future)

- `install()`:
    - accepts fewer arguments (2) than before (8)
    - no longer knows about index.Plugin, or environment.Paths

- cmd/install: removed a redundant check detecting specifying plugin names
  along with --manifest option.

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

codecov-io commented Jul 23, 2019

Codecov Report

Merging #296 into master will decrease coverage by 1.17%.
The diff coverage is 11.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #296      +/-   ##
==========================================
- Coverage   56.22%   55.04%   -1.18%     
==========================================
  Files          19       19              
  Lines         891      901      +10     
==========================================
- Hits          501      496       -5     
- Misses        337      353      +16     
+ Partials       53       52       -1
Impacted Files Coverage Δ
pkg/installation/util.go 0% <ø> (-37.5%) ⬇️
pkg/installation/upgrade.go 0% <0%> (ø) ⬆️
pkg/installation/move.go 32.06% <0%> (-0.5%) ⬇️
pkg/installation/install.go 37.5% <21.05%> (+3.18%) ⬆️
pkg/installation/platform.go 79.16% <0%> (-12.5%) ⬇️

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 86a9199...d7cc487. 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.

Nice work. This is much cleaner now.

Finally install becomes somewhat testable. This could be one of the next steps. For that we just need to override downloadAndExtract or mock the http server as you already did.

return errors.Wrap(err, "failed while moving files to the installation directory")
}

subPathAbs, err := filepath.Abs(op.installDir)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you extract the whole sub-path checking logic to a separate function?

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we do that in another PR? 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

sure :)

@ahmetb
Copy link
Member Author

ahmetb commented Jul 23, 2019

Finally install becomes somewhat testable. This could be one of the next steps. For that we just need to override downloadAndExtract or mock the http server as you already did.

Yeah, I think install is becoming more approachable for testing.
Although I think we should also add tests for downloadAndExtract, and some other moveXxx methods. I'm less worried about install.

@corneliusweig
Copy link
Contributor

/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 23, 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

@k8s-ci-robot k8s-ci-robot merged commit 43b29c3 into kubernetes-sigs:master Jul 23, 2019
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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposed pkg/installation refactor
4 participants