From 87fbc80d4ad11b2ecf5db1af3b969b487a7b7cca Mon Sep 17 00:00:00 2001 From: Ruben Costa Date: Mon, 18 Nov 2024 09:49:53 +0100 Subject: [PATCH] return nkey seed --- internal/provider/nkey_resource.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/provider/nkey_resource.go b/internal/provider/nkey_resource.go index 6bf34f4..3cf3059 100644 --- a/internal/provider/nkey_resource.go +++ b/internal/provider/nkey_resource.go @@ -36,6 +36,7 @@ type NkeyModel struct { KeyType types.String `tfsdk:"type"` PublicKey types.String `tfsdk:"public_key"` PrivateKey types.String `tfsdk:"private_key"` + Seed types.String `tfsdk:"seed"` } func (r *Nkey) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { @@ -66,6 +67,11 @@ func (r *Nkey) Schema(ctx context.Context, req resource.SchemaRequest, resp *res MarkdownDescription: "Private key of the nkey to be given to the client for authentication", Sensitive: true, }, + "seed": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "Seed of the nkey to be given to the client for authentication", + Sensitive: true, + }, }, } } @@ -160,9 +166,14 @@ func (m *NkeyModel) generateKeys() (err error) { if err != nil { return err } + seed, err := keys.Seed() + if err != nil { + return err + } m.PublicKey = types.StringValue(pubKey) m.PrivateKey = types.StringValue(string(privKey)) + m.Seed = types.StringValue(string(seed)) return nil }