feat(plugin): Create skeleton

This commit is contained in:
Hugo committed 2024-02-28 15:12:43 +00:00
1 parent 9f09f161ba
commit a01669f03f
10 files changed
+547

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package plugin
import (
"github.com/hashicorp/boundary-plugin-minio/plugin/service/storage"
pb "github.com/hashicorp/boundary/sdk/pbs/plugin"
)
var (
_ pb.StoragePluginServiceServer = (*storage.StoragePlugin)(nil)
)
// MinioPlugin contains a collection of all MinIO plugin services.
type MinioPlugin struct {
// StoragePlugin implements the StoragePluginServiceServer interface for
// supporting storing and retrieving BSR data from a MinIO instance.
*storage.StoragePlugin
}
// NewMinioPlugin creates a new instance of the MinIO Plugin.
func NewMinioPlugin() *MinioPlugin {
return &MinioPlugin{
StoragePlugin: &storage.StoragePlugin{},
}
}
+35
View File
@@ -0,0 +1,35 @@
## Getting Started
To create a storage bucket (using default scope created by `boundary dev`):
```bash
boundary storage-buckets create \
-scope-id p_1234567890 \
-name "Example Plugin-Based Storage Bucket" \
-description "Description for plugin-based storage bucket" \
-plugin-name minio \
-bucket-name="session_recording_storage" \
-bucket-prefix="foo/bar/zoo" \
-worker-filter '"minio-access" in "/tags/type"' \
-attr endpoint_url="https://my-minio-instance.dev/s3-api" \
-attr region=REGION \
-secret access_key_id='KEY' \
-secret secret_access_key='SECRET'
```
### Attributes
The following `attributes` are valid on a MinIO storage bucket resource:
- `endpoint_url` (string, required): Fully-qualified endpoint pointing to a
MinIO S3 API.
- `region` (string, optional): The region to configure the storage bucket for.
### Secrets
The following `secrets` are valid on a MinIO storage bucket resource:
- `access_key_id` (string, required): The MinIO service account's access key to
use with this storage bucket.
- `secret_access_key` (string, required): The MinIO service account's secret key
to use with this storage bucket.
+62
View File
@@ -0,0 +1,62 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package storage
import (
"context"
"fmt"
pb "github.com/hashicorp/boundary/sdk/pbs/plugin"
)
var _ pb.StoragePluginServiceServer = (*StoragePlugin)(nil)
// StoragePlugin implements the StoragePluginServiceServer interface for the
// MinIO storage service plugin.
type StoragePlugin struct {
pb.UnimplementedStoragePluginServiceServer
}
// OnCreateStorageBucket is a hook that runs when a storage bucket is created.
func (sp *StoragePlugin) OnCreateStorageBucket(ctx context.Context, req *pb.OnCreateStorageBucketRequest) (*pb.OnCreateStorageBucketResponse, error) {
return nil, fmt.Errorf("unimplemented")
}
// OnUpdateStorageBucket is a hook that runs when a storage bucket is updated.
func (sp *StoragePlugin) OnUpdateStorageBucket(ctx context.Context, req *pb.OnUpdateStorageBucketRequest) (*pb.OnUpdateStorageBucketResponse, error) {
return nil, fmt.Errorf("unimplemented")
}
// OnDeleteStorageBucket is a hook that runs when a storage bucket is deleted.
func (sp *StoragePlugin) OnDeleteStorageBucket(ctx context.Context, req *pb.OnDeleteStorageBucketRequest) (*pb.OnDeleteStorageBucketResponse, error) {
return nil, fmt.Errorf("unimplemented")
}
// ValidatePermissions is a hook that checks if the secrets associated with the
// storage bucket meet the requirements of the plugin.
func (sp *StoragePlugin) ValidatePermissions(ctx context.Context, req *pb.ValidatePermissionsRequest) (*pb.ValidatePermissionsResponse, error) {
return nil, fmt.Errorf("unimplemented")
}
// HeadObject is a hook that retrieves metadata about an object.
func (sp *StoragePlugin) HeadObject(ctx context.Context, req *pb.HeadObjectRequest) (*pb.HeadObjectResponse, error) {
return nil, fmt.Errorf("unimplemented")
}
// GetObject is a hook that retrieves objects.
func (sp *StoragePlugin) GetObject(req *pb.GetObjectRequest, objServer pb.StoragePluginService_GetObjectServer) error {
return fmt.Errorf("unimplemented")
}
// PutObject is a hook that reads a file stored on local disk and stores it to
// an external object store.
func (sp *StoragePlugin) PutObject(ctx context.Context, req *pb.PutObjectRequest) (*pb.PutObjectResponse, error) {
return nil, fmt.Errorf("unimplemented")
}
// DeleteObjects deletes one or many files in an external object store via a
// provided key prefix.
func (sp *StoragePlugin) DeleteObjects(ctx context.Context, req *pb.DeleteObjectsRequest) (*pb.DeleteObjectsResponse, error) {
return nil, fmt.Errorf("unimplemented")
}
+24
View File
@@ -0,0 +1,24 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package storage
import (
"testing"
)
func TestOnCreateStorageBucket(t *testing.T) {}
func TestOnUpdateStorageBucket(t *testing.T) {}
func TestOnDeleteStorageBucket(t *testing.T) {}
func TestValidatePermissions(t *testing.T) {}
func TestHeadObject(t *testing.T) {}
func TestGetObject(t *testing.T) {}
func TestPutObject(t *testing.T) {}
func TestDeleteObjects(t *testing.T) {}