Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #550 from darkowlzz/cp
Browse files Browse the repository at this point in the history
Add command ignite cp
  • Loading branch information
stealthybox authored Apr 13, 2020
2 parents f5ba013 + fcb6b06 commit fd8cd29
Show file tree
Hide file tree
Showing 54 changed files with 7,276 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/ignite/cmd/cp.go
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)
}
1 change: 1 addition & 0 deletions cmd/ignite/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func NewIgniteCommand(in io.Reader, out, err io.Writer) *cobra.Command {

root.AddCommand(NewCmdAttach(os.Stdout))
root.AddCommand(NewCmdCompletion(os.Stdout, root))
root.AddCommand(NewCmdCP(os.Stdout))
root.AddCommand(NewCmdCreate(os.Stdout))
root.AddCommand(NewCmdKill(os.Stdout))
root.AddCommand(NewCmdLogs(os.Stdout))
Expand Down
51 changes: 51 additions & 0 deletions cmd/ignite/cmd/vmcmd/cp.go
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")
}
Loading

0 comments on commit fd8cd29

Please sign in to comment.