1package main
2
3import (
4	"errors"
5	"fmt"
6	"os"
7	"path/filepath"
8
9	"github.com/Microsoft/hcsshim"
10	"github.com/urfave/cli"
11)
12
13// Add a manifest to get proper Windows version detection.
14//
15// goversioninfo can be installed with "go get github.com/josephspurrier/goversioninfo/cmd/goversioninfo"
16
17//go:generate goversioninfo -platform-specific
18
19var usage = `Windows Container layer utility
20
21wclayer is a command line tool for manipulating Windows Container
22storage layers. It can import and export layers from and to OCI format
23layer tar files, create new writable layers, and mount and unmount
24container images.`
25
26var driverInfo = hcsshim.DriverInfo{}
27
28func main() {
29	app := cli.NewApp()
30	app.Name = "wclayer"
31	app.Commands = []cli.Command{
32		createCommand,
33		exportCommand,
34		importCommand,
35		mountCommand,
36		removeCommand,
37		unmountCommand,
38	}
39	app.Usage = usage
40
41	if err := app.Run(os.Args); err != nil {
42		fmt.Fprintln(os.Stderr, err)
43		os.Exit(1)
44	}
45}
46
47func normalizeLayers(il []string, needOne bool) ([]string, error) {
48	if needOne && len(il) == 0 {
49		return nil, errors.New("at least one read-only layer must be specified")
50	}
51	ol := make([]string, len(il))
52	for i := range il {
53		var err error
54		ol[i], err = filepath.Abs(il[i])
55		if err != nil {
56			return nil, err
57		}
58	}
59	return ol, nil
60}
61