-
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
New Resource: azurerm_hybrid_compute_machine_extension
#21027
Conversation
…xtensions in different order
# Conflicts: # internal/services/hybridcompute/client/client.go # vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hybridcompute/2022-11-10/machineextensions/id_extension.go # vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hybridcompute/2022-11-10/machineextensions/id_machine.go # vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hybridcompute/2022-11-10/machineextensions/predicates.go # vendor/modules.txt
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.
Thanks for this @liuwuliuyun - I've left a couple of minor comments here for you to consider.
Also, given that this is known as "Azure Arc" in the portal, we think it might make more sense to rename this along those same lines - azurerm_arc_machine_extension
perhaps? This would also involve renaming the corresponding datasource too. Thanks!
internal/services/hybridcompute/hybrid_compute_machine_extension_resource_test.go
Outdated
Show resolved
Hide resolved
internal/services/hybridcompute/hybrid_compute_machine_extension_resource.go
Outdated
Show resolved
Hide resolved
internal/services/hybridcompute/hybrid_compute_machine_extension_resource.go
Outdated
Show resolved
Hide resolved
…on_resource_test.go Co-authored-by: catriona-m <[email protected]>
func (r HybridComputeMachineDataSource) ResourceType() string { | ||
return "azurerm_hybrid_compute_machine" | ||
func (r ArcMachineDataSource) ResourceType() string { | ||
return "azurerm_arc_machine" |
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.
This is a breaking change, we'd need to add a new data source with the correct name and deprecate this one.
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.
Should I just change this name back? Since this RP is named hybridcompute, why dont we just call it hybrid_compute_machine and hybrid_compute_machine_extension. Which I believe make more sense than "arc_machine" for any new users. Plus, it will not cause a breaking change.
"code": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"display_status": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"level": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"message": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"time": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, |
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.
Is it possible to have multiple statuses? These properties can probably be flattened and moved up a level
"type": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, |
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.
Same comment regarding the field type
we do not usually expose these fields.
model := resp.Model | ||
if model == nil { | ||
return fmt.Errorf("retrieving %s: model was nil", id) | ||
} |
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.
We don't need to return an error if Model is nil (same applies to Properties) and for readability we assign it to a variable
model := resp.Model | |
if model == nil { | |
return fmt.Errorf("retrieving %s: model was nil", id) | |
} | |
if model := resp.Model; model != nil { | |
... | |
if props := model.Properties; props != nil { | |
... | |
func (r HybridComputeMachineExtensionResource) complete(data acceptance.TestData, template string) string { | ||
return fmt.Sprintf(` | ||
%s | ||
|
||
resource "azurerm_arc_machine_extension" "test" { | ||
name = "acctest-hcme-%d" | ||
arc_machine_id = data.azurerm_arc_machine.test.id | ||
location = "%s" | ||
automatic_upgrade_enabled = false | ||
publisher = "Microsoft.Azure.Monitor" | ||
type = "AzureMonitorLinuxAgent" | ||
type_handler_version = "1.24" | ||
} | ||
`, template, data.RandomInteger, data.Locations.Primary) | ||
} |
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.
It looks like this config is missing a fair few properties for it to be complete?
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.
Let me add settings and protected settings example to complete config.
func (r HybridComputeMachineExtensionResource) template(data acceptance.TestData) string { | ||
d := HybridComputeMachineDataSource{} | ||
clientSecret := os.Getenv("ARM_CLIENT_SECRET") | ||
randomUUID, _ := uuid.GenerateUUID() | ||
password := generateRandomPassword(10) | ||
return d.basic(data, clientSecret, randomUUID, password) | ||
} |
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.
For consistency the template should exist within the resource's tests and be referenced by the data source tests, not the other way around.
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.
Ok, Let me change this.
@stephybun @catriona-m what do you guys think of the naming of resources in the resource provider? Currently we have two options.
|
@liuwuliuyun - the commercial product name which is user facing and carries more weight than the resource provider's name is Azure Arc (for future reference the words It's better to fix these now to set the correct precedent. |
Ok, let me start working on that. |
Close this PR due to pending completion name change on the exsiting resources. Will open a new one. |
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. |
New Resource:
azurerm_hybrid_compute_machine_extension
Swagger: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-11-10/HybridCompute.json
Testing evidence will be provided after TC run completes.