(args []string)
| 83 | } |
| 84 | |
| 85 | func (c *mountCmd) RunCommand(args []string) error { |
| 86 | err := c.checkFlags(args) |
| 87 | if err != nil { |
| 88 | return cmdmain.UsageError(fmt.Sprint(err)) |
| 89 | } |
| 90 | if !*noBuild { |
| 91 | if err := build(filepath.Join("cmd", "pk-mount")); err != nil { |
| 92 | return fmt.Errorf("Could not build pk-mount: %v", err) |
| 93 | } |
| 94 | } |
| 95 | c.env.SetCamdevVars(c.altkey) |
| 96 | // wipeCacheDir needs to be called after SetCamdevVars, because that is |
| 97 | // where CAMLI_CACHE_DIR is defined. |
| 98 | if *wipeCache { |
| 99 | c.env.wipeCacheDir() |
| 100 | } |
| 101 | |
| 102 | tryUnmount(mountpoint) |
| 103 | if err := os.Mkdir(mountpoint, 0700); err != nil && !os.IsExist(err) { |
| 104 | return fmt.Errorf("Could not make mount point: %v", err) |
| 105 | } |
| 106 | |
| 107 | blobserver := "http://localhost:" + c.port + c.path |
| 108 | if c.tls { |
| 109 | blobserver = strings.Replace(blobserver, "http://", "https://", 1) |
| 110 | } |
| 111 | |
| 112 | cmdBin, err := osutil.LookPathGopath("pk-mount") |
| 113 | if err != nil { |
| 114 | return err |
| 115 | } |
| 116 | cmdArgs := []string{ |
| 117 | "-debug=" + strconv.FormatBool(c.debug), |
| 118 | "-server=" + blobserver, |
| 119 | } |
| 120 | cmdArgs = append(cmdArgs, args...) |
| 121 | cmdArgs = append(cmdArgs, mountpoint) |
| 122 | fmt.Printf("pk-mount running with mountpoint %v. Press 'q' <enter> or ctrl-c to shut down.\n", mountpoint) |
| 123 | return runExec(cmdBin, cmdArgs, c.env) |
| 124 | } |
| 125 | |
| 126 | func (c *mountCmd) checkFlags(args []string) error { |
| 127 | if _, err := strconv.ParseInt(c.port, 0, 0); err != nil { |
nothing calls this directly
no test coverage detected