@@ -59,13 +59,25 @@ func resourceGithubBranchDefault() *schema.Resource {
5959}
6060
6161func resourceGithubBranchDefaultCreate (ctx context.Context , d * schema.ResourceData , m any ) diag.Diagnostics {
62- meta := m .(* Owner )
62+ meta , ok := m .(* Owner )
63+ if ! ok {
64+ return diag .FromErr (errors .New ("unexpected meta type, expected *Owner" ))
65+ }
6366 client := meta .v3client
6467 owner := meta .name
6568
66- repoName := d .Get ("repository" ).(string )
67- defaultBranch := d .Get ("branch" ).(string )
68- rename := d .Get ("rename" ).(bool )
69+ repoName , ok := d .Get ("repository" ).(string )
70+ if ! ok {
71+ return diag .FromErr (errors .New ("repository must be a string" ))
72+ }
73+ defaultBranch , ok := d .Get ("branch" ).(string )
74+ if ! ok {
75+ return diag .FromErr (errors .New ("branch must be a string" ))
76+ }
77+ rename , ok := d .Get ("rename" ).(bool )
78+ if ! ok {
79+ return diag .FromErr (errors .New ("rename must be a boolean" ))
80+ }
6981
7082 tflog .Trace (ctx , "Creating default branch resource" , map [string ]any {
7183 "owner" : owner ,
@@ -121,11 +133,17 @@ func resourceGithubBranchDefaultCreate(ctx context.Context, d *schema.ResourceDa
121133
122134func resourceGithubBranchDefaultRead (ctx context.Context , d * schema.ResourceData , m any ) diag.Diagnostics {
123135 ctx = tflog .SetField (ctx , "resource_id" , d .Id ())
124- meta := m .(* Owner )
136+ meta , ok := m .(* Owner )
137+ if ! ok {
138+ return diag .FromErr (errors .New ("unexpected meta type, expected *Owner" ))
139+ }
125140 client := meta .v3client
126141 owner := meta .name
127142
128- repoName := d .Get ("repository" ).(string )
143+ repoName , ok := d .Get ("repository" ).(string )
144+ if ! ok {
145+ return diag .FromErr (errors .New ("repository must be a string" ))
146+ }
129147
130148 tflog .Trace (ctx , "Reading default branch resource" , map [string ]any {
131149 "owner" : owner ,
@@ -180,13 +198,25 @@ func resourceGithubBranchDefaultRead(ctx context.Context, d *schema.ResourceData
180198
181199func resourceGithubBranchDefaultUpdate (ctx context.Context , d * schema.ResourceData , m any ) diag.Diagnostics {
182200 ctx = tflog .SetField (ctx , "resource_id" , d .Id ())
183- meta := m .(* Owner )
201+ meta , ok := m .(* Owner )
202+ if ! ok {
203+ return diag .FromErr (errors .New ("unexpected meta type, expected *Owner" ))
204+ }
184205 client := meta .v3client
185206 owner := meta .name
186207
187- repoName := d .Get ("repository" ).(string )
188- defaultBranch := d .Get ("branch" ).(string )
189- rename := d .Get ("rename" ).(bool )
208+ repoName , ok := d .Get ("repository" ).(string )
209+ if ! ok {
210+ return diag .FromErr (errors .New ("repository must be a string" ))
211+ }
212+ defaultBranch , ok := d .Get ("branch" ).(string )
213+ if ! ok {
214+ return diag .FromErr (errors .New ("branch must be a string" ))
215+ }
216+ rename , ok := d .Get ("rename" ).(bool )
217+ if ! ok {
218+ return diag .FromErr (errors .New ("rename must be a boolean" ))
219+ }
190220
191221 tflog .Trace (ctx , "Updating default branch resource" , map [string ]any {
192222 "owner" : owner ,
@@ -229,10 +259,16 @@ func resourceGithubBranchDefaultUpdate(ctx context.Context, d *schema.ResourceDa
229259
230260func resourceGithubBranchDefaultDelete (ctx context.Context , d * schema.ResourceData , m any ) diag.Diagnostics {
231261 ctx = tflog .SetField (ctx , "resource_id" , d .Id ())
232- meta := m .(* Owner )
262+ meta , ok := m .(* Owner )
263+ if ! ok {
264+ return diag .FromErr (errors .New ("unexpected meta type, expected *Owner" ))
265+ }
233266 client := meta .v3client
234267 owner := meta .name
235- repoName := d .Get ("repository" ).(string )
268+ repoName , ok := d .Get ("repository" ).(string )
269+ if ! ok {
270+ return diag .FromErr (errors .New ("repository must be a string" ))
271+ }
236272
237273 tflog .Trace (ctx , "Deleting default branch resource" , map [string ]any {
238274 "owner" : owner ,
0 commit comments