@@ -815,7 +815,7 @@ func resourceGithubRepositoryCreate(ctx context.Context, d *schema.ResourceData,
815815 return diag .FromErr (err )
816816 }
817817
818- if diags := setRepositoryFieldsFromRepo (ctx , d , client , owner , finalRepo ); diags .HasError () {
818+ if diags := setResourceFieldsFromRepo (ctx , d , client , owner , finalRepo ); diags .HasError () {
819819 return diags
820820 }
821821
@@ -858,7 +858,7 @@ func resourceGithubRepositoryRead(ctx context.Context, d *schema.ResourceData, m
858858 return diag .FromErr (err )
859859 }
860860
861- if diags := setRepositoryFieldsFromRepo (ctx , d , client , owner , repo ); diags .HasError () {
861+ if diags := setResourceFieldsFromRepo (ctx , d , client , owner , repo ); diags .HasError () {
862862 return diags
863863 }
864864
@@ -967,7 +967,7 @@ func resourceGithubRepositoryUpdate(ctx context.Context, d *schema.ResourceData,
967967 repo = updatedRepo
968968 }
969969
970- if diags := setRepositoryFieldsFromRepo (ctx , d , client , owner , repo ); diags .HasError () {
970+ if diags := setResourceFieldsFromRepo (ctx , d , client , owner , repo ); diags .HasError () {
971971 return diags
972972 }
973973
@@ -1007,11 +1007,10 @@ func resourceGithubRepositoryImport(ctx context.Context, d *schema.ResourceData,
10071007 return []* schema.ResourceData {d }, nil
10081008}
10091009
1010- // setRepositoryFieldsFromRepo populates all Computed and Optional+Computed schema fields
1011- // from a *github.Repository API response. Used by Create and Update to set state directly
1012- // instead of chaining to Read. For fields requiring separate API calls (pages, vulnerability
1013- // alerts), targeted calls are made here.
1014- func setRepositoryFieldsFromRepo (ctx context.Context , d * schema.ResourceData , client * github.Client , owner string , repo * github.Repository ) diag.Diagnostics {
1010+ // setResourceFieldsFromRepo populates all Computed schema fields
1011+ // from a *github.Repository API response.
1012+ // For fields requiring separate API calls (pages, vulnerability alerts), targeted calls are made here.
1013+ func setResourceFieldsFromRepo (ctx context.Context , d * schema.ResourceData , client * github.Client , owner string , repo * github.Repository ) diag.Diagnostics {
10151014 repoName := repo .GetName ()
10161015
10171016 if err := errors .Join (
@@ -1093,7 +1092,6 @@ func setRepositoryFieldsFromRepo(ctx context.Context, d *schema.ResourceData, cl
10931092 }
10941093 }
10951094
1096- // Pages (requires separate API call for computed fields like url, status)
10971095 if repo .GetHasPages () {
10981096 pages , _ , err := client .Repositories .GetPagesInfo (ctx , owner , repoName )
10991097 if err != nil {
@@ -1104,7 +1102,6 @@ func setRepositoryFieldsFromRepo(ctx context.Context, d *schema.ResourceData, cl
11041102 }
11051103 }
11061104
1107- // Security and analysis + vulnerability alerts (requires separate API call)
11081105 if repo .GetSecurityAndAnalysis () != nil {
11091106 vulnerabilityAlerts , _ , err := client .Repositories .GetVulnerabilityAlerts (ctx , owner , repoName )
11101107 if err != nil {
0 commit comments