move rootfs, add gofmt
This commit is contained in:
parent
0f883d49e7
commit
273c337a23
5
BUILD
5
BUILD
@ -2,7 +2,10 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
|||||||
|
|
||||||
go_library(
|
go_library(
|
||||||
name = "undocker_lib",
|
name = "undocker_lib",
|
||||||
srcs = ["main.go"],
|
srcs = [
|
||||||
|
"main.go",
|
||||||
|
"rootfs.go",
|
||||||
|
],
|
||||||
importpath = "github.com/motiejus/code/undocker",
|
importpath = "github.com/motiejus/code/undocker",
|
||||||
visibility = ["//visibility:private"],
|
visibility = ["//visibility:private"],
|
||||||
deps = ["@com_github_jessevdk_go_flags//:go-flags"],
|
deps = ["@com_github_jessevdk_go_flags//:go-flags"],
|
||||||
|
28
main.go
28
main.go
@ -1,19 +1,20 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"errors"
|
|
||||||
|
|
||||||
goflags "github.com/jessevdk/go-flags"
|
goflags "github.com/jessevdk/go-flags"
|
||||||
)
|
)
|
||||||
|
|
||||||
type opts struct {
|
type (
|
||||||
PositionalArgs struct {
|
params struct {
|
||||||
Infile goflags.Filename `long:"infile" description:"Docker container tarball"`
|
RootFS cmdRootFS `command:"rootfs" description:"Unpack a docker container image to a single filesystem tarball"`
|
||||||
Outfile string `long:"outfile" description:"Output tarball"`
|
Manifest cmdManifest `command:"manifest"`
|
||||||
} `positional-args:"yes" required:"yes"`
|
}
|
||||||
}
|
|
||||||
|
cmdManifest struct{} // stub
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := run(os.Args); err != nil {
|
if err := run(os.Args); err != nil {
|
||||||
@ -23,17 +24,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func run(args []string) error {
|
func run(args []string) error {
|
||||||
var flags opts
|
var opts params
|
||||||
args1, err := goflags.ParseArgs(&flags, args)
|
if _, err := goflags.ParseArgs(&opts, args[1:]); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(args1) != 0 {
|
|
||||||
return errors.New("too many args")
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("infile: %s\n", flags.PositionalArgs.Infile)
|
|
||||||
fmt.Printf("outfile: %s\n", flags.PositionalArgs.Outfile)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
21
rootfs.go
Normal file
21
rootfs.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
goflags "github.com/jessevdk/go-flags"
|
||||||
|
)
|
||||||
|
|
||||||
|
type cmdRootFS struct {
|
||||||
|
PositionalArgs struct {
|
||||||
|
Infile goflags.Filename `long:"infile" description:"Input tarball"`
|
||||||
|
Outfile string `long:"outfile" description:"Output tarball (flattened file system)"`
|
||||||
|
} `positional-args:"yes" required:"yes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *cmdRootFS) Execute(args []string) error {
|
||||||
|
if len(args) != 0 {
|
||||||
|
return errors.New("too many args")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user