コード例 #1
0
ファイル: main.go プロジェクト: jrnt30/docker-volume-keywhiz
func main() {
	var Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: %s [options] url\n", os.Args[0])
		flag.PrintDefaults()
	}

	flag.Parse()
	if flag.NArg() != 1 {
		Usage()
		os.Exit(1)
	}

	config := keywhizConfig{
		ServerURL:      flag.Args()[0],
		CertFile:       *certFile,
		KeyFile:        *keyFile,
		CaFile:         *caFile,
		User:           *user,
		Group:          *group,
		Ping:           *ping,
		Debug:          *debug,
		TimeoutSeconds: time.Duration(*timeoutSeconds) * time.Second,
	}

	lockMemory(config.Debug)

	d := newKeywhizDriver(*root, config)
	h := dkvolume.NewHandler(d)
	fmt.Printf("Listening on %s\n", socketAddress)
	fmt.Println(h.ServeUnix("root", socketAddress))
}
コード例 #2
0
ファイル: main.go プロジェクト: yybear/docker-volume-ceph-rbd
func main() {
	flag.Parse()
	d := newCephDriver(*root, *pool)
	h := dkvolume.NewHandler(d)
	fmt.Printf("listening on %s\n", socketAddress)
	fmt.Println(h.ServeUnix("root", socketAddress))
}
コード例 #3
0
ファイル: main.go プロジェクト: coduno/docker-volume-gcs
func main() {
	d := driver{
		Mutex: new(sync.Mutex),
		cmds:  make(map[string]exec.Cmd),
	}

	h := plugin.NewHandler(d)
	log.Printf("Listening on %s with mount target %s\n", socketAddress, root)
	log.Println(h.ServeUnix("root", socketAddress))
}
コード例 #4
0
func start(dt drivers.DriverType, driver dkvolume.Driver) {
	h := dkvolume.NewHandler(driver)
	if isTCPEnabled() {
		addr := os.Getenv(EnvTCPAddr)
		if addr == "" {
			addr, _ = rootCmd.PersistentFlags().GetString(PortFlag)
		}
		fmt.Println(h.ServeTCP(dt.String(), addr))
	} else {
		fmt.Println(h.ServeUnix("", dt.String()))
	}
}
コード例 #5
0
ファイル: main.go プロジェクト: ulrichSchreiner/etcdriver
func main() {
	viper.SetEnvPrefix("ETCDRIVER")
	viper.AutomaticEnv()
	viper.SetDefault(basepathKey, "/tmp/etcdriver")
	viper.SetDefault(etcdurlKey, "http://localhost:4001")
	base := viper.GetString(basepathKey)
	etcdurl := viper.GetString(etcdurlKey)

	driver := NewDriver(base, etcdurl)
	h := dkvolume.NewHandler(driver)
	fmt.Printf("Listening on %s\n", socketAddress)
	fmt.Println(h.ServeUnix("root", socketAddress))
}
コード例 #6
0
ファイル: main.go プロジェクト: l15k4/docker-volume-glusterfs
func main() {
	var Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: %s [options]\n", os.Args[0])
		flag.PrintDefaults()
	}

	flag.Parse()
	if len(*serversList) == 0 {
		Usage()
		os.Exit(1)
	}

	servers := strings.Split(*serversList, ":")

	d := newGlusterfsDriver(*root, *restAddress, *gfsBase, servers)
	h := dkvolume.NewHandler(d)
	fmt.Println(h.ServeUnix(*group, "glusterfs"))
}
コード例 #7
0
ファイル: main.go プロジェクト: pshouse/global-hack-day-3
func main() {
	var Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: %s [options] url\n", os.Args[0])
		flag.PrintDefaults()
	}

	flag.Parse()
	if flag.NArg() != 1 {
		Usage()
		os.Exit(1)
	}

	lockMemory()

	d := newDriver(*root, flag.Args()[0])
	h := dkvolume.NewHandler(d)
	fmt.Println(h.ServeUnix("root", "vault"))
}
コード例 #8
0
func main() {

	var Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: %s [options]\n", os.Args[0])
		flag.PrintDefaults()
	}

	flag.Parse()
	if len(*root) == 0 {
		Usage()
		os.Exit(1)
	}

	fmt.Fprintf(os.Stderr, "root is %s\n", *root)

	d := newVolumePoolDriver(*root)
	h := dkvolume.NewHandler(d)
	fmt.Println(h.ServeUnix("root", "volume_pool"))
}
コード例 #9
0
ファイル: main.go プロジェクト: h0tbird/docker-volume-rsync
func main() {

	// Initialize the driver struct:
	d := rsyncDriver{
		srcdst:   make(map[string]string),
		volRoot:  *volRoot,
		sshKey:   *sshKey,
		archive:  *archive,
		del:      *del,
		compress: *compress,
	}

	// Initializes the request handler with a driver implementation:
	h := dkvolume.NewHandler(&d)

	// Listen for requests in a unix socket:
	log.Printf("Listening on %s\n", socketAddress)
	fmt.Println(h.ServeUnix("root", socketAddress))
}
コード例 #10
0
ファイル: main.go プロジェクト: rmetzler/docker-volume-vault
func main() {
	var Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: %s [options]\n", os.Args[0])
		flag.PrintDefaults()
	}

	flag.Parse()
	if *url == "" || *token == "" {
		Usage()
		os.Exit(1)
	}

	lockMemory()

	vault.DefaultConfig = &api.Config{Address: *url, HttpClient: http.DefaultClient}
	d := newDriver(*root, *token)
	h := dkvolume.NewHandler(d)
	fmt.Println(h.ServeUnix("root", "vault"))
}
コード例 #11
0
func main() {

	plugin := cli.NewApp()
	plugin.Name = "iscsi-docker-plugin"
	plugin.Usage = "Manage iSCSI Volumes"
	plugin.Version = "0.1.0"
	plugin.Commands = []cli.Command{
		{
			Name:   "list",
			Usage:  "List the iSCSI volumes (added/discovered)",
			Action: listVolumes,
		},
		{
			Name:  "discover",
			Usage: "Perform volume discovery",
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:  "target",
					Usage: "target IP / hostname for LUN discovery",
				},
			},
			Action: discoverVolumes,
		},
		{
			Name:   "login",
			Usage:  "login the target",
			Action: loginTarget,
		},
		{
			Name:   "logout",
			Usage:  "logout the target",
			Action: logoutTarget,
		},
	}
	plugin.Run(os.Args)

	d := newISCSIVolumeDriver("iscsi")
	h := dkvolume.NewHandler(d)
	fmt.Println("Listening on ", socketAddress)
	fmt.Println(h.ServeUnix("root", socketAddress))

}
コード例 #12
0
func main() {
	var Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: %s [options]\n", os.Args[0])
		flag.PrintDefaults()
	}

	flag.Parse()
	if flag.NArg() != 1 {
		Usage()
		os.Exit(1)
	}

	config := redisConfig{
		ServerURL: flag.Args()[0],
		DbName:    *dbName,
		Password:  *password,
	}

	d := newRedisDriver(*root, config)
	h := dkvolume.NewHandler(d)
	fmt.Printf("Listening on %s\n", socketAddress)
	fmt.Println(h.ServeUnix("root", socketAddress))
}
コード例 #13
0
func main() {
	var (
		clusterAddress string
		username       string
		password       string
	)

	flag.StringVar(&clusterAddress, "cluster-ip", "",
		"Isilon cluster ip address <x.x.x.x>")

	flag.StringVar(&username, "username", "",
		"Admin username")

	flag.StringVar(&password, "password", "",
		"Admin password")

	flag.Parse()

	d := driver.NewIsilonDriver(clusterAddress, username, password)
	handler := dkvolume.NewHandler(d)
	log.Printf("listening on %s\n", socketAddress)
	log.Fatal(handler.ServeUnix("root", socketAddress))
}
コード例 #14
0
func main() {
	if *versionFlag {
		fmt.Printf("%s\n", VERSION)
		return
	}

	logFile, err := setupLogging()
	if err != nil {
		log.Panicf("Unable to setup logging: %s", err)
	}
	defer shutdownLogging(logFile)

	log.Printf(
		"INFO: Setting up Ceph Driver for PluginID=%s, cluster=%s, user=%s, pool=%s, mount=%s, config=%s",
		*pluginName,
		*cephCluster,
		*cephUser,
		*defaultCephPool,
		*rootMountDir,
		*cephConfigFile,
	)
	// build driver struct
	d := newCephRBDVolumeDriver(
		*pluginName,
		*cephCluster,
		*cephUser,
		*defaultCephPool,
		*rootMountDir,
		*cephConfigFile,
	)
	defer d.shutdown()

	log.Println("INFO: Creating Docker VolumeDriver Handler")
	h := dkvolume.NewHandler(d)

	socket := socketPath()
	log.Printf("INFO: Opening Socket for Docker to connect: %s", socket)
	// ensure directory exists
	err = os.MkdirAll(filepath.Dir(socket), os.ModeDir)
	if err != nil {
		log.Panicf("Error creating socket directory: %s", err)
	}

	// setup signal handling after logging setup and creating driver, in order to signal the logfile and ceph connection
	// NOTE: systemd will send SIGTERM followed by SIGKILL after a timeout to stop a service daemon
	// NOTE: we chose to use SIGHUP to reload logfile and ceph connection
	signalChannel := make(chan os.Signal, 2) // chan with buffer size 2
	signal.Notify(signalChannel, syscall.SIGTERM, syscall.SIGKILL, syscall.SIGHUP)
	go func() {
		for sig := range signalChannel {
			//sig := <-signalChannel
			switch sig {
			case syscall.SIGTERM, syscall.SIGKILL:
				log.Printf("INFO: received TERM or KILL signal: %s", sig)
				// close up conn and logs
				d.shutdown()
				shutdownLogging(logFile)
				os.Exit(0)
			case syscall.SIGHUP:
				// reload logs and conn
				log.Printf("INFO: received HUP signal: %s", sig)
				logFile, err = reloadLogging(logFile)
				if err != nil {
					log.Printf("Unable to reload log: %s", err)
				}
				d.reload()
			}
		}
	}()

	// NOTE: pass empty string for group to skip broken chgrp in dkvolume lib
	err = h.ServeUnix("", socket)

	if err != nil {
		log.Printf("ERROR: Unable to create UNIX socket: %v", err)
	}
}
コード例 #15
0
ファイル: main.go プロジェクト: ioggstream/docker-volumes-nfs
func main() {
	d := garbageDriver{*root}
	h := dkvolume.NewHandler(d)
	fmt.Println(h.ServeUnix("", "/usr/share/docker/plugins/nfs.sock"))
}
コード例 #16
0
ファイル: main.go プロジェクト: kapalhq/docker-volume-tmpfs
func main() {
	d := newTmpfsDriver("/var/lib/dockertmpfs")
	h := dkvolume.NewHandler(d)
	fmt.Println(h.ServeUnix("root", "tmpfs"))
}
コード例 #17
0
func main() {
	app := cli.NewApp()
	app.Version = version.FullVersion()
	app.Name = "docker-volume-libsecret"
	app.Usage = "docker volume driver plugin for libsecret"
	app.Author = "@ehazlett"
	app.Email = "github.com/ehazlett/docker-volume-libsecret"
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "root, r",
			Usage: "root path for volumes",
			Value: "/var/lib/docker/volumes/libsecret",
		},
		cli.StringFlag{
			Name:  "addr",
			Usage: "secret backend addr",
			Value: "",
		},
		cli.StringFlag{
			Name:  "backend",
			Usage: "secret backend",
			Value: "",
		},
		cli.StringSliceFlag{
			Name:  "store-opt",
			Usage: "options to pass to libsecret store (key=val)",
			Value: &cli.StringSlice{},
		},
	}

	app.Action = func(c *cli.Context) {
		log.Infof("%s v%s", app.Name, app.Version)

		rootPath := c.String("root")
		backendAddr := c.String("addr")
		backendName := c.String("backend")
		opts := getStoreOpts(c)

		if backendAddr == "" {
			log.Fatal("you must specify a backend address")
		}

		if backendName == "" {
			log.Fatal("you must specify a backend type")
		}

		backend := getBackend(backendName)

		log.Debugf("initializing secret driver: backend=%s addr=%s", backend, backendAddr)
		d, err := NewSecretDriver(rootPath, backend, backendAddr, opts)
		if err != nil {
			log.Fatal(err)
		}

		h := dkvolume.NewHandler(d)
		if err := h.ServeUnix("root", "libsecret"); err != nil {
			log.Fatal(err)
		}

		cs := make(chan os.Signal, 1)
		signal.Notify(cs, os.Interrupt)
		go func() {
			for _ = range cs {
				// cleanup
			}
		}()

	}

	if err := app.Run(os.Args); err != nil {
		log.Fatal(err)
	}
}