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

azurerm_stream_analytics_function_javascript_udf - support new property is_configuration_parameter #16579

Merged
merged 2 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ func resourceStreamAnalyticsFunctionUDF() *pluginsdk.Resource {
"record",
}, false),
},

"configuration_parameter": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
},
},
},
},
Expand Down Expand Up @@ -242,7 +248,8 @@ func expandStreamAnalyticsFunctionInputs(input []interface{}) *[]streamanalytics
v := raw.(map[string]interface{})
variableType := v["type"].(string)
outputs = append(outputs, streamanalytics.FunctionInput{
DataType: utils.String(variableType),
DataType: utils.String(variableType),
IsConfigurationParameter: utils.Bool(v["configuration_parameter"].(bool)),
})
}

Expand All @@ -262,8 +269,14 @@ func flattenStreamAnalyticsFunctionInputs(input *[]streamanalytics.FunctionInput
variableType = *v.DataType
}

var isConfigurationParameter bool
if v.IsConfigurationParameter != nil {
isConfigurationParameter = *v.IsConfigurationParameter
}

outputs = append(outputs, map[string]interface{}{
"type": variableType,
"type": variableType,
"configuration_parameter": isConfigurationParameter,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,28 @@ func TestAccStreamAnalyticsFunctionJavaScriptUDF_inputs(t *testing.T) {
})
}

func TestAccStreamAnalyticsFunctionJavaScriptUDF_isConfigurationParameter(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_stream_analytics_function_javascript_udf", "test")
r := StreamAnalyticsFunctionJavaScriptUDFResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.isConfigurationParameter(data, true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.isConfigurationParameter(data, false),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func (r StreamAnalyticsFunctionJavaScriptUDFResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := parse.FunctionID(state.ID)
if err != nil {
Expand Down Expand Up @@ -166,6 +188,35 @@ SCRIPT
`, template, data.RandomInteger)
}

func (r StreamAnalyticsFunctionJavaScriptUDFResource) isConfigurationParameter(data acceptance.TestData, isConfigurationParameter bool) string {
template := r.template(data)
return fmt.Sprintf(`
%s

resource "azurerm_stream_analytics_function_javascript_udf" "test" {
name = "acctestinput-%d"
stream_analytics_job_name = azurerm_stream_analytics_job.test.name
resource_group_name = azurerm_stream_analytics_job.test.resource_group_name

script = <<SCRIPT
function getRandomNumber(in) {
return in;
}
SCRIPT


input {
type = "bigint"
configuration_parameter = %t
}

output {
type = "bigint"
}
}
`, template, data.RandomInteger, isConfigurationParameter)
}

func (r StreamAnalyticsFunctionJavaScriptUDFResource) template(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ A `input` block supports the following:

* `type` - The Data Type for the Input Argument of this JavaScript Function. Possible values include `array`, `any`, `bigint`, `datetime`, `float`, `nvarchar(max)` and `record`.

* `configuration_parameter` - (Optional) Is this input parameter a configuration parameter? Defaults to `false`.

---

A `output` block supports the following:
Expand Down