@@ -5,12 +5,13 @@ import (
55
66 "github.com/google/go-github/v83/github"
77
8+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
89 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
910)
1011
1112func dataSourceGithubActionsOrganizationSecrets () * schema.Resource {
1213 return & schema.Resource {
13- Read : dataSourceGithubActionsOrganizationSecretsRead ,
14+ ReadContext : dataSourceGithubActionsOrganizationSecretsRead ,
1415
1516 Schema : map [string ]* schema.Schema {
1617 "secrets" : {
@@ -41,20 +42,19 @@ func dataSourceGithubActionsOrganizationSecrets() *schema.Resource {
4142 }
4243}
4344
44- func dataSourceGithubActionsOrganizationSecretsRead (d * schema.ResourceData , meta any ) error {
45- ctx := context .Background ()
45+ func dataSourceGithubActionsOrganizationSecretsRead (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
4646 client := meta .(* Owner ).v3client
4747 owner := meta .(* Owner ).name
4848
4949 options := github.ListOptions {
5050 PerPage : 100 ,
5151 }
5252
53- var all_secrets []map [string ]string
53+ var allSecrets []map [string ]string
5454 for {
5555 secrets , resp , err := client .Actions .ListOrgSecrets (ctx , owner , & options )
5656 if err != nil {
57- return err
57+ return diag . FromErr ( err )
5858 }
5959 for _ , secret := range secrets .Secrets {
6060 new_secret := map [string ]string {
@@ -63,7 +63,7 @@ func dataSourceGithubActionsOrganizationSecretsRead(d *schema.ResourceData, meta
6363 "updated_at" : secret .UpdatedAt .String (),
6464 "visibility" : secret .Visibility ,
6565 }
66- all_secrets = append (all_secrets , new_secret )
66+ allSecrets = append (allSecrets , new_secret )
6767
6868 }
6969 if resp .NextPage == 0 {
@@ -73,9 +73,9 @@ func dataSourceGithubActionsOrganizationSecretsRead(d *schema.ResourceData, meta
7373 }
7474
7575 d .SetId (owner )
76- err := d .Set ("secrets" , all_secrets )
76+ err := d .Set ("secrets" , allSecrets )
7777 if err != nil {
78- return err
78+ return diag . FromErr ( err )
7979 }
8080
8181 return nil
0 commit comments