Skip to content

Commit 7cb06fa

Browse files
committed
Make the linter happy
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
1 parent 2598ebe commit 7cb06fa

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

github/resource_github_repository_file_migration.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,19 @@ func resourceGithubRepositoryFileStateUpgradeV0(ctx context.Context, rawState ma
105105

106106
rawState["repository_id"] = int(repo.GetID())
107107

108+
branch, ok := rawState["branch"].(string)
108109
// If branch is missing or empty, fetch the default branch from the repository
109-
if branch, ok := rawState["branch"].(string); !ok || branch == "" {
110-
rawState["branch"] = repo.GetDefaultBranch()
110+
if !ok || branch == "" {
111+
branch = repo.GetDefaultBranch()
112+
rawState["branch"] = branch
111113
}
112114

113-
newResourceID, err := buildID(rawState["repository"].(string), escapeIDPart(rawState["file"].(string)), rawState["branch"].(string))
115+
filePath, ok := rawState["file"].(string)
116+
if !ok {
117+
return nil, fmt.Errorf("state upgrade v0: file path is not a string")
118+
}
119+
120+
newResourceID, err := buildID(repoName, escapeIDPart(filePath), branch)
114121
if err != nil {
115122
return nil, fmt.Errorf("state upgrade v0: failed to build ID: %w", err)
116123
}

0 commit comments

Comments
 (0)