| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "errors" |
| 6 | "io" |
| 7 | |
| 8 | "github.com/sylvinus/agent-vm/internal/hostproxy" |
| 9 | ) |
| 10 | |
| 11 | |
| 12 | |
| 13 | func hostDownload(ctx context.Context, args []string, out io.Writer) error { |
| 14 | if len(args) != 3 && len(args) != 4 && len(args) != 6 { |
| 15 | return errors.New("host-download requires URL, staging path, component name and optional Accept, cache directory and SHA-256") |
| 16 | } |
| 17 | var accept, cache, digest string |
| 18 | if len(args) >= 4 { |
| 19 | accept = args[3] |
| 20 | } |
| 21 | if len(args) == 6 { |
| 22 | cache, digest = args[4], args[5] |
| 23 | } |
| 24 | return hostproxy.Download(ctx, args[0], args[1], args[2], accept, cache, digest, out) |
| 25 | } |