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(
|
||||
name = "undocker_lib",
|
||||
srcs = ["main.go"],
|
||||
srcs = [
|
||||
"main.go",
|
||||
"rootfs.go",
|
||||
],
|
||||
importpath = "github.com/motiejus/code/undocker",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = ["@com_github_jessevdk_go_flags//:go-flags"],
|
||||
|
28
main.go
28
main.go
@ -1,19 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"errors"
|
||||
|
||||
goflags "github.com/jessevdk/go-flags"
|
||||
)
|
||||
|
||||
type opts struct {
|
||||
PositionalArgs struct {
|
||||
Infile goflags.Filename `long:"infile" description:"Docker container tarball"`
|
||||
Outfile string `long:"outfile" description:"Output tarball"`
|
||||
} `positional-args:"yes" required:"yes"`
|
||||
}
|
||||
type (
|
||||
params struct {
|
||||
RootFS cmdRootFS `command:"rootfs" description:"Unpack a docker container image to a single filesystem tarball"`
|
||||
Manifest cmdManifest `command:"manifest"`
|
||||
}
|
||||
|
||||
cmdManifest struct{} // stub
|
||||
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := run(os.Args); err != nil {
|
||||
@ -23,17 +24,10 @@ func main() {
|
||||
}
|
||||
|
||||
func run(args []string) error {
|
||||
var flags opts
|
||||
args1, err := goflags.ParseArgs(&flags, args)
|
||||
if err != nil {
|
||||
var opts params
|
||||
if _, err := goflags.ParseArgs(&opts, args[1:]); err != nil {
|
||||
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
|
||||
}
|
||||
|
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