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

scp: add option types #24240

Merged
merged 1 commit into from
Oct 15, 2024
Merged

Conversation

zackattackz
Copy link
Contributor

Prior to this commit, many scp functions existed without option structs, which would make extending functionality (adding new options) impossible without breaking changes, or without adding redundant wrapper functions.

This commit adds in new option types for various scp related functions, and changes those functions' signatures to use the new options.

This commit also modifies the ImageEngine.Scp() function's interface to use the new opts.

The commit also renames the existing ImageScpOptions entity type to ScpTransferImageOptions. This is because the previous ImageScpOptions was inaccurate, as it is not the actual options for ImageEngine.Scp(). ImageEngine.Scp() should instead receive ImageScpOptions.

This commit should not change any behavior, however it will break the existing functions' signatures.

--

Created this PR to replace #24234 to go ahead and make the breaking changes.

Worth noting: I selected the functions to change pretty arbitrarily. Just based on if I think they have a realistic chance of needing to change in order to add new features. I based it on my experience working on #24211 so it is at least grounded in some way. But I am open to feedback if more or fewer functions should be changed.

Does this PR introduce a user-facing change?

None

@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Oct 11, 2024
@@ -713,18 +713,22 @@ func ImageScp(w http.ResponseWriter, r *http.Request) {

sourceArg := utils.GetName(r)

rep, source, dest, _, err := domainUtils.ExecuteTransfer(sourceArg, query.Destination, []string{}, query.Quiet, ssh.GolangMode)
opts := entities.ScpExecuteTransferOptions{}
opts.ParentFlags = []string{}
Copy link
Member

Choose a reason for hiding this comment

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

Feels more natural to have ExecuteTransfer be tolerant of a nil here so callers don't have to explicitly set this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess it should already tolerate nil, since the only place ParentFlags is really used is here

Which should behave the same if it's nil vs an empty array.

I'll amend to remove the explicit setting you reference though since it should be fine without. Though there are no tests in place to confirm this, the tests for scp in general are pretty sparse.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The parent flags that are passed to ExecuteTransfer end up getting passed directly to Transfer for local transfers though, so I'll have to verify that would tolerate nil as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like it should be fine because parentFlags gets passed to transferRootless, which creates new arrays from them here

Then it's also used in transferRootful to similar effect here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While on that subject, would you think that those functions should get options structs as well?

Copy link
Member

Choose a reason for hiding this comment

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

The signatures don't seem all that bad, but they're certainly not clean either. Wouldn't call it a requirement but wouldn't say no either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just amended to change Transfer's signature because it's public and I could see the need for passing options for one reason or another. I left the other two the same though bc they're private and they could be changed as needed anyways.

Prior to this commit, many scp functions existed without option structs, which would make extending functionality (adding new options) impossible without breaking changes, or without adding redundant wrapper functions.

This commit adds in new option types for various scp related functions, and changes those functions' signatures to use the new options.

This commit also modifies the `ImageEngine.Scp()` function's interface to use the new opts.

The commit also renames the existing `ImageScpOptions` entity type to `ScpTransferImageOptions`. This is because the previous `ImageScpOptions` was inaccurate, as it is not the actual options for `ImageEngine.Scp()`. `ImageEngine.Scp()` should instead receive `ImageScpOptions`.

This commit should not change any behavior, however it will break the existing functions' signatures.

Signed-off-by: Zachary Hanham <[email protected]>
@mheon
Copy link
Member

mheon commented Oct 15, 2024

LGTM

@rhatdan
Copy link
Member

rhatdan commented Oct 15, 2024

/approve
/lgtm
Thanks @zackattackz

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 15, 2024
Copy link
Contributor

openshift-ci bot commented Oct 15, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhatdan, zackattackz

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 15, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit a38eaa5 into containers:main Oct 15, 2024
74 checks passed
@zackattackz
Copy link
Contributor Author

Thanks y'all 😄

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. kind/api-change Change to remote API; merits scrutiny lgtm Indicates that a PR is ready to be merged. release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants