This repository has been archived by the owner on Dec 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #550 from darkowlzz/cp
Add command ignite cp
- Loading branch information
Showing
54 changed files
with
7,276 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package cmd | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/weaveworks/ignite/cmd/ignite/cmd/vmcmd" | ||
) | ||
|
||
// NewCmdCP is an alias for vmcmd.NewCmdCP | ||
func NewCmdCP(out io.Writer) *cobra.Command { | ||
return vmcmd.NewCmdCP(out) | ||
} |
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,51 @@ | ||
package vmcmd | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/lithammer/dedent" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/pflag" | ||
"github.com/weaveworks/ignite/cmd/ignite/cmd/cmdutil" | ||
"github.com/weaveworks/ignite/cmd/ignite/run" | ||
) | ||
|
||
// NewCmdCP CP's a file into a running vm | ||
func NewCmdCP(out io.Writer) *cobra.Command { | ||
cf := &run.CPFlags{} | ||
|
||
cmd := &cobra.Command{ | ||
Use: "cp <source> <dest>", | ||
Short: "Copy files/folders between a running vm and the local filesystem", | ||
Long: dedent.Dedent(` | ||
Copy a file between host and a running VM. | ||
Creates an SFTP connection to the running VM using the private key created for | ||
it during generation, and transfers files between the host and VM. If no | ||
private key was created or wanting to use a different identity file, use the | ||
identity file flag (-i, --identity) to override the used identity file. | ||
Example usage: | ||
$ ignite cp localfile.txt my-vm:remotefile.txt | ||
$ ignite cp my-vm:remotefile.txt localfile.txt | ||
`), | ||
Args: cobra.ExactArgs(2), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
cmdutil.CheckErr(func() error { | ||
co, err := cf.NewCPOptions(args[0], args[1]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return run.CP(co) | ||
}()) | ||
}, | ||
} | ||
|
||
addCPFlags(cmd.Flags(), cf) | ||
return cmd | ||
} | ||
|
||
func addCPFlags(fs *pflag.FlagSet, cf *run.CPFlags) { | ||
fs.StringVarP(&cf.IdentityFile, "identity", "i", "", "Override the vm's default identity file") | ||
fs.Uint32VarP(&cf.Timeout, "timeout", "t", 10, "Timeout waiting for connection in seconds") | ||
} |
Oops, something went wrong.