-
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 data source azurerm_search_service
#10181
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.
hey @Brunhil
Thanks for this PR :)
I've taken a look through and this is looking good, if we can fix up the comments and linting issues then this should otherwise be good to go 👍
Thanks!
if utils.ResponseWasNotFound(resp.Response) { | ||
log.Printf("[INFO] Error reading Search Service %q - removing from state", d.Id()) | ||
d.SetId("") | ||
return nil |
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 this is a Data Source we should raise an error if this is not found rather than returning nil
here - so could we make this:
return nil | |
return fmt.Errorf("%s was not found", id) |
(the format string for "id" will be "Search Service %q (Resource Group %q)")
{ | ||
Config: r.basic(data), | ||
Check: resource.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).Key("id").Exists(), |
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 can remove this, since otherwise the resource won't be in the state/will raise an error (which'll be hit before this point)
check.That(data.ResourceName).Key("id").Exists(), |
|
||
* `replica_count` - The number of replica's which have been created. | ||
|
||
-> **Note:** `partition_count` and `replica_count` can only be configured when using a `standard` sku. |
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 this is a data source, this isn't configurable - so we can remove this (since the fields should get a default value either way)
-> **Note:** `partition_count` and `replica_count` can only be configured when using a `standard` sku. |
|
||
* `query_keys` - A `query_keys` block as defined below. | ||
|
||
* `public_network_access_enabled` - Whether or not public network access is allowed for this resource. Defaults to `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.
this is a Data Source which is read-only, so the default value doesn't apply here - could we also update the messaging to highlight this isn't configurable:
* `public_network_access_enabled` - Whether or not public network access is allowed for this resource. Defaults to `true`. | |
* `public_network_access_enabled` - Whether or not public network access is enabled for this Search Service. |
|
||
* `identity` - An `identity` block as defined below. | ||
|
||
* `tags` - (Optional) A mapping of tags which should be assigned to the Search Service. |
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.
(as above) since this isn't configurable can we update the wording to highlight that this is read only:
* `tags` - (Optional) A mapping of tags which should be assigned to the Search Service. | |
* `tags` - A mapping of tags which are assigned to the Search Service. |
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 actually set the tags on this data source so I'll just remove this line 😄
|
||
A `identity` block supports the following: | ||
|
||
* `type` - The Type of Identity which should be used for the Search Service. At this time the only possible value is `SystemAssigned`. |
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.
(as above)
* `type` - The Type of Identity which should be used for the Search Service. At this time the only possible value is `SystemAssigned`. | |
* `type` - The type of Managed Identity which used for the Search Service. |
Thanks for the review @tombuildsstuff ! Let me know if there are any other changes you see |
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.
hey @Brunhil
Thanks for pushing those changes - I've taken a look through and left some comments inline but if we can fix those up then this should be good to go 👍
Thanks!
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: 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.
as the linter says, a Data Sources properties can't be ForceNew
- so we can remove this:
ForceNew: true, |
"identity": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
MaxItems: 1, |
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.
as the linter mentions, since this is a Data Source we can remove the max items here, since these are read-only/not user configurable:
MaxItems: 1, |
if err != nil { | ||
if utils.ResponseWasNotFound(resp.Response) { | ||
log.Printf("[INFO] Error reading Search Service %q - removing from state", d.Id()) | ||
d.SetId("") |
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 can remove both of these lines since the error will raise this anyway
id, err := parse.SearchServiceID(d.Id()) | ||
if err != nil { | ||
return 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.
a Data Source won't have an ID at this point, instead it needs to look this up using the name
and resource_group_name
- that said we need to build this up to use it below - so can we make this:
} | |
subscriptionId := meta.(*clients.Client).Account.SubscriptionID | |
id := parse.NewSearchServiceID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) |
} | ||
|
||
d.Set("name", id.Name) | ||
d.Set("resource_group_name", id.ResourceGroup) |
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 user is specifying these, we can remove these and just set the ID instead (which is needed for this to get tracked into the state):
d.Set("resource_group_name", id.ResourceGroup) | |
d.SetID(id.ID()) |
|
||
The following arguments are supported: | ||
|
||
* `name` - (Required) The Name which should be used for this Search Service. Changing this forces a new Search Service to be created. |
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 the data source this will already exist, so we can update the language here:
* `name` - (Required) The Name which should be used for this Search Service. Changing this forces a new Search Service to be created. | |
* `name` - (Required) The Name of the Search Service. |
(since this is a Data Source this also doesn't force a new resource
|
||
* `name` - (Required) The Name which should be used for this Search Service. Changing this forces a new Search Service to be created. | ||
|
||
* `resource_group_name` - (Required) The name of the Resource Group where the Search Service should exist. Changing this forces a new Search Service to be created. |
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)
* `resource_group_name` - (Required) The name of the Resource Group where the Search Service should exist. Changing this forces a new Search Service to be created. | |
* `resource_group_name` - (Required) The name of the Resource Group where the Search Service exists. |
Test is also failing with
|
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.
LGTM - thanks for pushing those changes @Brunhil
azurerm/internal/services/search/search_service_data_source_test.go
Outdated
Show resolved
Hide resolved
…st.go Co-authored-by: Tom Harvey <[email protected]>
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.
Even after committing that change it the test is still failing:
------- Stdout: -------
=== RUN TestAccDataSourceSearchService_basic
=== PAUSE TestAccDataSourceSearchService_basic
=== CONT TestAccDataSourceSearchService_basic
testing.go:684: Step 0 error: Check failed: Check 6/8 error: data.azurerm_search_service.test: Attribute 'identity.0.type' expected to be set
--- FAIL: TestAccDataSourceSearchService_basic (104.58s)
FAIL
Turns out I was missing the |
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.
Aside from one comment this LGTM 👍
azurerm/internal/services/search/search_service_data_source_test.go
Outdated
Show resolved
Hide resolved
This has been released in version 2.45.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example: provider "azurerm" {
version = "~> 2.45.0"
}
# ... other configuration ... |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
Fixes #10153