func New(opts ...Option) (Keystore, error) {
	o := &Options{
		primaryKeyURI:   localKeyURIPrefix + "primaryKey",
		storageProvider: mem.NewProvider(),
		secretLock:      &noop.NoLock{},
	}

	for i := range opts {
		opts[i](o)
	}

	if o.kmsCreator == nil {
		o.kmsCreator = func(p kms.Provider) (kms.KeyManager, error) {
			localKMS, e := localkms.New(o.primaryKeyURI, p)
			if e != nil {
				return nil, fmt.Errorf("new local KMS: %w", e)
			}

			return localKMS, nil
		}
	}

	p := kmsProvider{
		storageProvider: o.storageProvider,
		secretLock:      o.secretLock,
	}

	keyManager, err := o.kmsCreator(p)
	if err != nil {
		return nil, fmt.Errorf("new keystore: %w", err)
	}

	return &keystore{keyManager: keyManager}, nil
}
// New returns a new Keystore instance.
New returns a new Keystore instance.
// New returns a new Keystore instance .
func New(opts ...Option) (Keystore, error) {
	o := &Options{
		primaryKeyURI:   localKeyURIPrefix + "primaryKey",
		storageProvider: mem.NewProvider(),
		secretLock:      &noop.NoLock{},
	}
	for i := range opts {
		opts[i](o)
	}
	if o.kmsCreator == nil {
		o.kmsCreator = func(p kms.Provider) (kms.KeyManager, error) {
			localKMS, e := localkms.New(o.primaryKeyURI, p)
			if e != nil {
				return nil, fmt.Errorf("new local KMS: %w", e)
			}
			return localKMS, nil
		}
	}
	p := kmsProvider{
		storageProvider: o.storageProvider,
		secretLock:      o.secretLock,
	}
	keyManager, err := o.kmsCreator(p)
	if err != nil {
		return nil, fmt.Errorf("new keystore: %w", err)
	}
	return &keystore{keyManager: keyManager}, nil
}
func New ( opts ... Option ) ( Keystore , error ) { o := & Options { primaryKeyURI : localKeyURIPrefix + " " , storageProvider : mem . NewProvider ( ) , secretLock : & noop . NoLock { } , } for i := range opts { opts [ i ] ( o ) } if o . kmsCreator == nil { o . kmsCreator = func ( p kms . Provider ) ( kms . KeyManager , error ) { localKMS , e := localkms . New ( o . primaryKeyURI , p ) if e != nil { return nil , fmt . Errorf ( " " , e ) } return localKMS , nil } } p := kmsProvider { storageProvider : o . storageProvider , secretLock : o . secretLock , } keyManager , err := o . kmsCreator ( p ) if err != nil { return nil , fmt . Errorf ( " " , err ) } return & keystore { keyManager : keyManager } , nil }
New returns a new Keystore instance.
New returns a new Keystore instance .