Add fake store for unit tests
Signed-off-by: Hasan Turken <turkenh@gmail.com>
This commit is contained in:
parent
19034f22d1
commit
936e12174d
|
|
@ -1,29 +0,0 @@
|
|||
package fake
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/crossplane/crossplane-runtime/pkg/reconciler/managed"
|
||||
|
||||
"github.com/crossplane/crossplane-runtime/pkg/resource"
|
||||
)
|
||||
|
||||
type SecretStoreFns struct {
|
||||
ConnectionPublisherFns
|
||||
}
|
||||
|
||||
// ConnectionPublisherFns is the pluggable struct to produce objects with ConnectionPublisher interface.
|
||||
type ConnectionPublisherFns struct {
|
||||
PublishConnectionFn func(ctx context.Context, mg resource.Managed, c managed.ConnectionDetails) error
|
||||
UnpublishConnectionFn func(ctx context.Context, mg resource.Managed, c managed.ConnectionDetails) error
|
||||
}
|
||||
|
||||
// PublishConnection details for the supplied Managed resource.
|
||||
func (fn ConnectionPublisherFns) PublishConnection(ctx context.Context, mg resource.Managed, c managed.ConnectionDetails) error {
|
||||
return fn.PublishConnectionFn(ctx, mg, c)
|
||||
}
|
||||
|
||||
// UnpublishConnection details for the supplied Managed resource.
|
||||
func (fn ConnectionPublisherFns) UnpublishConnection(ctx context.Context, mg resource.Managed, c managed.ConnectionDetails) error {
|
||||
return fn.UnpublishConnectionFn(ctx, mg, c)
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package fake
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/crossplane/crossplane-runtime/pkg/connection/secret/store"
|
||||
)
|
||||
|
||||
type SecretStore struct {
|
||||
ReadKeyValuesFn func(ctx context.Context, i store.SecretInstance) (store.KeyValues, error)
|
||||
WriteKeyValuesFn func(ctx context.Context, i store.SecretInstance, kv store.KeyValues) error
|
||||
DeleteKeyValuesFn func(ctx context.Context, i store.SecretInstance, kv store.KeyValues) error
|
||||
}
|
||||
|
||||
func (ss *SecretStore) ReadKeyValues(ctx context.Context, i store.SecretInstance) (store.KeyValues, error) {
|
||||
return ss.ReadKeyValuesFn(ctx, i)
|
||||
}
|
||||
|
||||
func (ss *SecretStore) WriteKeyValues(ctx context.Context, i store.SecretInstance, kv store.KeyValues) error {
|
||||
return ss.WriteKeyValuesFn(ctx, i, kv)
|
||||
}
|
||||
|
||||
func (ss *SecretStore) DeleteKeyValues(ctx context.Context, i store.SecretInstance, kv store.KeyValues) error {
|
||||
return ss.DeleteKeyValuesFn(ctx, i, kv)
|
||||
}
|
||||
Loading…
Reference in New Issue