本文整理汇总了Golang中github.com/pachyderm/pachyderm/src/pfs/pfsutil.InspectFile函数的典型用法代码示例。如果您正苦于以下问题:Golang InspectFile函数的具体用法?Golang InspectFile怎么用?Golang InspectFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InspectFile函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Lookup
func (d *directory) Lookup(ctx context.Context, name string) (fs.Node, error) {
if d.commitID == "" {
commitInfo, err := pfsutil.InspectCommit(
d.fs.apiClient,
d.fs.repositoryName,
name,
)
if err != nil {
return nil, err
}
if commitInfo == nil {
return nil, fuse.ENOENT
}
return &directory{
d.fs,
name,
commitInfo.CommitType == pfs.CommitType_COMMIT_TYPE_WRITE,
"",
},
nil
}
fileInfo, err := pfsutil.InspectFile(
d.fs.apiClient,
d.fs.repositoryName,
d.commitID,
path.Join(d.path, name),
)
if err != nil {
return nil, err
}
return d.nodeFromFileInfo(fileInfo)
}
示例2: lookUpFile
func (d *directory) lookUpFile(ctx context.Context, name string) (fs.Node, error) {
fileInfo, err := pfsutil.InspectFile(
d.fs.apiClient,
d.File.Commit.Repo.Name,
d.File.Commit.Id,
path.Join(d.File.Path, name),
d.fs.Shard,
)
if err != nil {
return nil, err
}
if fileInfo.FileType == pfs.FileType_FILE_TYPE_NONE {
return nil, fuse.ENOENT
}
directory := d.copy()
directory.File.Path = fileInfo.File.Path
switch fileInfo.FileType {
case pfs.FileType_FILE_TYPE_REGULAR:
directory.File.Path = fileInfo.File.Path
return &file{
*directory,
0,
int64(fileInfo.SizeBytes),
}, nil
case pfs.FileType_FILE_TYPE_DIR:
return directory, nil
default:
return nil, fmt.Errorf("Unrecognized FileType.")
}
}
示例3: Attr
func (f *file) Attr(ctx context.Context, a *fuse.Attr) error {
fileInfo, err := pfsutil.InspectFile(
f.fs.apiClient,
f.fs.repositoryName,
f.commitID,
f.path,
)
if err != nil {
return err
}
if fileInfo != nil {
a.Size = fileInfo.SizeBytes
}
a.Mode = 0666
return nil
}
示例4: Attr
func (f *file) Attr(ctx context.Context, a *fuse.Attr) (retErr error) {
defer func() {
protolog.Info(&FileAttr{&f.Node, &Attr{uint32(a.Mode)}, errorToString(retErr)})
}()
fileInfo, err := pfsutil.InspectFile(
f.fs.apiClient,
f.RepoName,
f.CommitID,
f.Path,
)
if err != nil {
return err
}
if fileInfo != nil {
a.Size = fileInfo.SizeBytes
}
a.Mode = 0666
return nil
}
示例5: Attr
func (f *file) Attr(ctx context.Context, a *fuse.Attr) (retErr error) {
defer func() {
protolog.Debug(&FileAttr{&f.Node, &Attr{uint32(a.Mode)}, errorToString(retErr)})
}()
fileInfo, err := pfsutil.InspectFile(
f.fs.apiClient,
f.File.Commit.Repo.Name,
f.File.Commit.Id,
f.File.Path,
f.fs.Shard,
)
if err != nil && !f.local {
return err
}
if fileInfo != nil {
a.Size = fileInfo.SizeBytes
}
a.Mode = 0666
a.Inode = f.fs.inode(f.File)
return nil
}
示例6: Cmds
//.........这里部分代码省略.........
apiClient, err := getAPIClient(address)
if err != nil {
return err
}
_, err = pfsutil.PutFile(apiClient, args[0], args[1], args[2], 0, os.Stdin)
return err
}),
}
getFile := &cobra.Command{
Use: "get-file repo-name commit-id path/to/file",
Short: "Return the contents of a file.",
Long: "Return the contents of a file.",
Run: pkgcobra.RunFixedArgs(3, func(args []string) error {
apiClient, err := getAPIClient(address)
if err != nil {
return err
}
return pfsutil.GetFile(apiClient, args[0], args[1], args[2], 0, math.MaxInt64, shard(), os.Stdout)
}),
}
getFile.Flags().IntVarP(&number, "shard", "s", 0, "shard to read from")
getFile.Flags().IntVarP(&modulus, "modulus", "m", 1, "modulus of the shards")
inspectFile := &cobra.Command{
Use: "inspect-file repo-name commit-id path/to/file",
Short: "Return info about a file.",
Long: "Return info about a file.",
Run: pkgcobra.RunFixedArgs(3, func(args []string) error {
apiClient, err := getAPIClient(address)
if err != nil {
return err
}
fileInfo, err := pfsutil.InspectFile(apiClient, args[0], args[1], args[2], shard())
if err != nil {
return err
}
if fileInfo == nil {
return fmt.Errorf("file %s not found", args[2])
}
writer := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
pretty.PrintFileInfoHeader(writer)
pretty.PrintFileInfo(writer, fileInfo)
return writer.Flush()
}),
}
inspectFile.Flags().IntVarP(&number, "shard", "s", 0, "shard to read from")
inspectFile.Flags().IntVarP(&modulus, "modulus", "m", 1, "modulus of the shards")
listFile := &cobra.Command{
Use: "list-file repo-name commit-id path/to/dir",
Short: "Return the files in a directory.",
Long: "Return the files in a directory.",
Run: pkgcobra.RunBoundedArgs(pkgcobra.Bounds{Min: 2, Max: 3}, func(args []string) error {
apiClient, err := getAPIClient(address)
if err != nil {
return err
}
var path string
if len(args) == 3 {
path = args[2]
}
fileInfos, err := pfsutil.ListFile(apiClient, args[0], args[1], path, shard())
if err != nil {
return err
}
示例7: do
//.........这里部分代码省略.........
NumArgs: 3,
Run: func(cmd *cobra.Command, args []string) error {
return pfsutil.MakeDirectory(apiClient, args[0], args[1], args[2])
},
}.ToCobraCommand()
putFile := cobramainutil.Command{
Use: "put-file repo-name commit-id path/to/file",
Short: "Put a file from stdin",
Long: "Put a file from stdin. Directories must exist. commit-id must be a writeable commit.",
NumArgs: 3,
Run: func(cmd *cobra.Command, args []string) error {
_, err := pfsutil.PutFile(apiClient, args[0], args[1], args[2], 0, os.Stdin)
return err
},
}.ToCobraCommand()
getFile := cobramainutil.Command{
Use: "get-file repo-name commit-id path/to/file",
Short: "Return the contents of a file.",
Long: "Return the contents of a file.",
NumArgs: 3,
Run: func(cmd *cobra.Command, args []string) error {
return pfsutil.GetFile(apiClient, args[0], args[1], args[2], 0, math.MaxInt64, os.Stdout)
},
}.ToCobraCommand()
inspectFile := cobramainutil.Command{
Use: "inspect-file repo-name commit-id path/to/file",
Short: "Return info about a file.",
Long: "Return info about a file.",
NumArgs: 3,
Run: func(cmd *cobra.Command, args []string) error {
fileInfo, err := pfsutil.InspectFile(apiClient, args[0], args[1], args[2])
if err != nil {
return err
}
if fileInfo == nil {
return fmt.Errorf("file %s not found", args[2])
}
writer := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
pretty.PrintFileInfoHeader(writer)
pretty.PrintFileInfo(writer, fileInfo)
return writer.Flush()
},
}.ToCobraCommand()
listFile := cobramainutil.Command{
Use: "list-file repo-name commit-id path/to/dir",
Short: "Return the files in a directory.",
Long: "Return the files in a directory.",
NumArgs: 3,
Run: func(cmd *cobra.Command, args []string) error {
fileInfos, err := pfsutil.ListFile(apiClient, args[0], args[1], args[2], uint64(shard), uint64(modulus))
if err != nil {
return err
}
writer := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
pretty.PrintFileInfoHeader(writer)
for _, fileInfo := range fileInfos {
pretty.PrintFileInfo(writer, fileInfo)
}
return writer.Flush()
},
}.ToCobraCommand()
listFile.Flags().IntVarP(&shard, "shard", "s", 0, "shard to read from")
示例8: Cmds
//.........这里部分代码省略.........
Run: pkgcobra.RunFixedArgs(3, func(args []string) error {
apiClient, err := getAPIClient(address)
if err != nil {
return err
}
_, err = pfsutil.PutFile(apiClient, args[0], args[1], args[2], 0, os.Stdin)
return err
}),
}
getFile := &cobra.Command{
Use: "get-file repo-name commit-id path/to/file",
Short: "Return the contents of a file.",
Long: "Return the contents of a file.",
Run: pkgcobra.RunFixedArgs(3, func(args []string) error {
apiClient, err := getAPIClient(address)
if err != nil {
return err
}
return pfsutil.GetFile(apiClient, args[0], args[1], args[2], 0, 0, "", shard(), os.Stdout)
}),
}
addShardFlags(getFile)
inspectFile := &cobra.Command{
Use: "inspect-file repo-name commit-id path/to/file",
Short: "Return info about a file.",
Long: "Return info about a file.",
Run: pkgcobra.RunFixedArgs(3, func(args []string) error {
apiClient, err := getAPIClient(address)
if err != nil {
return err
}
fileInfo, err := pfsutil.InspectFile(apiClient, args[0], args[1], args[2], "", shard())
if err != nil {
return err
}
if fileInfo == nil {
return fmt.Errorf("file %s not found", args[2])
}
writer := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
pretty.PrintFileInfoHeader(writer)
pretty.PrintFileInfo(writer, fileInfo)
return writer.Flush()
}),
}
addShardFlags(inspectFile)
listFile := &cobra.Command{
Use: "list-file repo-name commit-id path/to/dir",
Short: "Return the files in a directory.",
Long: "Return the files in a directory.",
Run: pkgcobra.RunBoundedArgs(pkgcobra.Bounds{Min: 2, Max: 3}, func(args []string) error {
apiClient, err := getAPIClient(address)
if err != nil {
return err
}
var path string
if len(args) == 3 {
path = args[2]
}
fileInfos, err := pfsutil.ListFile(apiClient, args[0], args[1], path, "", shard())
if err != nil {
return err
}
writer := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)