Sha256: 348dab688961f29b13dd75ababb7e178662198ec9fa940e3f048009ee1b2b575

Contents?: true

Size: 1.3 KB

Versions: 16

Compression:

Stored size: 1.3 KB

Contents

package keyring

// ArrayKeyring is a mock/non-secure backend that meets the Keyring interface.
// It is intended to be used to aid unit testing of code that relies on the package.
// NOTE: Do not use in production code.
type ArrayKeyring struct {
	items map[string]Item
}

// NewArrayKeyring returns an ArrayKeyring, optionally constructed with an initial slice
// of items.
func NewArrayKeyring(initial []Item) *ArrayKeyring {
	kr := &ArrayKeyring{}
	for _, i := range initial {
		_ = kr.Set(i)
	}
	return kr
}

// Get returns an Item matching Key.
func (k *ArrayKeyring) Get(key string) (Item, error) {
	if i, ok := k.items[key]; ok {
		return i, nil
	}
	return Item{}, ErrKeyNotFound
}

// Set will store an item on the mock Keyring.
func (k *ArrayKeyring) Set(i Item) error {
	if k.items == nil {
		k.items = map[string]Item{}
	}
	k.items[i.Key] = i
	return nil
}

// Remove will delete an Item from the Keyring.
func (k *ArrayKeyring) Remove(key string) error {
	delete(k.items, key)
	return nil
}

// Keys provides a slice of all Item keys on the Keyring.
func (k *ArrayKeyring) Keys() ([]string, error) {
	var keys = []string{}
	for key := range k.items {
		keys = append(keys, key)
	}
	return keys, nil
}

func (k *ArrayKeyring) GetMetadata(_ string) (Metadata, error) {
	return Metadata{}, ErrMetadataNeedsCredentials
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby_snowflake_client-1.3.7 ext/vendor/github.com/99designs/keyring/array.go
ruby_snowflake_client-1.3.6 ext/vendor/github.com/99designs/keyring/array.go
ruby_snowflake_client-1.3.5 ext/vendor/github.com/99designs/keyring/array.go
ruby_snowflake_client-1.3.4 ext/vendor/github.com/99designs/keyring/array.go
ruby_snowflake_client-1.3.4.pre.debug ext/vendor/github.com/99designs/keyring/array.go
ruby_snowflake_client-1.3.3.pre.debug ext/vendor/github.com/99designs/keyring/array.go
ruby_snowflake_client-1.3.2 ext/vendor/github.com/99designs/keyring/array.go
ruby_snowflake_client-1.3.1 ext/vendor/github.com/99designs/keyring/array.go
ruby_snowflake_client-1.3.0 ext/vendor/github.com/99designs/keyring/array.go
ruby_snowflake_client-1.2.1 ext/vendor/github.com/99designs/keyring/array.go
ruby_snowflake_client-1.2.0 ext/vendor/github.com/99designs/keyring/array.go
ruby_snowflake_client-1.1.1 ext/vendor/github.com/99designs/keyring/array.go
ruby_snowflake_client-1.1.0 ext/vendor/github.com/99designs/keyring/array.go
ruby_snowflake_client-1.0.2 ext/vendor/github.com/99designs/keyring/array.go
ruby_snowflake_client-1.0.1 ext/vendor/github.com/99designs/keyring/array.go
ruby_snowflake_client-1.0.0 ext/vendor/github.com/99designs/keyring/array.go