Esempio n. 1
0
// NewServer returns a new server with initial state
func NewServer(config *api.Config, mountpoint, token, root string) (*Server, error) {
	fs, err := fs.New(config, mountpoint, token, root)
	if err != nil {
		return nil, err
	}

	return &Server{fs: fs, connections: 1}, nil
}
Esempio n. 2
0
		if len(args) == 0 {
			return errors.New("expected exactly one argument")
		}

		if err := viper.BindPFlags(cmd.Flags()); err != nil {
			logrus.WithError(err).Fatal("could not bind flags")
		}

		return nil
	},
	Run: func(cmd *cobra.Command, args []string) {
		config := fs.NewConfig(viper.GetString("address"), viper.GetBool("insecure"))

		logrus.WithField("address", viper.GetString("address")).Info("creating FUSE client for Vault")

		fs, err := fs.New(config, args[0], viper.GetString("token"), viper.GetString("root"))
		if err != nil {
			logrus.WithError(err).Fatal("error creatinging fs")
		}

		// handle interrupt
		go func() {
			c := make(chan os.Signal, 1)
			signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)

			<-c
			logrus.Info("stopping")
			err := fs.Unmount()
			if err != nil {
				logrus.WithError(err).Fatal("could not unmount cleanly")
			}