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_hdinsight_cluster_pool
#25937
base: main
Are you sure you want to change the base?
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.
@jiaweitao001, thanks for opening the PR. It mostly looks good however I have left a couple of suggestions and a question or two that I would like clarification on. If we get those straightened out we can move the PR to the next step. 🚀
Required: true, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"cluster_pool_version": { |
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.
Since the parent field is already called cluster_pool_profile
, would it make sense to shorten the name of the child element name to just version
to avoid redundancy?
"cluster_pool_version": { | |
"version": { |
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.
Will change.
Optional: true, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"log_analytics_profile_enabled": { |
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 here, since the parent is called log_analytics_profile
we can assume the the child fields refer to it so the prefix of this field name seems not needed, what do you think?
"log_analytics_profile_enabled": { | |
"enabled": { |
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.
Will change.
ValidateFunc: commonids.ValidateSubnetID, | ||
}, | ||
|
||
"private_api_server_enabled": { |
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.
The name of the field is confusing, is this referring to a private link?
"private_api_server_enabled": { | |
"private_link_enabled": { |
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.
Will change.
return fmt.Errorf("reading %s: %+v", *id, err) | ||
} | ||
|
||
model := existing.Model |
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.
Shouldn't we check to see if the model is nil before we start accessing it's members?
model := existing.Model | |
model := existing.Model | |
if model == nil { | |
return fmt.Errorf("%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.
Will change.
} | ||
|
||
func expandComputeProfile(profiles []ComputeProfile) hdinsights.ClusterPoolComputeProfile { | ||
result := hdinsights.ClusterPoolComputeProfile{ | ||
VMSize: profiles[0].VmSize, | ||
} | ||
return result | ||
} | ||
|
||
func expandLogAnalyticsProfile(profiles []LogAnalyticsProfile) *hdinsights.ClusterPoolLogAnalyticsProfile { | ||
if len(profiles) == 0 { | ||
return nil | ||
} | ||
|
||
result := hdinsights.ClusterPoolLogAnalyticsProfile{ | ||
Enabled: profiles[0].LogAnalyticsProfileEnabled, | ||
WorkspaceId: pointer.To(profiles[0].WorkspaceId), | ||
} | ||
return &result | ||
} | ||
|
||
func expandNetworkProfile(profiles []NetworkProfile) *hdinsights.ClusterPoolNetworkProfile { | ||
if len(profiles) == 0 { | ||
return nil | ||
} | ||
|
||
result := hdinsights.ClusterPoolNetworkProfile{ | ||
SubnetId: profiles[0].SubnetId, | ||
} | ||
|
||
if profiles[0].PrivateApiServerEnabled { | ||
result.EnablePrivateApiServer = pointer.To(true) | ||
} | ||
|
||
if profiles[0].OutboundType != "" { | ||
result.OutboundType = pointer.To(hdinsights.OutboundType(profiles[0].OutboundType)) | ||
} | ||
return &result | ||
} | ||
|
||
func flattenClusterPoolProfile(input *hdinsights.ClusterPoolProfile) []ClusterPoolProfile { | ||
result := make([]ClusterPoolProfile, 0) | ||
if input == nil { | ||
return result | ||
} | ||
|
||
profile := ClusterPoolProfile{ | ||
ClusterPoolVersion: input.ClusterPoolVersion, | ||
} | ||
result = append(result, profile) | ||
|
||
return result | ||
} | ||
|
||
func flattenComputeProfile(input hdinsights.ClusterPoolComputeProfile) []ComputeProfile { | ||
result := make([]ComputeProfile, 0) | ||
profile := ComputeProfile{ | ||
VmSize: input.VMSize, | ||
} | ||
result = append(result, profile) | ||
|
||
return result | ||
} | ||
|
||
func flattenLogAnalyticsProfile(input *hdinsights.ClusterPoolLogAnalyticsProfile) []LogAnalyticsProfile { | ||
result := make([]LogAnalyticsProfile, 0) | ||
if input == nil { | ||
return result | ||
} | ||
|
||
profile := LogAnalyticsProfile{ | ||
LogAnalyticsProfileEnabled: input.Enabled, | ||
WorkspaceId: pointer.From(input.WorkspaceId), | ||
} | ||
result = append(result, profile) | ||
|
||
return result | ||
} | ||
|
||
func flattenNetworkProfile(input *hdinsights.ClusterPoolNetworkProfile) []NetworkProfile { | ||
result := make([]NetworkProfile, 0) | ||
if input == nil { | ||
return result | ||
} | ||
|
||
profile := NetworkProfile{ | ||
SubnetId: input.SubnetId, | ||
} | ||
|
||
if input.EnablePrivateApiServer != nil { | ||
profile.PrivateApiServerEnabled = *input.EnablePrivateApiServer | ||
} | ||
|
||
if input.OutboundType != nil { | ||
profile.OutboundType = string(*input.OutboundType) | ||
} | ||
result = append(result, profile) | ||
|
||
return result | ||
} |
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.
I am confused, why are all of these fields lists when all of the expand and flatten functions are not looping over multiple values, they are only looking at the 0 index?
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's because only one set of profile is allowed for them.
"cluster_pool_profile": { | ||
Type: pluginsdk.TypeList, | ||
Required: 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.
Shouldn't this have a MaxItems
property defined for the list?
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.
Sure.
"log_analytics_profile": { | ||
Type: pluginsdk.TypeList, | ||
Optional: 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 here, Shouldn't this have a MaxItems
property defined for the list?
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.
Sure.
"network_profile": { | ||
Type: pluginsdk.TypeList, | ||
Optional: 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.
and here as well, shouldn't this have a MaxItems
property defined for the list?
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.
Sure.
Community Note
Description
Add support for
azurerm_hdinsight_cluster_pool
.PR Checklist
For example: “
resource_name_here
- description of change e.g. adding propertynew_property_name_here
”Changes to existing Resource / Data Source
Testing
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_hdinsight_cluster_pool
This is a (please select all that apply):
Related Issue(s)
Fixes #0000
Note
If this PR changes meaningfully during the course of review please update the title and description as required.