Skip to content

Commit

Permalink
Skeleton code for AWS EFS provider (#5940)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakan Memisoglu authored and Ilya Kislenko committed Jun 27, 2019
1 parent 272ef43 commit 92fa1f7
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 0 deletions.
70 changes: 70 additions & 0 deletions pkg/blockstorage/awsefs/awsefs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package awsefs

import (
"context"
"errors"

"github.com/kanisterio/kanister/pkg/blockstorage"
)

type efs struct {
}

var _ blockstorage.Provider = (*efs)(nil)

// NewEFSProvider retuns a blockstorage provider for AWS EFS.
func NewEFSProvider() blockstorage.Provider {
return &efs{}
}

func (e *efs) Type() blockstorage.Type {
return blockstorage.TypeEFS
}

func (e *efs) VolumeCreate(context.Context, blockstorage.Volume) (*blockstorage.Volume, error) {
return nil, errors.New("Not implemented")
}

func (e *efs) VolumeCreateFromSnapshot(ctx context.Context, snapshot blockstorage.Snapshot, tags map[string]string) (*blockstorage.Volume, error) {
return nil, errors.New("Not implemented")
}

func (e *efs) VolumeDelete(context.Context, *blockstorage.Volume) error {
return errors.New("Not implemented")
}

func (e *efs) VolumeGet(ctx context.Context, id string, zone string) (*blockstorage.Volume, error) {
return nil, errors.New("Not implemented")
}

func (e *efs) SnapshotCopy(ctx context.Context, from blockstorage.Snapshot, to blockstorage.Snapshot) (*blockstorage.Snapshot, error) {
return nil, errors.New("Not implemented")
}

func (e *efs) SnapshotCreate(ctx context.Context, volume blockstorage.Volume, tags map[string]string) (*blockstorage.Snapshot, error) {
return nil, errors.New("Not implemented")
}

func (e *efs) SnapshotCreateWaitForCompletion(context.Context, *blockstorage.Snapshot) error {
return errors.New("Not implemented")
}

func (e *efs) SnapshotDelete(context.Context, *blockstorage.Snapshot) error {
return errors.New("Not implemented")
}

func (e *efs) SnapshotGet(ctx context.Context, id string) (*blockstorage.Snapshot, error) {
return nil, errors.New("Not implemented")
}

func (e *efs) SetTags(ctx context.Context, resource interface{}, tags map[string]string) error {
return errors.New("Not implemented")
}

func (e *efs) VolumesList(ctx context.Context, tags map[string]string, zone string) ([]*blockstorage.Volume, error) {
return nil, errors.New("Not implemented")
}

func (e *efs) SnapshotsList(ctx context.Context, tags map[string]string) ([]*blockstorage.Snapshot, error) {
return nil, errors.New("Not implemented")
}
57 changes: 57 additions & 0 deletions pkg/blockstorage/awsefs/awsefs_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package awsefs

import (
"context"
"testing"

"github.com/kanisterio/kanister/pkg/blockstorage"
. "gopkg.in/check.v1"
)

func Test(t *testing.T) { TestingT(t) }

type AWSEFSTestSuite struct {
provider blockstorage.Provider
}

func (s *AWSEFSTestSuite) SetUpSuite(c *C) {
s.provider = NewEFSProvider()
}
func (s *AWSEFSTestSuite) TestVolumeCreateGetDelete(c *C) {
c.Skip("Implementation is not ready")
ctx := context.Background()
az := "us-west-2a"
tags := make(map[string]string)
vol := blockstorage.Volume{
Az: az,
Type: blockstorage.TypeEFS,
Attributes: tags,
}

vol1, err := s.provider.VolumeCreate(ctx, vol)
c.Assert(err, IsNil)
c.Assert(vol1.ID, Equals, vol.ID)

vol2, err := s.provider.VolumeGet(ctx, vol1.ID, vol1.Az)
c.Assert(err, IsNil)
c.Assert(vol2.ID, Equals, vol1.ID)

vols1, err := s.provider.VolumesList(ctx, tags, vol2.Az)
c.Assert(err, IsNil)
c.Assert(vols1, HasLen, 1)

err = s.provider.VolumeDelete(ctx, vol2)
c.Assert(err, IsNil)

// Deleting second time must not fail
err = s.provider.VolumeDelete(ctx, vol2)
c.Assert(err, IsNil)

// Get for deleted volume must return error
_, err = s.provider.VolumeGet(ctx, vol2.ID, vol2.Az)
c.Assert(err, NotNil)

vols2, err := s.provider.VolumesList(ctx, tags, vol2.Az)
c.Assert(err, IsNil)
c.Assert(vols2, HasLen, 0)
}
2 changes: 2 additions & 0 deletions pkg/blockstorage/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ const (
TypeCeph Type = "Ceph"
// TypeSoftlayerBlock captures enum value "SoftlayerBlock"
TypeSoftlayerBlock Type = "SoftlayerBlock"
// TypeEFS captures enum value "EFS"
TypeEFS Type = "EFS"
)

0 comments on commit 92fa1f7

Please sign in to comment.