-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: using New{Resource}ID
rather than instantiating the Resource ID types
#25354
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple of minor comments, but otherwise LGTM!
@@ -4,6 +4,7 @@ | |||
package parse | |||
|
|||
import ( | |||
"github.com/hashicorp/go-azure-helpers/lang/pointer" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imports need sorted here
@@ -4,6 +4,7 @@ | |||
package parse | |||
|
|||
import ( | |||
"github.com/hashicorp/go-azure-helpers/lang/pointer" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imports here
} | ||
storageCfg, err := storageCfgsClient.Get(ctx, storageId) | ||
if err != nil { | ||
return fmt.Errorf("reading Recovery Service storage Cfg %s: %+v", id.String(), err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Errorf("reading Recovery Service storage Cfg %s: %+v", id.String(), err) | |
return fmt.Errorf("reading Recovery Service storage Cfg %s: %+v", id, err) |
This PR is being labeled as "stale" because it has not been updated for 30 or more days. If this PR is still valid, please remove the "stale" label. If this PR is blocked, please add it to the "Blocked" milestone. If you need some help completing this PR, please leave a comment letting us know. Thank you! |
We should be using `example.NewExampleID(` rather than `example.ExampleId{` to instantiate Resource IDs Whilst that might seem pedantic, it means that should a new field be added to `ExampleId` we'd get a compile-time failure when using the `New` function which would mean we'd identify the missing field, whereas instantiating the struct would mean these would get the default (empty) value - leading to incorrect details. It's minor, but worthwhile from a consistency perspective
ebea7e4
to
6528910
Compare
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Community Note
Description
We should be using
example.NewExampleID(
rather thanexample.ExampleId{
to instantiate Resource IDsWhilst that might seem pedantic, it means that should a new field be added to
ExampleId
we'd get a compile-time failure when using theNew
function which would mean we'd identify the missing field, whereas instantiating the struct would mean these would get the default (empty) value - leading to incorrect details.It's minor, but worthwhile from a consistency perspective