Skip to content
Merged
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
23 changes: 23 additions & 0 deletions internal/backends/nop/nop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package nop

import "context"

func New() *Backend {
return &Backend{}
}

// Backend can be used in cases where no backend is specified to avoid the need to check for nil
// pointers in all resolvers.
type Backend struct{}

func (*Backend) Set(_ context.Context, _, _, _ string) error {
return nil
}

func (*Backend) Get(_ context.Context, _, _ string) (string, error) {
return "", nil
}

func (*Backend) Close(_ context.Context) error {
return nil
}
3 changes: 2 additions & 1 deletion plugins/source/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/cloudquery/plugin-sdk/backend"
"github.com/cloudquery/plugin-sdk/caser"
"github.com/cloudquery/plugin-sdk/internal/backends/local"
"github.com/cloudquery/plugin-sdk/internal/backends/nop"
"github.com/cloudquery/plugin-sdk/schema"
"github.com/cloudquery/plugin-sdk/specs"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -210,7 +211,7 @@ func (p *Plugin) Init(ctx context.Context, spec specs.Source) error {

switch spec.Backend {
case specs.BackendNone:
// do nothing
p.backend = nop.New()
case specs.BackendLocal:
p.backend, err = local.New(spec)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion specs/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
BackendLocal
)

var AllBackends = Backends{BackendLocal}
var AllBackends = Backends{BackendNone, BackendLocal}
var AllBackendNames = [...]string{
BackendNone: "none",
BackendLocal: "local",
Expand Down