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

New resource: azurerm_mssql_job_target_group #28492

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

sreallymatt
Copy link
Collaborator

@sreallymatt sreallymatt commented Jan 13, 2025

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

Added new resource azurerm_mssql_job_target_group

E: will resolve conflicts after review

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)
image

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

internal/services/mssql/mssql_job_target_group_resource.go Outdated Show resolved Hide resolved
internal/services/mssql/mssql_job_target_group_resource.go Outdated Show resolved Hide resolved
internal/services/mssql/mssql_job_target_group_resource.go Outdated Show resolved Hide resolved
Comment on lines 286 to 299
switch v.Type {
case string(jobtargetgroups.JobTargetTypeSqlDatabase):
if v.DatabaseName == "" {
return nil, fmt.Errorf("`database_name` is required when `type` is `%s`", jobtargetgroups.JobTargetTypeSqlDatabase)
}

t.DatabaseName = pointer.To(v.DatabaseName)
case string(jobtargetgroups.JobTargetTypeSqlElasticPool):
if v.ElasticPoolName == "" {
return nil, fmt.Errorf("`elastic_pool_name` is required when `type` is `%s`", jobtargetgroups.JobTargetTypeSqlElasticPool)
}

t.ElasticPoolName = pointer.To(v.ElasticPoolName)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the logic here I'm wondering whether it makes sense to not expose the type property and to hardcode it for users e.g.

  • If only server_name is supplied, type is set to server
  • If server_name and database_name are supplied, we set type to database
  • If server_name and elastic_pool_name are supplied, we set type to elastic pool

Might make the validation on line 278-284 tricky, but just a thought.

Furthermore I think there is some validation here that we can move into the schema or add to prevent misconfiguration:

  • Only one of database_name or elastic_pool_name can be specified (not both together) so we may want to add the ConflictsWith attribute on those in the schema
  • It appears job_credential_id is required if the type is either server or elastic pool, so we could take advantage of the RequiredWith attribute (though this one might not be as simple as I initially thought given it also depends on the value of membership_type 🙈)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, unfortunately I can't use ConflictsWith and RequiredWith, though I have moved the validation into a CustomizeDiff so it's caught during the plan.

The job_target.type argument is now set by the provider and is no longer a configurable argument.

website/docs/r/mssql_job_target_group.html.markdown Outdated Show resolved Hide resolved
@sreallymatt
Copy link
Collaborator Author

sreallymatt commented Jan 29, 2025

Tests still pass:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants