package commands
import "github.com/containerd/continuity/commands"
Index ¶
Variables ¶
var ApplyCmd = &cobra.Command{ Use: "apply <root> [<manifest>]", Short: "Apply the manifest to the provided root", Run: func(cmd *cobra.Command, args []string) { root, path := args[0], args[1] p, err := ioutil.ReadFile(path) if err != nil { log.Fatalf("error reading manifest: %v", err) } m, err := continuity.Unmarshal(p) if err != nil { log.Fatalf("error unmarshaling manifest: %v", err) } ctx, err := continuity.NewContext(root) if err != nil { log.Fatalf("error getting context: %v", err) } if err := continuity.ApplyManifest(ctx, m); err != nil { log.Fatalf("error applying manifest: %v", err) } }, }
var ( BuildCmd = &cobra.Command{ Use: "build <root>", Short: "Build a manifest for the provided root", Run: func(cmd *cobra.Command, args []string) { if len(args) != 1 { log.Fatalln("please specify a root") } ctx, err := continuity.NewContext(args[0]) if err != nil { log.Fatalf("error creating path context: %v", err) } m, err := continuity.BuildManifest(ctx) if err != nil { log.Fatalf("error generating manifest: %v", err) } p, err := continuity.Marshal(m) if err != nil { log.Fatalf("error marshaling manifest: %v", err) } if _, err := os.Stdout.Write(p); err != nil { log.Fatalf("error writing to stdout: %v", err) } }, } )
var DumpCmd = &cobra.Command{ Use: "dump <manifest>", Short: "Dump the contents of the manifest in protobuf text format", Run: func(cmd *cobra.Command, args []string) { var p []byte var err error if len(args) < 1 { p, err = ioutil.ReadAll(os.Stdin) if err != nil { log.Fatalf("error reading manifest: %v", err) } } else { p, err = ioutil.ReadFile(args[0]) if err != nil { log.Fatalf("error reading manifest: %v", err) } } var bm pb.Manifest if err := proto.Unmarshal(p, &bm); err != nil { log.Fatalf("error unmarshaling manifest: %v", err) } if err := proto.MarshalText(os.Stdout, &bm); err != nil { log.Fatalf("error dumping manifest: %v", err) } }, }
var LSCmd = &cobra.Command{ Use: "ls <manifest>", Short: "List the contents of the manifest.", Run: func(cmd *cobra.Command, args []string) { if len(args) != 1 { log.Fatalln("please specify a manifest") } bm, err := readManifestFile(args[0]) if err != nil { log.Fatalf("error reading manifest: %v", err) } w := tabwriter.NewWriter(os.Stdout, 0, 2, 2, ' ', 0) for _, entry := range bm.Resource { for _, path := range entry.Path { if os.FileMode(entry.Mode)&os.ModeSymlink != 0 { fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v -> %v\n", os.FileMode(entry.Mode), entry.User, entry.Group, humanize.Bytes(uint64(entry.Size)), path, entry.Target) } else { fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\n", os.FileMode(entry.Mode), entry.User, entry.Group, humanize.Bytes(uint64(entry.Size)), path) } } } w.Flush() }, }
var ( MainCmd = &cobra.Command{ Use: "continuity <command>", Short: "A transport-agnostic filesytem metadata tool.", } )
var ( StatsCmd = &cobra.Command{ Use: "stats <manifest>", Short: "display statistics about the specified manifest", Run: func(cmd *cobra.Command, args []string) { if len(args) != 1 { log.Fatalln("please specify a manifest") } bm, err := readManifestFile(args[0]) if err != nil { log.Fatalf("error reading manifest: %v", err) } var stats struct { resources int files int directories int totalSize int64 symlinks int } for _, entry := range bm.Resource { stats.resources++ stats.totalSize += int64(entry.Size) mode := os.FileMode(entry.Mode) if mode.IsRegular() { stats.files += len(entry.Path) } else if mode.IsDir() { stats.directories++ } else if mode&os.ModeSymlink != 0 { stats.symlinks++ } } w := newTabwriter(os.Stdout) defer w.Flush() fmt.Fprintf(w, "resources\t%v\n", stats.resources) fmt.Fprintf(w, "directories\t%v\n", stats.directories) fmt.Fprintf(w, "files\t%v\n", stats.files) fmt.Fprintf(w, "symlinks\t%v\n", stats.symlinks) fmt.Fprintf(w, "size\t%v\n", humanize.Bytes(uint64(stats.totalSize))) }, } )
var VerifyCmd = &cobra.Command{ Use: "verify <root> [<manifest>]", Short: "Verify the root against the provided manifest", Run: func(cmd *cobra.Command, args []string) { if len(args) != 2 { log.Fatalln("please specify a root and manifest") } root, path := args[0], args[1] p, err := ioutil.ReadFile(path) if err != nil { log.Fatalf("error reading manifest: %v", err) } m, err := continuity.Unmarshal(p) if err != nil { log.Fatalf("error unmarshaling manifest: %v", err) } ctx, err := continuity.NewContext(root) if err != nil { log.Fatalf("error getting context: %v", err) } if err := continuity.VerifyManifest(ctx, m); err != nil { log.Fatalf("error verifying manifest: %v", err) } }, }
Source Files ¶
apply.go build.go dump.go ls.go main.go stats.go verify.go
- Version
- v0.2.0
- Published
- Sep 14, 2021
- Platform
- js/wasm
- Imports
- 11 packages
- Last checked
- 12 hours ago –
Tools for package owners.