-
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
azurerm_search_service
- upgrade search service API to version 2023-11-01
and expose semantic_search_sku
field
#23698
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 @WodansSon
Thanks for this PR - I've taken a look through and left a few comments inline, mostly to make use of the None pattern for this field - but if we can update this to account for that, then this otherwise LGTM 👍
Thanks!
Default: services.SearchSemanticSearchDisabled, | ||
ValidateFunc: validation.StringInSlice([]string{ | ||
string(services.SearchSemanticSearchDisabled), |
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 should treat disabled
as a None value - meaning we can remove this default and the possible value here:
Default: services.SearchSemanticSearchDisabled, | |
ValidateFunc: validation.StringInSlice([]string{ | |
string(services.SearchSemanticSearchDisabled), | |
ValidateFunc: validation.StringInSlice([]string{ |
In favour of this field being empty/unset when null
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.
Fixed.
@@ -233,6 +245,11 @@ func resourceSearchServiceCreate(d *pluginsdk.ResourceData, meta interface{}) er | |||
return fmt.Errorf("%q SKUs in %q mode can have a maximum of 3 partitions, got %d", string(services.SkuNameStandardThree), string(services.HostingModeHighDensity), partitionCount) | |||
} | |||
|
|||
// NOTE: Semantic Search SKU cannot be set if the SKU is 'free' | |||
if skuName == services.SkuNameFree && semanticSearchSku != string(services.SearchSemanticSearchDisabled) { | |||
return fmt.Errorf("'semantic_search_sku' can only be set to %q if the 'sku' field is set to %q, got %q", string(services.SearchSemanticSearchDisabled), string(services.SkuNameFree), semanticSearchSku) |
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.
which allows this to become:
return fmt.Errorf("'semantic_search_sku' can only be set to %q if the 'sku' field is set to %q, got %q", string(services.SearchSemanticSearchDisabled), string(services.SkuNameFree), semanticSearchSku) | |
return fmt.Errorf("`semantic_search_sku` can only be specified when `sku` is not set to %q string(services.SkuNameFree) |
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.
Fixed.
@@ -281,6 +298,7 @@ func resourceSearchServiceCreate(d *pluginsdk.ResourceData, meta interface{}) er | |||
DisableLocalAuth: pointer.To(!localAuthenticationEnabled), | |||
PartitionCount: pointer.To(partitionCount), | |||
ReplicaCount: pointer.To(replicaCount), | |||
SemanticSearch: pointer.To(services.SearchSemanticSearch(semanticSearchSku)), |
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.
in this case can we conditionally assign this field depending on whether it's != ""
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.
Fixed.
@@ -209,6 +220,7 @@ func resourceSearchServiceCreate(d *pluginsdk.ResourceData, meta interface{}) er | |||
cmkEnforcementEnabled := d.Get("customer_managed_key_enforcement_enabled").(bool) | |||
localAuthenticationEnabled := d.Get("local_authentication_enabled").(bool) | |||
authenticationFailureMode := d.Get("authentication_failure_mode").(string) | |||
semanticSearchSku := d.Get("semantic_search_sku").(string) |
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 field is Optional, we can then default this here:
semanticSearchSku := d.Get("semantic_search_sku").(string) | |
semanticSearchSku := services.SearchSemanticSearchDisabled | |
if v := d.Get("semantic_search_sku").(string); v != "" { | |
semanticSearchSku = services.SearchSemanticSearch(v) | |
} |
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.
Fixed.
semanticSearchSku := d.Get("semantic_search_sku").(string) | ||
|
||
// NOTE: Semantic Search SKU cannot be set if the SKU is 'free' | ||
if pointer.From(model.Sku.Name) == services.SkuNameFree && semanticSearchSku != string(services.SearchSemanticSearchDisabled) { | ||
return fmt.Errorf("'semantic_search_sku' can only be set to %q if the 'sku' field is set to %q, got %q", string(services.SearchSemanticSearchDisabled), string(services.SkuNameFree), semanticSearchSku) | ||
} | ||
|
||
model.Properties.SemanticSearch = pointer.To(services.SearchSemanticSearch(semanticSearchSku)) |
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.
Which means this can become:
semanticSearchSku := d.Get("semantic_search_sku").(string) | |
// NOTE: Semantic Search SKU cannot be set if the SKU is 'free' | |
if pointer.From(model.Sku.Name) == services.SkuNameFree && semanticSearchSku != string(services.SearchSemanticSearchDisabled) { | |
return fmt.Errorf("'semantic_search_sku' can only be set to %q if the 'sku' field is set to %q, got %q", string(services.SearchSemanticSearchDisabled), string(services.SkuNameFree), semanticSearchSku) | |
} | |
model.Properties.SemanticSearch = pointer.To(services.SearchSemanticSearch(semanticSearchSku)) | |
semanticSearchSku := services.SearchSemanticSearchDisabled | |
if v := d.Get("semantic_search_sku").(string); v != "" { | |
semanticSearchSku = services.SearchSemanticSearch(v) | |
} | |
// NOTE: Semantic Search SKU cannot be set if the SKU is 'free' | |
if pointer.From(model.Sku.Name) == services.SkuNameFree && semanticSearchSku != services.SearchSemanticSearchDisabled { | |
return fmt.Errorf("`semantic_search_sku` can only be specified when `sku` is not set to %q string(services.SkuNameFree) | |
} | |
model.Properties.SemanticSearch = pointer.To(semanticSearchSku) |
To allow this property to be removed/marked as null
in the configuration to remove this field
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.
Fixed.
@@ -233,6 +245,11 @@ func resourceSearchServiceCreate(d *pluginsdk.ResourceData, meta interface{}) er | |||
return fmt.Errorf("%q SKUs in %q mode can have a maximum of 3 partitions, got %d", string(services.SkuNameStandardThree), string(services.HostingModeHighDensity), partitionCount) | |||
} | |||
|
|||
// NOTE: Semantic Search SKU cannot be set if the SKU is 'free' | |||
if skuName == services.SkuNameFree && semanticSearchSku != string(services.SearchSemanticSearchDisabled) { |
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.
which would mean we don't need to cast this one:
if skuName == services.SkuNameFree && semanticSearchSku != string(services.SearchSemanticSearchDisabled) { | |
if skuName == services.SkuNameFree && semanticSearchSku != services.SearchSemanticSearchDisabled { |
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.
Fixed.
if props.SemanticSearch != nil { | ||
semanticSearchSku = string(pointer.From(props.SemanticSearch)) | ||
} |
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.
to map the None behaviour this can become:
if props.SemanticSearch != nil { | |
semanticSearchSku = string(pointer.From(props.SemanticSearch)) | |
} | |
semanticSearchSku := "" | |
if props.SemanticSearch != nil && pointer.From(props.SemanticSearch) != services.SearchSemanticSearchDisabled { | |
semanticSearchSku = string(pointer.From(props.SemanticSearch)) | |
} |
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.
Fixed.
@@ -108,6 +108,10 @@ The following arguments are supported: | |||
|
|||
* `replica_count` - (Optional) Specifies the number of Replica's which should be created for this Search Service. This field cannot be set when using a `free` sku ([see the Microsoft documentation](https://learn.microsoft.com/azure/search/search-sku-tier)). | |||
|
|||
* `semantic_search_sku` - (Optional) The Semantic Search SKU which should be used for this Search Service. Possible values include `disabled`, `free` and `standard`. Defaults to `disabled`. |
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.
Updated to remove the disabled
value, but typically these are prefixed with Specifies
:
* `semantic_search_sku` - (Optional) The Semantic Search SKU which should be used for this Search Service. Possible values include `disabled`, `free` and `standard`. Defaults to `disabled`. | |
* `semantic_search_sku` - (Optional) Specifies the Semantic Search SKU which should be used for this Search Service. Possible values include `free` and `standard`. |
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.
Fixed.
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 🔎
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. |
No description provided.