Ejemplo n.º 1
0
// Driver uses the DriverFactory's Options to construct a strata.Driver
func (factory DriverFactory) Driver() (*strata.Driver, error) {
	options := factory.GetOptions().(*Options)

	accessKey := os.Getenv("AWS_ACCESS_KEY_ID")
	secretKey := os.Getenv("AWS_SECRET_ACCESS_KEY")
	if accessKey == "" || secretKey == "" {
		return nil, errors.New("Environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must be set")
	}

	s3storage, err := s3storage.NewS3Storage(
		aws.Regions[options.AWS.Region],
		aws.Auth{AccessKey: accessKey, SecretKey: secretKey},
		options.AWS.BucketName,
		options.AWS.BucketPrefix,
		s3.ACL(options.AWS.BucketACL))
	if err != nil {
		return nil, err
	}
	replica, err := lreplica.NewLocalReplica(options.Replica.MaxBackgroundCopies, strconv.Itoa(options.Replica.Port))
	if err != nil {
		return nil, err
	}
	manager, err := strata.NewSnapshotManager(replica, s3storage)
	if err != nil {
		return nil, err
	}
	return &strata.Driver{Manager: manager}, err
}
Ejemplo n.º 2
0
// Driver uses the DriverFactory's Options to construct a strata.Driver
func (factory DriverFactory) Driver() (*strata.Driver, error) {
	options := factory.GetOptions().(*Options)

	endPoint := os.Getenv("MINIO_ENDPOINT")
	secure := os.Getenv("MINIO_SECURE")
	accessKey := os.Getenv("MINIO_ACCESS_KEY_ID")
	secretKey := os.Getenv("MINIO_SECRET_ACCESS_KEY")
	if endPoint == "" || accessKey == "" || secretKey == "" {
		return nil, errors.New("Environment variables MINIO_ENDPOINT, MINIO_ACCESS_KEY_ID and MINIO_SECRET_ACCESS_KEY must be set")
	}

	if secure == "" {
		secure = "true"
	}

	secureBool, err := strconv.ParseBool(secure)
	if err != nil {
		return nil, errors.New("Valid values for environment variable MINIO_SECURE are 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False")
	}

	minio, err := miniostorage.NewMinioStorage(
		endPoint,
		accessKey, secretKey,
		options.Minio.BucketName,
		options.Minio.BucketPrefix,
		options.Minio.Region,
		secureBool)

	if err != nil {
		return nil, err
	}

	replica, err := lreplica.NewLocalReplica(
		options.Replica.MaxBackgroundCopies,
		strconv.Itoa(options.Replica.Port),
		options.Replica.Username,
		options.Replica.Password,
	)

	if err != nil {
		return nil, err
	}

	manager, err := strata.NewSnapshotManager(replica, minio)

	if err != nil {
		return nil, err
	}

	return &strata.Driver{Manager: manager}, err
}
Ejemplo n.º 3
0
// Driver uses the DriverFactory's Options to construct a strata.Driver
func (factory DriverFactory) Driver() (*strata.Driver, error) {
	options := factory.GetOptions().(*Options)

	fsstore, err := lstorage.NewLStorage(options.LocalStorage.Mountpoint)
	if err != nil {
		return nil, err
	}

	replica, err := lreplica.NewLocalReplica(
		options.Replica.MaxBackgroundCopies,
		strconv.Itoa(options.Replica.Port),
		options.Replica.Username,
		options.Replica.Password,
	)
	if err != nil {
		return nil, err
	}
	manager, err := strata.NewSnapshotManager(replica, fsstore)
	if err != nil {
		return nil, err
	}
	return &strata.Driver{Manager: manager}, err
}