[BUG]: fix github repository file id escaping#3415
Conversation
|
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with |
stevehipwell
left a comment
There was a problem hiding this comment.
Have we tested this doesn't break existing IDs? It looks OK, but worth checking. Also should we add this to the next minor release milestone as we can always cherry pick it into a patch if required?
65ea3b4 to
2598ebe
Compare
|
@stevehipwell Thanks for asking, I ran v6.11.0 locally and then tried to run this code: same failure, since it was already the v0 migration that was failing! |
|
I think we should release this as a patch, considering that the changes in v6.11.1 are blocking upgrading for anyone with colons in |
|
@deiga do you want to rebase this and then we can get it merged in. Once it's been merged we can decide if we want to cherry pick it onto a patch branch. |
| direct { | ||
| exclude = ["registry.terraform.io/hashicorp/github"] | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Could we fix the EOF?
There was a problem hiding this comment.
Actually should this file even be in this PR?
There was a problem hiding this comment.
No, it's not directly related. It's a Scout Rule thing, since I used the example to verify the changes and noticed that the config file didn't work as we had it
|
|
||
| rawState["repository_id"] = int(repo.GetID()) | ||
|
|
||
| branch, ok := rawState["branch"].(string) |
There was a problem hiding this comment.
Is there a reason this has been changed from a single line?
There was a problem hiding this comment.
forcetypeassert linter bit it :)
There was a problem hiding this comment.
I'm not sure I follow why, the code is identical as there isn't a new check for the map lookup (which could be nested single lines anyway).
There was a problem hiding this comment.
In this commit I needed to touch that line, which caused it to be checked by make lintcheck-new
And since we didn't use forcetypeassert when that migration was originally created: it had a lot to complain about
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
…capred ID parts Signed-off-by: Timo Sand <timo.sand@f-secure.com>
- We want to ensure that users never accidentally get `hashicorp/github` - `~/` failed to expand on macOS Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
7cb06fa to
8f0bfe8
Compare
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
| branch, ok := rawState["branch"].(string) | ||
| // If branch is missing or empty, fetch the default branch from the repository | ||
| if branch, ok := rawState["branch"].(string); !ok || branch == "" { | ||
| rawState["branch"] = repo.GetDefaultBranch() | ||
| if !ok || branch == "" { | ||
| branch = repo.GetDefaultBranch() | ||
| rawState["branch"] = branch | ||
| } | ||
|
|
||
| newResourceID, err := buildID(rawState["repository"].(string), rawState["file"].(string), rawState["branch"].(string)) | ||
| filePath, ok := rawState["file"].(string) | ||
| if !ok { | ||
| return nil, fmt.Errorf("state upgrade v0: file path is not a string") | ||
| } |
There was a problem hiding this comment.
| branch, ok := rawState["branch"].(string) | |
| // If branch is missing or empty, fetch the default branch from the repository | |
| if branch, ok := rawState["branch"].(string); !ok || branch == "" { | |
| rawState["branch"] = repo.GetDefaultBranch() | |
| if !ok || branch == "" { | |
| branch = repo.GetDefaultBranch() | |
| rawState["branch"] = branch | |
| } | |
| newResourceID, err := buildID(rawState["repository"].(string), rawState["file"].(string), rawState["branch"].(string)) | |
| filePath, ok := rawState["file"].(string) | |
| if !ok { | |
| return nil, fmt.Errorf("state upgrade v0: file path is not a string") | |
| } | |
| branchSet := false | |
| if v, ok := rawState["branch"]; ok { | |
| if _, ok := v.(string); ok || s != "" { | |
| branchSet = true | |
| } | |
| } | |
| if !branchSet { | |
| rawState["branch"] = repo.GetDefaultBranch() | |
| } | |
| pathSet := false | |
| if v, ok := rawState["file"]; ok { | |
| if _, ok := v.(string); ok { | |
| pathSet = true | |
| } | |
| } | |
| if !pathSet { | |
| return nil, fmt.Errorf("state upgrade v0: file path is not a string") | |
| } |
This would be my prefered pattern here, otherwise we're still masking a conversion.
Resolves #3335
Before the change?
filePathingithub_repository_resourcecontained a colongithub_repository_file#3175 when I changed the ID generation codeAfter the change?
filePathingithub_repository_resourcecontains a colonPull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!