Go - Secret.Version.Access()
Retrieves the value from a version of a secret.
import ("fmt""github.com/nitrictech/go-sdk/nitric")func main() {secret, err := nitric.NewSecret("secret-name").With(nitric.SecretAccessing)if err != nil {return}value, err := secret.Latest().Access(context.TODO())if err != nil {return}fmt.Println(value.AsString())nitric.Run()}
Parameters
- Name
ctx
- Required
- Required
- Type
- context
- Description
The context of the call, used for tracing.
Examples
Access the latest version of a secret
import ("fmt""github.com/nitrictech/go-sdk/nitric")func main() {secret, err := nitric.NewSecret("secret-name").With(nitric.SecretAccessing)if err != nil {return}value, err := secret.Latest().Access(context.TODO())if err != nil {return}fmt.Println(value.AsString())nitric.Run()}
Access a specific version of a secret
import ("context""fmt""github.com/nitrictech/go-sdk/nitric")func main() {secret, err := nitric.NewSecret("secret-name").With(nitric.SecretAccessing)if err != nil {return}version, err := secret.Version("the-version-id").Access(context.TODO())if err != nil {fmt.Println(err)return}fmt.Println(version.AsString())nitric.Run()}
Last updated on Dec 5, 2024