Skip to content

Commit

Permalink
return nkey seed
Browse files Browse the repository at this point in the history
  • Loading branch information
rubencosta committed Nov 18, 2024
1 parent 81c8090 commit 87fbc80
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/provider/nkey_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
},
},
}
}
Expand Down Expand Up @@ -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
}

0 comments on commit 87fbc80

Please sign in to comment.