@@ -32,6 +32,11 @@ func resourceGithubEnterpriseSecurityConfiguration() *schema.Resource {
3232 ForceNew : true ,
3333 Description : "The slug of the enterprise." ,
3434 },
35+ "configuration_id" : {
36+ Type : schema .TypeInt ,
37+ Computed : true ,
38+ Description : "The numeric ID of the code security configuration." ,
39+ },
3540 "name" : {
3641 Type : schema .TypeString ,
3742 Required : true ,
@@ -303,7 +308,7 @@ func resourceGithubEnterpriseSecurityConfigurationCreate(ctx context.Context, d
303308 enterprise := d .Get ("enterprise_slug" ).(string )
304309 name := d .Get ("name" ).(string )
305310
306- tflog .Debug (ctx , fmt . Sprintf ( "Creating enterprise code security configuration: %s/%s" , enterprise , name ) , map [string ]any {
311+ tflog .Debug (ctx , "Creating enterprise code security configuration" , map [string ]any {
307312 "enterprise" : enterprise ,
308313 "name" : name ,
309314 })
@@ -312,7 +317,7 @@ func resourceGithubEnterpriseSecurityConfigurationCreate(ctx context.Context, d
312317
313318 configuration , _ , err := client .Enterprise .CreateCodeSecurityConfiguration (ctx , enterprise , config )
314319 if err != nil {
315- tflog .Error (ctx , fmt . Sprintf ( "Failed to create enterprise code security configuration: %s/%s" , enterprise , name ) , map [string ]any {
320+ tflog .Error (ctx , "Failed to create enterprise code security configuration" , map [string ]any {
316321 "enterprise" : enterprise ,
317322 "name" : name ,
318323 "error" : err .Error (),
@@ -326,7 +331,7 @@ func resourceGithubEnterpriseSecurityConfigurationCreate(ctx context.Context, d
326331 }
327332 d .SetId (id )
328333
329- tflog .Info (ctx , fmt . Sprintf ( "Created enterprise code security configuration: %s/%s (ID: %d)" , enterprise , name , configuration . GetID ()) , map [string ]any {
334+ tflog .Info (ctx , "Created enterprise code security configuration" , map [string ]any {
330335 "enterprise" : enterprise ,
331336 "name" : name ,
332337 "id" : configuration .GetID (),
@@ -348,7 +353,7 @@ func resourceGithubEnterpriseSecurityConfigurationRead(ctx context.Context, d *s
348353 return diag .FromErr (err )
349354 }
350355
351- tflog .Trace (ctx , fmt . Sprintf ( "Reading enterprise code security configuration: %s/%d" , enterprise , id ) , map [string ]any {
356+ tflog .Trace (ctx , "Reading enterprise code security configuration" , map [string ]any {
352357 "enterprise" : enterprise ,
353358 "id" : id ,
354359 })
@@ -358,15 +363,15 @@ func resourceGithubEnterpriseSecurityConfigurationRead(ctx context.Context, d *s
358363 var ghErr * github.ErrorResponse
359364 if errors .As (err , & ghErr ) {
360365 if ghErr .Response .StatusCode == http .StatusNotFound {
361- tflog .Info (ctx , fmt . Sprintf ( "Removing enterprise code security configuration %s/%d from state because it no longer exists in GitHub" , enterprise , id ) , map [string ]any {
366+ tflog .Info (ctx , "Removing enterprise code security configuration from state because it no longer exists in GitHub" , map [string ]any {
362367 "enterprise" : enterprise ,
363368 "id" : id ,
364369 })
365370 d .SetId ("" )
366371 return nil
367372 }
368373 }
369- tflog .Error (ctx , fmt . Sprintf ( "Failed to read enterprise code security configuration: %s/%d" , enterprise , id ) , map [string ]any {
374+ tflog .Error (ctx , "Failed to read enterprise code security configuration" , map [string ]any {
370375 "enterprise" : enterprise ,
371376 "id" : id ,
372377 "error" : err .Error (),
@@ -382,7 +387,7 @@ func resourceGithubEnterpriseSecurityConfigurationRead(ctx context.Context, d *s
382387 return diags
383388 }
384389
385- tflog .Trace (ctx , fmt . Sprintf ( "Successfully read enterprise code security configuration: %s/%d" , enterprise , id ) , map [string ]any {
390+ tflog .Trace (ctx , "Successfully read enterprise code security configuration" , map [string ]any {
386391 "enterprise" : enterprise ,
387392 "id" : id ,
388393 })
@@ -392,35 +397,27 @@ func resourceGithubEnterpriseSecurityConfigurationRead(ctx context.Context, d *s
392397
393398func resourceGithubEnterpriseSecurityConfigurationUpdate (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
394399 client := meta .(* Owner ).v3client
400+ enterprise := d .Get ("enterprise_slug" ).(string )
401+ id := int64 (d .Get ("configuration_id" ).(int ))
395402
396- enterprise , idStr , err := parseID2 (d .Id ())
397- if err != nil {
398- return diag .FromErr (err )
399- }
400-
401- id , err := strconv .ParseInt (idStr , 10 , 64 )
402- if err != nil {
403- return diag .FromErr (err )
404- }
405-
406- tflog .Debug (ctx , fmt .Sprintf ("Updating enterprise code security configuration: %s/%d" , enterprise , id ), map [string ]any {
403+ tflog .Debug (ctx , "Updating enterprise code security configuration" , map [string ]any {
407404 "enterprise" : enterprise ,
408405 "id" : id ,
409406 })
410407
411408 config := expandCodeSecurityConfigurationCommon (d )
412409
413- _ , _ , err = client .Enterprise .UpdateCodeSecurityConfiguration (ctx , enterprise , id , config )
410+ _ , _ , err : = client .Enterprise .UpdateCodeSecurityConfiguration (ctx , enterprise , id , config )
414411 if err != nil {
415- tflog .Error (ctx , fmt . Sprintf ( "Failed to update enterprise code security configuration: %s/%d" , enterprise , id ) , map [string ]any {
412+ tflog .Error (ctx , "Failed to update enterprise code security configuration" , map [string ]any {
416413 "enterprise" : enterprise ,
417414 "id" : id ,
418415 "error" : err .Error (),
419416 })
420417 return diag .FromErr (err )
421418 }
422419
423- tflog .Info (ctx , fmt . Sprintf ( "Updated enterprise code security configuration: %s/%d" , enterprise , id ) , map [string ]any {
420+ tflog .Info (ctx , "Updated enterprise code security configuration" , map [string ]any {
424421 "enterprise" : enterprise ,
425422 "id" : id ,
426423 })
@@ -430,41 +427,33 @@ func resourceGithubEnterpriseSecurityConfigurationUpdate(ctx context.Context, d
430427
431428func resourceGithubEnterpriseSecurityConfigurationDelete (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
432429 client := meta .(* Owner ).v3client
430+ enterprise := d .Get ("enterprise_slug" ).(string )
431+ id := int64 (d .Get ("configuration_id" ).(int ))
433432
434- enterprise , idStr , err := parseID2 (d .Id ())
435- if err != nil {
436- return diag .FromErr (err )
437- }
438-
439- id , err := strconv .ParseInt (idStr , 10 , 64 )
440- if err != nil {
441- return diag .FromErr (err )
442- }
443-
444- tflog .Debug (ctx , fmt .Sprintf ("Deleting enterprise code security configuration: %s/%d" , enterprise , id ), map [string ]any {
433+ tflog .Debug (ctx , "Deleting enterprise code security configuration" , map [string ]any {
445434 "enterprise" : enterprise ,
446435 "id" : id ,
447436 })
448437
449- _ , err = client .Enterprise .DeleteCodeSecurityConfiguration (ctx , enterprise , id )
438+ _ , err : = client .Enterprise .DeleteCodeSecurityConfiguration (ctx , enterprise , id )
450439 if err != nil {
451440 var ghErr * github.ErrorResponse
452441 if errors .As (err , & ghErr ) && ghErr .Response .StatusCode == http .StatusNotFound {
453- tflog .Info (ctx , fmt . Sprintf ( "Enterprise code security configuration %s/%d already deleted" , enterprise , id ) , map [string ]any {
442+ tflog .Info (ctx , "Enterprise code security configuration already deleted" , map [string ]any {
454443 "enterprise" : enterprise ,
455444 "id" : id ,
456445 })
457446 return nil
458447 }
459- tflog .Error (ctx , fmt . Sprintf ( "Failed to delete enterprise code security configuration: %s/%d" , enterprise , id ) , map [string ]any {
448+ tflog .Error (ctx , "Failed to delete enterprise code security configuration" , map [string ]any {
460449 "enterprise" : enterprise ,
461450 "id" : id ,
462451 "error" : err .Error (),
463452 })
464453 return diag .FromErr (err )
465454 }
466455
467- tflog .Info (ctx , fmt . Sprintf ( "Deleted enterprise code security configuration: %s/%d" , enterprise , id ) , map [string ]any {
456+ tflog .Info (ctx , "Deleted enterprise code security configuration" , map [string ]any {
468457 "enterprise" : enterprise ,
469458 "id" : id ,
470459 })
0 commit comments