github.com/trustbloc/kms-go@v1.1.2/spi/kms/key_opts.go (about) 1 /* 2 Copyright SecureKey Technologies Inc. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package kms 8 9 // keyOpts holds options for Create, Rotate and CreateAndExportPubKeyBytes. 10 type keyOpts struct { 11 attrs []string 12 } 13 14 // NewKeyOpt creates a new empty key option. 15 // Not to be used directly. It's intended for implementations of KeyManager interface 16 // Use WithAttrs() option function below instead. 17 func NewKeyOpt() *keyOpts { // nolint 18 return &keyOpts{} 19 } 20 21 // Attrs gets the additional attributes to be used for a key creation. 22 // Not to be used directly. It's intended for implementations of KeyManager interface 23 // Use WithAttrs() option function below instead. 24 func (pk *keyOpts) Attrs() []string { 25 return pk.attrs 26 } 27 28 // KeyOpts are the create key option. 29 type KeyOpts func(opts *keyOpts) 30 31 // WithAttrs option is for creating a key that requires extra attributes. 32 func WithAttrs(attrs []string) KeyOpts { 33 return func(opts *keyOpts) { 34 opts.attrs = attrs 35 } 36 }