(cmd *cobra.Command, args []string)
| 82 | } |
| 83 | |
| 84 | func copyOptions(cmd *cobra.Command, args []string) (types.ContainerCpOptions, error) { |
| 85 | globalOptions, err := helpers.ProcessRootCmdFlags(cmd) |
| 86 | if err != nil { |
| 87 | return types.ContainerCpOptions{}, err |
| 88 | } |
| 89 | flagL, err := cmd.Flags().GetBool("follow-link") |
| 90 | if err != nil { |
| 91 | return types.ContainerCpOptions{}, err |
| 92 | } |
| 93 | |
| 94 | srcSpec, err := parseCpFileSpec(args[0]) |
| 95 | if err != nil { |
| 96 | return types.ContainerCpOptions{}, err |
| 97 | } |
| 98 | |
| 99 | destSpec, err := parseCpFileSpec(args[1]) |
| 100 | if err != nil { |
| 101 | return types.ContainerCpOptions{}, err |
| 102 | } |
| 103 | |
| 104 | if (srcSpec.Container != nil && destSpec.Container != nil) || (len(srcSpec.Path) == 0 && len(destSpec.Path) == 0) { |
| 105 | return types.ContainerCpOptions{}, fmt.Errorf("one of src or dest must be a local file specification") |
| 106 | } |
| 107 | if srcSpec.Container == nil && destSpec.Container == nil { |
| 108 | return types.ContainerCpOptions{}, fmt.Errorf("one of src or dest must be a container file specification") |
| 109 | } |
| 110 | |
| 111 | container2host := srcSpec.Container != nil |
| 112 | var containerReq string |
| 113 | if container2host { |
| 114 | containerReq = *srcSpec.Container |
| 115 | } else { |
| 116 | containerReq = *destSpec.Container |
| 117 | } |
| 118 | return types.ContainerCpOptions{ |
| 119 | GOptions: globalOptions, |
| 120 | Container2Host: container2host, |
| 121 | ContainerReq: containerReq, |
| 122 | DestPath: destSpec.Path, |
| 123 | SrcPath: srcSpec.Path, |
| 124 | FollowSymLink: flagL, |
| 125 | FromStdin: srcSpec.Path == "-", |
| 126 | ToStdout: destSpec.Path == "-", |
| 127 | }, nil |
| 128 | } |
| 129 | |
| 130 | func AddCpCommand(rootCmd *cobra.Command) { |
| 131 | rootCmd.AddCommand(copyCommand()) |
no test coverage detected
searching dependent graphs…