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

Add support for 'auto_update' #690

Merged
merged 7 commits into from
Feb 20, 2023
Merged

Conversation

paulkirkwood
Copy link
Contributor

@paulkirkwood paulkirkwood commented Jan 17, 2023

All Submissions:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My code follows the code style of this project.
  • I ran lint checks locally prior to submission.
  • Have you checked to ensure there aren't other open PRs for the same update/change?

What about the current behavior has changed?

Added behaviour to allow the setting of the 'auto_update' attribute within a 'azuredevops_agent_pool' resource.

Issue Number: #688

Does this introduce a change to go.mod, go.sum or vendor/?

  • Yes
  • No

Does this introduce a breaking change?

  • Yes
  • No

@paulkirkwood
Copy link
Contributor Author

paulkirkwood commented Jan 17, 2023

@microsoft-github-policy-service agree company="Vodafone"

Copy link
Collaborator

@xuzhang3 xuzhang3 left a comment

Choose a reason for hiding this comment

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

@paulkirkwood A few change request others look to me.

@xuzhang3 xuzhang3 self-assigned this Feb 15, 2023
Copy link
Collaborator

@xuzhang3 xuzhang3 left a comment

Choose a reason for hiding this comment

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

can we call the update after the create if the auto_update set to false? So that user can initially set it to true or false.

Example code:

func resourceAzureAgentPoolCreate(d *schema.ResourceData, m interface{}) error {
	clients := m.(*client.AggregatedClient)
	agentPool, err := expandAgentPool(d, true)
	if err != nil {
		return fmt.Errorf("Error converting terraform data model to AzDO agentPool reference: %+v", err)
	}

	createdAgentPool, err := createAzureAgentPool(clients, agentPool)
	if err != nil {
		return fmt.Errorf("Error creating agent pool in Azure DevOps: %+v", err)
	}

	if agentPool.AutoUpdate != nil && !*agentPool.AutoUpdate {
		agentPool.Id = createdAgentPool.Id
		createdAgentPool, err = azureAgentPoolUpdate(clients, agentPool)
		if err != nil {
			return fmt.Errorf("Error updating agent pool in Azure DevOps: %+v", err)
		}
	}

	flattenAzureAgentPool(d, createdAgentPool)

	return resourceAzureAgentPoolRead(d, m)
}

@xuzhang3
Copy link
Collaborator

=== RUN   TestAccAgentPool_CreateAndUpdate
=== PAUSE TestAccAgentPool_CreateAndUpdate
=== CONT  TestAccAgentPool_CreateAndUpdate
--- PASS: TestAccAgentPool_CreateAndUpdate (29.91s)
PASS
ok      github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/acceptancetests        36.392s
=== RUN   TestAccAgentPool_DataSource
=== PAUSE TestAccAgentPool_DataSource
=== CONT  TestAccAgentPool_DataSource
--- PASS: TestAccAgentPool_DataSource (23.20s)
PASS
ok      github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/acceptancetests        23.833s
=== RUN   TestAccAgentQueue_DataSource
=== PAUSE TestAccAgentQueue_DataSource
=== CONT  TestAccAgentQueue_DataSource
--- PASS: TestAccAgentQueue_DataSource (40.18s)
PASS
ok      github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/acceptancetests        40.786s
=== RUN   TestAccAgentPools_DataSource
=== PAUSE TestAccAgentPools_DataSource
=== CONT  TestAccAgentPools_DataSource
--- PASS: TestAccAgentPools_DataSource (21.85s)
PASS
ok      github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/acceptancetests        22.378s

@xuzhang3 xuzhang3 merged commit 7d1d91c into microsoft:main Feb 20, 2023
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.

2 participants