本文整理汇总了Golang中go/mozilla/org/sops.KeySource.Keys方法的典型用法代码示例。如果您正苦于以下问题:Golang KeySource.Keys方法的具体用法?Golang KeySource.Keys怎么用?Golang KeySource.Keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类go/mozilla/org/sops.KeySource
的用法示例。
在下文中一共展示了KeySource.Keys方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: kmsEntries
func (store *Store) kmsEntries(in []interface{}) (sops.KeySource, error) {
var keys []sops.MasterKey
keysource := sops.KeySource{Name: "kms", Keys: keys}
for _, v := range in {
entry, ok := v.(map[interface{}]interface{})
if !ok {
fmt.Println("KMS entry has invalid format, skipping...")
continue
}
key := &kms.MasterKey{}
key.Arn = entry["arn"].(string)
key.EncryptedKey = entry["enc"].(string)
role, ok := entry["role"].(string)
if ok {
key.Role = role
}
creationDate, err := time.Parse(time.RFC3339, entry["created_at"].(string))
if err != nil {
return keysource, fmt.Errorf("Could not parse creation date: %s", err)
}
key.CreationDate = creationDate
if _, ok := entry["context"]; ok {
key.EncryptionContext = kms.ParseKMSContext(entry["context"].(string))
}
keysource.Keys = append(keysource.Keys, key)
}
return keysource, nil
}
示例2: pgpEntries
func (store *Store) pgpEntries(in []interface{}) (sops.KeySource, error) {
var keys []sops.MasterKey
keysource := sops.KeySource{Name: "pgp", Keys: keys}
for _, v := range in {
entry := v.(map[interface{}]interface{})
key := &pgp.MasterKey{}
key.Fingerprint = entry["fp"].(string)
key.EncryptedKey = entry["enc"].(string)
creationDate, err := time.Parse(time.RFC3339, entry["created_at"].(string))
if err != nil {
return keysource, fmt.Errorf("Could not parse creation date: %s", err)
}
key.CreationDate = creationDate
keysource.Keys = append(keysource.Keys, key)
}
return keysource, nil
}
示例3: kmsEntries
func (store *Store) kmsEntries(in []interface{}) (sops.KeySource, error) {
var keys []sops.MasterKey
keysource := sops.KeySource{Name: "kms", Keys: keys}
for _, v := range in {
entry := v.(map[interface{}]interface{})
key := &kms.MasterKey{}
key.Arn = entry["arn"].(string)
key.EncryptedKey = entry["enc"].(string)
role, ok := entry["role"].(string)
if ok {
key.Role = role
}
creationDate, err := time.Parse(time.RFC3339, entry["created_at"].(string))
if err != nil {
return keysource, fmt.Errorf("Could not parse creation date: %s", err)
}
key.CreationDate = creationDate
keysource.Keys = append(keysource.Keys, key)
}
return keysource, nil
}