@@ -34,10 +34,11 @@ func resourceGithubUserSshSigningKey() *schema.Resource {
3434 Required : true ,
3535 ForceNew : true ,
3636 Description : "The public SSH key to add to your GitHub account." ,
37- DiffSuppressFunc : func (k , oldV , newV string , d * schema.ResourceData ) bool {
38- newTrimmed := strings .TrimSpace (newV )
39- return oldV == newTrimmed
40- },
37+ },
38+ "key_id" : {
39+ Type : schema .TypeInt ,
40+ Computed : true ,
41+ Description : "The unique identifier of the SSH signing key." ,
4142 },
4243 "etag" : {
4344 Type : schema .TypeString ,
@@ -63,6 +64,9 @@ func resourceGithubUserSshSigningKeyCreate(ctx context.Context, d *schema.Resour
6364
6465 d .SetId (strconv .FormatInt (userKey .GetID (), 10 ))
6566
67+ if err = d .Set ("key_id" , userKey .GetID ()); err != nil {
68+ return diag .FromErr (err )
69+ }
6670 if err = d .Set ("etag" , resp .Header .Get ("ETag" )); err != nil {
6771 return diag .FromErr (err )
6872 }
@@ -79,12 +83,8 @@ func resourceGithubUserSshSigningKeyCreate(ctx context.Context, d *schema.Resour
7983func resourceGithubUserSshSigningKeyRead (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
8084 client := meta .(* Owner ).v3client
8185
82- id , err := strconv .ParseInt (d .Id (), 10 , 64 )
83- if err != nil {
84- return diag .Errorf ("failed to convert ID %s: %v" , d .Id (), err )
85- }
86-
87- key , resp , err := client .Users .GetSSHSigningKey (ctx , id )
86+ keyID := d .Get ("key_id" ).(int64 )
87+ key , resp , err := client .Users .GetSSHSigningKey (ctx , keyID )
8888 if err != nil {
8989 if ghErr , ok := err .(* github.ErrorResponse ); ok {
9090 if ghErr .Response .StatusCode == http .StatusNotModified {
@@ -99,29 +99,14 @@ func resourceGithubUserSshSigningKeyRead(ctx context.Context, d *schema.Resource
9999 }
100100 }
101101 }
102-
103- if err = d .Set ("etag" , resp .Header .Get ("ETag" )); err != nil {
104- return diag .FromErr (err )
105- }
106- if err = d .Set ("title" , key .GetTitle ()); err != nil {
107- return diag .FromErr (err )
108- }
109- if err = d .Set ("key" , key .GetKey ()); err != nil {
110- return diag .FromErr (err )
111- }
112-
113102 return nil
114103}
115104
116105func resourceGithubUserSshSigningKeyDelete (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
117106 client := meta .(* Owner ).v3client
118107
119- id , err := strconv .ParseInt (d .Id (), 10 , 64 )
120- if err != nil {
121- return diag .Errorf ("failed to convert ID %s: %v" , d .Id (), err )
122- }
123-
124- resp , err := client .Users .DeleteSSHSigningKey (ctx , id )
108+ keyID := d .Get ("key_id" ).(int64 )
109+ resp , err := client .Users .DeleteSSHSigningKey (ctx , keyID )
125110 if resp .StatusCode == http .StatusNotFound {
126111 return nil
127112 }
0 commit comments