Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
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) } }, }
View Source
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) } }, } )
View Source
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) } }, }
View Source
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() }, }
View Source
var (
MainCmd = &cobra.Command{
Use: "continuity <command>",
Short: "A transport-agnostic filesytem metadata tool.",
}
)
View Source
var MountCmd = &cobra.Command{ Use: "mount <mountpoint> [<manifest>] [<source directory>]", Short: "Mount the manifest to the provided mountpoint using content from a source directory", Run: func(cmd *cobra.Command, args []string) { if len(args) != 3 { log.Fatal("Must specify mountpoint, manifest, and source directory") } mountpoint := args[0] manifest, source := args[1], args[2] manifestName := filepath.Base(manifest) p, err := ioutil.ReadFile(manifest) 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) } driver, err := continuity.NewSystemDriver() if err != nil { logrus.Fatal(err) } provider := continuityfs.NewFSFileContentProvider(source, driver) contfs, err := continuityfs.NewFSFromManifest(m, mountpoint, provider) if err != nil { logrus.Fatal(err) } c, err := fuse.Mount( mountpoint, fuse.ReadOnly(), fuse.FSName(manifestName), fuse.Subtype("continuity"), fuse.LocalVolume(), fuse.VolumeName("Continuity FileSystem"), ) if err != nil { logrus.Fatal(err) } <-c.Ready if err := c.MountError; err != nil { c.Close() logrus.Fatal(err) } errChan := make(chan error, 1) go func() { err = fs.Serve(c, contfs) if err != nil { errChan <- err } }() sigChan := make(chan os.Signal, 1) signal.Notify(sigChan, os.Interrupt) signal.Notify(sigChan, syscall.SIGTERM) select { case <-sigChan: logrus.Infof("Shutting down") case err = <-errChan: } go func() { if err := c.Close(); err != nil { logrus.Errorf("Unable to close connection %s", err) } }() time.Sleep(time.Second) logrus.Infof("Attempting unmount") if err := fuse.Unmount(mountpoint); err != nil { logrus.Errorf("Error unmounting %s: %v", mountpoint, err) } if err != nil { logrus.Fatalf("Error serving fuse server: %v", err) } }, }
View Source
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))) }, } )
View Source
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) } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.