forked from 1Password/onepassword-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
secrets.go
43 lines (36 loc) · 1.4 KB
/
secrets.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// AUTOGENERATED - DO NOT EDIT MANUALLY
package onepassword
import (
"context"
"encoding/json"
"github.com/1password/onepassword-sdk-go/internal"
)
type SecretsAPI interface {
// Resolve returns the secret the provided secret reference points to.
// Secret references point to fields in 1Password. They have the following format: op://<vault-name>/<item-name>[/<section-name>]/<field-name>
// Read more about secret references: https://developer.1password.com/docs/cli/secret-references
Resolve(ctx context.Context, secretReference string) (string, error)
}
type SecretsSource struct {
internal.InnerClient
}
func NewSecretsSource(inner internal.InnerClient) *SecretsSource {
return &SecretsSource{inner}
}
// Resolve returns the secret the provided secret reference points to.
// Secret references point to fields in 1Password. They have the following format: op://<vault-name>/<item-name>[/<section-name>]/<field-name>
// Read more about secret references: https://developer.1password.com/docs/cli/secret-references
func (s SecretsSource) Resolve(ctx context.Context, secretReference string) (string, error) {
resultString, err := clientInvoke(ctx, s.InnerClient, "Resolve", map[string]interface{}{
"secret_reference": secretReference,
})
if err != nil {
return "", err
}
var result string
err = json.Unmarshal([]byte(*resultString), &result)
if err != nil {
return "", err
}
return result, nil
}