-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scp: add option types + *WithOpts functions
Priot 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. It also adds relevant *WithOpts counterparts to existing functions, which use these new option types. This commit also adds in an experimental `ScpWithOpts` function to image engine implementations, which should eventually replace the existing `ImageEngine.Scp()` function. However, this replacement can't be done without breaking the `ImageEngine` interface, so it should happen at a later major version upgrade. The commit also renames the existing `ImageScpOptions` entity type to `ScpTransferImageOptions`, and adds an alias mapping the old to the new name to prevent breakage. This is because the previous `ImageScpOptions` was inaccurate, as it is not the actual options for `ImageEngine.Scp()`. The new name is more accurate. Also, if the signature of `ImageEngine.Scp()` is eventually changed to match `ScpWithOpts` as discussed above, `ImageScpBaseOptions` could then be more accurately renamed to `ImageScpOptions` This commit SHOULD NOT introduce any breaking changes. The breakages could be made in a later commit that would replace the existing functions with the *WithOpts counterparts. Signed-off-by: Zachary Hanham <z.hanham00@gmail.com>
- Loading branch information
1 parent
569d005
commit 65daca7
Showing
8 changed files
with
301 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package entities | ||
|
||
import ( | ||
"net/url" | ||
|
||
"github.com/containers/common/pkg/ssh" | ||
) | ||
|
||
// ScpTransferImageOptions provide options for securely copying images to and from a remote host | ||
type ScpTransferImageOptions struct { | ||
// Remote determines if this entity is operating on a remote machine | ||
Remote bool `json:"remote,omitempty"` | ||
// File is the input/output file for the save and load Operation | ||
File string `json:"file,omitempty"` | ||
// Quiet Determines if the save and load operation will be done quietly | ||
Quiet bool `json:"quiet,omitempty"` | ||
// Image is the image the user is providing to save and load | ||
Image string `json:"image,omitempty"` | ||
// User is used in conjunction with Transfer to determine if a valid user was given to save from/load into | ||
User string `json:"user,omitempty"` | ||
// Tag is the name to be used for the image on the destination | ||
Tag string `json:"tag,omitempty"` | ||
} | ||
|
||
// Deprecated: Use ScpTransferImageOptions | ||
type ImageScpOptions = ScpTransferImageOptions | ||
|
||
type ScpLoadReport = ImageLoadReport | ||
|
||
type ScpExecuteTransferOptions struct { | ||
// ParentFlags are the arguments to apply to the parent podman command when called via ssh | ||
ParentFlags []string | ||
// Quiet Determines if the save and load operation will be done quietly | ||
Quiet bool | ||
// SshMode is the specified ssh.EngineMode which should be used | ||
SshMode ssh.EngineMode | ||
} | ||
|
||
type ScpExecuteTransferReport struct { | ||
// LoadReport provides results from calling podman load | ||
LoadReport *ScpLoadReport | ||
// Source contains data relating to the source of the image to transfer | ||
Source *ScpTransferImageOptions | ||
// Dest contains data relating to the destination of the image to transfer | ||
Dest *ScpTransferImageOptions | ||
// ParentFlags are the arguments to apply to the parent podman command when called via ssh | ||
ParentFlags []string | ||
} | ||
|
||
type ScpLoadToRemoteOptions struct { | ||
// Dest contains data relating to the destination of the image to transfer | ||
Dest ScpTransferImageOptions | ||
// LocalFile is a path to a local file containing saved image data to transfer | ||
LocalFile string | ||
// Tag is the name of the tag to be given to the loaded image (unused) | ||
Tag string | ||
// Url points to the remote location for loading to | ||
Url *url.URL | ||
// Iden is a path to an optional identity file with ssh key | ||
Iden string | ||
// SshMode is the specified ssh.EngineMode which should be used | ||
SshMode ssh.EngineMode | ||
} | ||
|
||
type ScpLoadToRemoteReport struct { | ||
// Response contains any additional information from the executed load command | ||
Response string | ||
// Id is the identifier of the loaded image | ||
Id string | ||
} | ||
|
||
type ScpSaveToRemoteOptions struct { | ||
Image string | ||
// LocalFile is a path to a local file to copy the saved image to | ||
LocalFile string | ||
// Tag is the name of the tag to be given to the saved image (unused) | ||
Tag string | ||
// Url points to the remote location for saving from | ||
Url *url.URL | ||
// Iden is a path to an optional identity file with ssh key | ||
Iden string | ||
// SshMode is the specified ssh.EngineMode which should be used | ||
SshMode ssh.EngineMode | ||
} | ||
|
||
type ScpSaveToRemoteReport struct{} | ||
|
||
type ScpCreateCommandsOptions struct { | ||
// ParentFlags are the arguments to apply to the parent podman command when called via ssh | ||
ParentFlags []string | ||
// Podman is the path to the local podman executable | ||
Podman string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.