Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add noop plugins #2218

Draft
wants to merge 1 commit into
base: release/v1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/porter/internal_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"fmt"
"io"

"get.porter.sh/porter/pkg/storage/plugins/noop"

"get.porter.sh/porter/pkg/config"
"get.porter.sh/porter/pkg/plugins"
"get.porter.sh/porter/pkg/portercontext"
Expand Down Expand Up @@ -129,6 +131,13 @@ func getInternalPlugins() map[string]InternalPlugin {
return filesystem.NewPlugin(c, pluginCfg), nil
},
},
noop.PluginKey: {
Interface: storageplugins.PluginInterface,
ProtocolVersion: storageplugins.PluginProtocolVersion,
Create: func(c *config.Config, pluginCfg interface{}) (plugin.Plugin, error) {
return noop.NewPlugin(c.Context)
},
},
mongodb.PluginKey: {
Interface: storageplugins.PluginInterface,
ProtocolVersion: storageplugins.PluginProtocolVersion,
Expand Down
65 changes: 65 additions & 0 deletions pkg/storage/plugins/noop/noop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package noop

import (
"context"

"get.porter.sh/porter/pkg/storage/plugins"
"go.mongodb.org/mongo-driver/bson"
)

var (
_ plugins.StorageProtocol = Store{}
)

// Store implements a noop storage plugin.
type Store struct{}

// NewStore creates a new storage plugin that does nothing.
func NewStore() Store {
return Store{}
}

// Aggregate does nothing.
func (s Store) Aggregate(ctx context.Context, opts plugins.AggregateOptions) ([]bson.Raw, error) {
return nil, nil
}

// EnsureIndex does nothing.
func (s Store) EnsureIndex(ctx context.Context, opts plugins.EnsureIndexOptions) error {
return nil
}

// Count does nothing.
func (s Store) Count(ctx context.Context, opts plugins.CountOptions) (int64, error) {
return 0, nil
}

// Find does nothing.
func (s Store) Find(ctx context.Context, opts plugins.FindOptions) ([]bson.Raw, error) {
return nil, nil
}

// Insert does nothing
func (s Store) Insert(ctx context.Context, opts plugins.InsertOptions) error {
return nil
}

// Patch does nothing
func (s Store) Patch(ctx context.Context, opts plugins.PatchOptions) error {
return nil
}

// Remove does nothing
func (s Store) Remove(ctx context.Context, opts plugins.RemoveOptions) error {
return nil
}

// Update does nothing
func (s Store) Update(ctx context.Context, opts plugins.UpdateOptions) error {
return nil
}

// RemoveDatabase does nothing.
func (s Store) RemoveDatabase(ctx context.Context) error {
return nil
}
21 changes: 21 additions & 0 deletions pkg/storage/plugins/noop/plugin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package noop

import (
"get.porter.sh/porter/pkg/portercontext"
"get.porter.sh/porter/pkg/storage/plugins"
"get.porter.sh/porter/pkg/storage/pluginstore"
"github.com/hashicorp/go-plugin"
)

const PluginKey = plugins.PluginInterface + ".porter.noop"

var _ plugins.StorageProtocol = Plugin{}

type Plugin struct {
*Store
}

func NewPlugin(c *portercontext.Context) (plugin.Plugin, error) {
impl := NewStore()
return pluginstore.NewPlugin(c, impl), nil
}