Documentation ¶
Index ¶
- Constants
- Variables
- func BoolFlag(fs *flag.FlagSet, name string) bool
- func HasGlobChar(pattern string) bool
- func IntFlag(fs *flag.FlagSet, name string) int
- func StringFlag(fs *flag.FlagSet, name string) string
- func Tilde(file string) string
- type ServerConfig
- type State
- func (s *State) AtSign(file string) upspin.PathName
- func (s *State) CreateLocal(path string) *os.File
- func (s *State) DefaultIO()
- func (s *State) DirServer(name upspin.PathName) upspin.DirServer
- func (s *State) Exit(err error)
- func (s *State) ExitNow()
- func (s *State) Exitf(format string, args ...interface{})
- func (s *State) Fail(err error)
- func (s *State) Failf(format string, args ...interface{})
- func (s *State) GlobAllUpspin(args []string) []*upspin.DirEntry
- func (s *State) GlobAllUpspinPath(args []string) []upspin.PathName
- func (s *State) GlobLocal(pattern string) []string
- func (s *State) GlobOneLocal(pattern string) string
- func (s *State) GlobOneUpspinPath(pattern string) upspin.PathName
- func (s *State) GlobUpspin(pattern string) []*upspin.DirEntry
- func (s *State) GlobUpspinPath(pattern string) []upspin.PathName
- func (s *State) Init(config upspin.Config)
- func (s *State) KeyServer() upspin.KeyServer
- func (s *State) MkdirAllLocal(path string)
- func (s *State) MkdirLocal(path string)
- func (s *State) OpenLocal(path string) *os.File
- func (s *State) ParseFlags(fs *flag.FlagSet, args []string, help, usage string)
- func (s *State) ReadAll(fileName string) []byte
- func (s *State) ReadServerConfig(cfgPath string) *ServerConfig
- func (s *State) SetIO(stdin io.Reader, stdout, stderr io.Writer)
- func (s *State) ShouldNotExist(path string)
- func (s *State) WriteServerConfig(cfgPath string, cfg *ServerConfig)
Constants ¶
const ServerConfigFile = "serverconfig.json"
ServerConfigFile specifies the file name of the JSON-encoded ServerConfig.
Variables ¶
var SetupServerFiles = []string{ "Writers", "public.upspinkey", "secret.upspinkey", ServerConfigFile, }
SetupServerFiles specifies the configuration files that 'upspin setupserver' should send to the upspinserver.
Functions ¶
func HasGlobChar ¶
HasGlobChar reports whether the string contains an unescaped Glob metacharacter.
func StringFlag ¶
StringFlag returns the value of the named string flag in the flag set.
func Tilde ¶
Tilde processes a leading tilde, if any, in the local file name. If the file name does not begin with a tilde, Tilde returns the argument unchanged. This special processing (only) is applied to all local file names passed to functions in this package. If the target user does not exist, it returns the original string.
Types ¶
type ServerConfig ¶
type ServerConfig struct { // Addr specifies the public host and port of the upspinserver. Addr upspin.NetAddr // User specifies the user name that the upspinserver will run as. User upspin.UserName // StoreConfig specifies the configuration options for the StoreServer. StoreConfig []string }
ServerConfig describes the configuration of an upspinserver.
type State ¶
type State struct { Name string // Name of the subcommand we are running. Config upspin.Config // Config; may be nil. Client upspin.Client // Client; may be nil. Interactive bool // Whether the command is line-by-line. Stdin io.Reader // Where to read standard input Stdout io.Writer // Where to write standard output. Stderr io.Writer // Where to write error output. ExitCode int // Exit with non-zero status for minor problems. }
State describes the state of a subcommand. See the comments for Exitf to see how Interactive is used. It allows a program to run multiple commands.
func (*State) AtSign ¶
AtSign processes a leading at sign, if any, in the Upspin file name and replaces it with the current user name. The name must be strictly "@" or begin with "@/", possibly with a suffix ("@+snapshot", "@+camera/"). (If the user name ready has a suffix and the file starts @+suffix, the returned user name appends the suffix from the argument.) Unlike Tilde, it does not look up others user's roots. The argument is of type string; once a file becomes an upspin.PathName it should not be passed to this function. If the file name does not begin with an at sign, AtSign returns the argument unchanged except for promotion to upspin.PathName. If the target user does not exist, it returns the original string.
func (*State) CreateLocal ¶
CreateLocal creates a file on local disk.
func (*State) DirServer ¶
DirServer returns the DirServer for the root of the name, or exits on failure.
func (*State) ExitNow ¶
func (s *State) ExitNow()
ExitNow terminates the process with the current ExitCode.
func (*State) Exitf ¶
Exitf prints the error and exits the program. If we are interactive, it calls panic("exit"), which is intended to be recovered from by the calling interpreter. We don't use log (although the packages we call do) because the errors are for regular people.
func (*State) GlobAllUpspin ¶
GlobAllUpspin processes the arguments, which should be Upspin paths, expanding glob patterns.
func (*State) GlobAllUpspinPath ¶
GlobAllUpspinPath processes the arguments, which should be Upspin paths, expanding glob patterns. It returns just the paths.
func (*State) GlobLocal ¶
GlobLocal glob-expands the argument, which should be a syntactically valid Glob pattern (including a plain file name). If the pattern is erroneous or matches no files, the function exits.
func (*State) GlobOneLocal ¶
GlobOneLocal glob-expands the argument, which must result in a single local file name. If not, it exits.
func (*State) GlobOneUpspinPath ¶
GlobOneUpspin glob-expands the argument, which must result in a single Upspin path.
func (*State) GlobUpspin ¶
GlobUpspin glob-expands the argument, which must be a syntactically valid Upspin glob pattern (including a plain path name). If the path does not exist or the pattern matches no paths, the function exits.
func (*State) GlobUpspinPath ¶
GlobUpspinPath glob-expands the argument, which must be a syntactically valid Upspin glob pattern (including a plain path name). It returns just the path names. If the pattern matches no paths, the function exits.
func (*State) KeyServer ¶
KeyServer returns the KeyServer for the root of the name, or exits on failure.
func (*State) MkdirAllLocal ¶
MkdirAllLocal creates a directory on local disk. It creates as much of the path as is necessary.
func (*State) MkdirLocal ¶
MkdirLocal creates a directory on local disk. It requires all but the last element to be present.
func (*State) ParseFlags ¶
ParseFlags parses the flags in the command line arguments, according to those set in the flag set.
func (*State) ReadAll ¶
ReadAll reads all contents from a local input file or from stdin if the input file name is empty
func (*State) ReadServerConfig ¶
func (s *State) ReadServerConfig(cfgPath string) *ServerConfig
ReadServerConfig reads and JSON-decodes the ServerConfigFile under cfgPath.
func (*State) ShouldNotExist ¶
ShouldNotExist calls s.Exit if the file already exists.
func (*State) WriteServerConfig ¶
func (s *State) WriteServerConfig(cfgPath string, cfg *ServerConfig)
WriteServerConfig JSON-encodes and writes the ServerConfigFile under cfgPath.