MCPcopy Create free account
hub / github.com/containerd/nerdctl / copyAction

Function copyAction

cmd/nerdctl/compose/compose_cp.go:48–105  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

46}
47
48func copyAction(cmd *cobra.Command, args []string) error {
49 globalOptions, err := helpers.ProcessRootCmdFlags(cmd)
50 if err != nil {
51 return err
52 }
53 source := args[0]
54 if source == "" {
55 return errors.New("source can not be empty")
56 }
57 destination := args[1]
58 if destination == "" {
59 return errors.New("destination can not be empty")
60 }
61
62 dryRun, err := cmd.Flags().GetBool("dry-run")
63 if err != nil {
64 return err
65 }
66 followLink, err := cmd.Flags().GetBool("follow-link")
67 if err != nil {
68 return err
69 }
70 index, err := cmd.Flags().GetInt("index")
71 if err != nil {
72 return err
73 }
74
75 // rootless cp runs in the host namespaces, so the address is different
76 if rootlessutil.IsRootless() {
77 globalOptions.Address, err = rootlessutil.RootlessContainredSockAddress()
78 if err != nil {
79 return err
80 }
81 }
82 client, ctx, cancel, err := clientutil.NewClient(cmd.Context(), globalOptions.Namespace, globalOptions.Address)
83 if err != nil {
84 return err
85 }
86 defer cancel()
87 options, err := getComposeOptions(cmd, globalOptions.DebugFull, globalOptions.Experimental)
88 if err != nil {
89 return err
90 }
91 c, err := compose.New(client, globalOptions, options, cmd.OutOrStdout(), cmd.ErrOrStderr())
92 if err != nil {
93 return err
94 }
95
96 co := composer.CopyOptions{
97 Source: source,
98 Destination: destination,
99 Index: index,
100 FollowLink: followLink,
101 DryRun: dryRun,
102 }
103 return c.Copy(ctx, co)
104
105}

Callers

nothing calls this directly

Calls 7

ProcessRootCmdFlagsFunction · 0.92
IsRootlessFunction · 0.92
NewClientFunction · 0.92
NewFunction · 0.92
getComposeOptionsFunction · 0.85
CopyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…