Skip to content
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

Merged
merged 2 commits into from
Apr 22, 2024

Conversation

tombuildsstuff
Copy link
Contributor

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave "+1" or "me too" comments, they generate extra noise for PR followers and do not help prioritize for review

Description

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

Copy link
Member

@catriona-m catriona-m left a 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"
Copy link
Member

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"
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

Copy link

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!

tombuildsstuff and others added 2 commits April 22, 2024 09:44
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
@stephybun stephybun force-pushed the b/resource-id-creation branch from ebea7e4 to 6528910 Compare April 22, 2024 07:51
@stephybun stephybun merged commit a7dfd9c into main Apr 22, 2024
29 checks passed
@stephybun stephybun deleted the b/resource-id-creation branch April 22, 2024 08:24
@github-actions github-actions bot added this to the v3.101.0 milestone Apr 22, 2024
Copy link

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants