1
0
Форкнуть 0

Merge branch 'master' into feature/add-serviceendpoint-azuredevops

This commit is contained in:
Dmitry Zhmurko 2020-09-14 14:47:56 +03:00 коммит произвёл GitHub
Родитель 1962f06c53 0c7be7dc48
Коммит 418c44f016
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
58 изменённых файлов: 371 добавлений и 108 удалений

Просмотреть файл

@ -4,7 +4,7 @@ provider "azuredevops" {
}
resource "azuredevops_project" "project" {
project_name = "terraform-provider-azuredevops"
name = "terraform-provider-azuredevops"
description = ""
visibility = "private"
version_control = "Git"

Просмотреть файл

@ -1,10 +1,10 @@
## 0.0.2 (Unreleased)
FEATURES:
* **New Resource** `azuredevops_git_permissions` [#18](https://github.com/microsoft/terraform-provider-azuredevops/issues/18)
* **New Resource** `azuredevops_project_permissions` [#18](https://github.com/microsoft/terraform-provider-azuredevops/issues/18)
* **New Resource** `azuredevops_serviceendpoint_aws` [#58](https://github.com/microsoft/terraform-provider-azuredevops/issues/58)
* **New Resource** `azuredevops_serviceendpoint_devops` [#182](https://github.com/microsoft/terraform-provider-azuredevops/issues/182)
* **New Resource** `azuredevops_git_permissions` [#18](https://github.com/microsoft/terraform-provider-azuredevops/issues/18)
* **New Resource** `azuredevops_project_permissions` [#18](https://github.com/microsoft/terraform-provider-azuredevops/issues/18)
* **New Resource** `azuredevops_serviceendpoint_aws` [#58](https://github.com/microsoft/terraform-provider-azuredevops/issues/58)
* **New Resource** `azuredevops_serviceendpoint_devops` [#182](https://github.com/microsoft/terraform-provider-azuredevops/issues/182)
* **New Resource** `azuredevops_branch_policy_auto_reviewers` [#71](https://github.com/microsoft/terraform-provider-azuredevops/issues/71)
* **New Resource** `azuredevops_workitemquery_permissions` [#79](https://github.com/microsoft/terraform-provider-azuredevops/issues/79)
* **New Resource** `azuredevops_serviceendpoint_azurecr` [#119](https://github.com/microsoft/terraform-provider-azuredevops/issues/119/)
@ -12,27 +12,33 @@ FEATURES:
* **New Resource** `azuredevops_iteration_permissions` [#85](https://github.com/microsoft/terraform-provider-azuredevops/issues/85)
* **New Resource** `azuredevops_branch_policy_work_item_linking` [#144](https://github.com/microsoft/terraform-provider-azuredevops/issues/144)
* **New Resource** `azuredevops_branch_policy_comment_resolution` [#144](https://github.com/microsoft/terraform-provider-azuredevops/issues/144)
* **New Data Resource** `azuredevops_git_repository` [#18](https://github.com/microsoft/terraform-provider-azuredevops/issues/18)
* **New Data Resource** `azuredevops_area` [#85](https://github.com/microsoft/terraform-provider-azuredevops/issues/85)
* **New Data Resource** `azuredevops_iteration` [#85](https://github.com/microsoft/terraform-provider-azuredevops/issues/85)
* **New Data Resource** `azuredevops_git_repository` [#18](https://github.com/microsoft/terraform-provider-azuredevops/issues/18)
* **New Data Resource** `azuredevops_area` [#85](https://github.com/microsoft/terraform-provider-azuredevops/issues/85)
* **New Data Resource** `azuredevops_iteration` [#85](https://github.com/microsoft/terraform-provider-azuredevops/issues/85)
* **New Data Resource** `azuredevops_agent_queue` [#175](https://github.com/microsoft/terraform-provider-azuredevops/issues/175)
IMPROVEMENTS:
* **All resources: Remove from `.state` if project has been deleted** [#25](https://github.com/microsoft/terraform-provider-azuredevops/issues/25)
* **`azuredevops_branch_policy_build_validation`: Add `filename_patterns` support for repository build policy** [#62](https://github.com/microsoft/terraform-provider-azuredevops/issues/62)
* **`azuredevops_git_repository`:
- Use `default_branch` as the name of an initialized branch [#89](https://github.com/microsoft/terraform-provider-azuredevops/pull/89)
* All resources - remove from `.tfstate` if project has been deleted [#25](https://github.com/microsoft/terraform-provider-azuredevops/issues/25)
* Data source `azuredevops_build_definition` - support export `origin` and `origin_id` [#177](https://github.com/microsoft/terraform-provider-azuredevops/issues/177)
* `azuredevops_branch_policy_build_validation` - add `filename_patterns` support for repository build policy [#62](https://github.com/microsoft/terraform-provider-azuredevops/issues/62)
* `azuredevops_git_repository`
- Use `default_branch` as the name of an initialized branch [#89](https://github.com/microsoft/terraform-provider-azuredevops/issues/89)
- Add support for import Git repository [#45](https://github.com/microsoft/terraform-provider-azuredevops/issues/45)
* **`azuredevops_build_definition`:**
- Add Support for GitHub enterprise as a build definition repository type [#97](https://github.com/microsoft/terraform-provider-azuredevops/pull/97)
* `azuredevops_build_definition`
- Add Support for GitHub enterprise as a build definition repository type [#97](https://github.com/microsoft/terraform-provider-azuredevops/issues/97)
- Add Support for report build status configuration [#63](https://github.com/microsoft/terraform-provider-azuredevops/issues/63)
BUG FIX:
* **`azuredevops_serviceendpoint_github`: GitHub service connection API breaking change** [#72](https://github.com/microsoft/terraform-provider-azuredevops/issues/72)
* **All service connection resources: Terraform crashes when the service connection description is set to an empty string** [#60](https://github.com/microsoft/terraform-provider-azuredevops/pull/60)
* **`azuredevops_build_definition`: Build Definition creation failed when repository type is GitHub** [#65](https://github.com/microsoft/terraform-provider-azuredevops/issues/65)
* All service connection resources - Terraform crashes when the service connection description is set to an empty string [#60](https://github.com/microsoft/terraform-provider-azuredevops/issues/60)
* Resource import - set the project ID to `project_id` [#172](https://github.com/microsoft/terraform-provider-azuredevops/issues/172)
* `azuredevops_build_definition` - build Definition creation failed when repository type is GitHub [#65](https://github.com/microsoft/terraform-provider-azuredevops/issues/65)
* `azuredevops_serviceendpoint_github` - GitHub service connection API breaking change [#72](https://github.com/microsoft/terraform-provider-azuredevops/issues/72)
BREAKING CHANGES:
* `azuredevops_git_repository` - `initialization` now is a required configuration. [#54](https://github.com/microsoft/terraform-provider-azuredevops/issues/54)
* Data source: `azuredevops_project` - remove `project_name`, add `project_identifier` as the required configuration [#176](https://github.com/microsoft/terraform-provider-azuredevops/issues/176)
* `azuredevops_git_repository` - `initialization` is a required configuration [#54](https://github.com/microsoft/terraform-provider-azuredevops/issues/54)
* `azuredevops_project` - rename `project_name` to `name` [#179](https://github.com/microsoft/terraform-provider-azuredevops/issues/179)
## 0.0.1 (June 18, 2020)
@ -42,14 +48,14 @@ NOTES:
FEATURES:
* **New Resource** `azuredevops_build_definition`
* **New Resource** `azuredevops_project`
* **New Resource** `azuredevops_variable_group` [#21](https://github.com/microsoft/terraform-provider-azuredevops/issues/21)
* **New Resource** `azuredevops_serviceendpoint_github` [#3](https://github.com/microsoft/terraform-provider-azuredevops/issues/3)
* **New Resource** `azuredevops_serviceendpoint_dockerregistry` [#297](https://github.com/microsoft/terraform-provider-azuredevops/issues/3)
* **New Resource** `azuredevops_serviceendpoint_azurerm` [#3](https://github.com/microsoft/terraform-provider-azuredevops/issues/3)
* **New Resource** `azuredevops_git_repository` [#94](https://github.com/microsoft/terraform-provider-azuredevops/issues/94) [#95](https://github.com/microsoft/terraform-provider-azuredevops/issues/95) [#96](https://github.com/microsoft/terraform-provider-azuredevops/issues/96) [#97](https://github.com/microsoft/terraform-provider-azuredevops/issues/97)
* **New Resource** `azuredevops_user_entitlement` [#125](https://github.com/microsoft/terraform-provider-azuredevops/issues/125)
* **New Resource** `azuredevops_group_membership` [#74](https://github.com/microsoft/terraform-provider-azuredevops/issues/74)
* **New Resource** `azuredevops_agent_pool` [#22](https://github.com/microsoft/terraform-provider-azuredevops/issues/22)
* **New Resource** `azuredevops_group` [#103](https://github.com/microsoft/terraform-provider-azuredevops/issues/103)
* **New Data Source** `azuredevops_group` [#126](https://github.com/microsoft/terraform-provider-azuredevops/issues/126)
* **New Data Source** `azuredevops_projects` [#17](https://github.com/microsoft/terraform-provider-azuredevops/issues/17)
* **New Resource** `azuredevops_variable_group`
* **New Resource** `azuredevops_serviceendpoint_github`
* **New Resource** `azuredevops_serviceendpoint_dockerregistry`
* **New Resource** `azuredevops_serviceendpoint_azurerm`
* **New Resource** `azuredevops_git_repository`
* **New Resource** `azuredevops_user_entitlement`
* **New Resource** `azuredevops_group_membership`
* **New Resource** `azuredevops_agent_pool`
* **New Resource** `azuredevops_group`
* **New Data Source** `azuredevops_group`
* **New Data Source** `azuredevops_projects`

Просмотреть файл

@ -24,7 +24,7 @@ provider "azuredevops" {
}
resource "azuredevops_project" "project" {
project_name = "My Awesome Project"
name = "My Awesome Project"
description = "All of my awesomee things"
}

Просмотреть файл

@ -49,7 +49,7 @@ provider "azuredevops" {
}
resource "azuredevops_project" "project" {
project_name = "My Awesome Project"
name = "My Awesome Project"
description = "All of my awesomee things"
}

Просмотреть файл

@ -0,0 +1,34 @@
// +build all data_sources data_agent_queue
// +build !exclude_data_sources !exclude_data_agent_queue
package acceptancetests
import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/acceptancetests/testutils"
)
func TestAccAgentQueue_DataSource(t *testing.T) {
projectName := testutils.GenerateResourceName()
agentQueueName := "Azure Pipelines"
agentQueueData := testutils.HclAgentQueueDataSource(projectName, agentQueueName)
tfNode := "data.azuredevops_agent_queue.queue"
resource.Test(t, resource.TestCase{
PreCheck: func() { testutils.PreCheck(t, nil) },
Providers: testutils.GetProviders(),
Steps: []resource.TestStep{
{
Config: agentQueueData,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(tfNode, "id"),
resource.TestCheckResourceAttr(tfNode, "name", agentQueueName),
resource.TestCheckResourceAttrSet(tfNode, "project_id"),
resource.TestCheckResourceAttrSet(tfNode, "agent_pool_id"),
),
},
},
})
}

Просмотреть файл

@ -29,7 +29,7 @@ func TestAccProject_DataSource(t *testing.T) {
{
Name: "Get project with name",
Identifier: "project_identifier",
IdentifierOnProject: "project_name",
IdentifierOnProject: "name",
},
}
@ -53,7 +53,7 @@ func TestAccProject_DataSource(t *testing.T) {
Config: projectData,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(tfNode, "process_template_id"),
resource.TestCheckResourceAttr(tfNode, "project_name", projectName),
resource.TestCheckResourceAttr(tfNode, "name", projectName),
resource.TestCheckResourceAttr(tfNode, "version_control", "Git"),
resource.TestCheckResourceAttr(tfNode, "visibility", "private"),
resource.TestCheckResourceAttr(tfNode, "work_item_template", "Agile"),

Просмотреть файл

@ -32,7 +32,7 @@ func TestAccProject_CreateAndUpdate(t *testing.T) {
Config: testutils.HclProjectResource(projectNameFirst),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(tfNode, "process_template_id"),
resource.TestCheckResourceAttr(tfNode, "project_name", projectNameFirst),
resource.TestCheckResourceAttr(tfNode, "name", projectNameFirst),
resource.TestCheckResourceAttr(tfNode, "version_control", "Git"),
resource.TestCheckResourceAttr(tfNode, "visibility", "private"),
resource.TestCheckResourceAttr(tfNode, "work_item_template", "Agile"),
@ -43,7 +43,7 @@ func TestAccProject_CreateAndUpdate(t *testing.T) {
Config: testutils.HclProjectResource(projectNameSecond),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(tfNode, "process_template_id"),
resource.TestCheckResourceAttr(tfNode, "project_name", projectNameSecond),
resource.TestCheckResourceAttr(tfNode, "name", projectNameSecond),
resource.TestCheckResourceAttr(tfNode, "version_control", "Git"),
resource.TestCheckResourceAttr(tfNode, "visibility", "private"),
resource.TestCheckResourceAttr(tfNode, "work_item_template", "Agile"),
@ -73,7 +73,7 @@ func TestAccProject_CreateAndUpdateWithFeatures(t *testing.T) {
Config: testutils.HclProjectResourceWithFeature(projectName, "disabled", "disabled"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(tfNode, "process_template_id"),
resource.TestCheckResourceAttr(tfNode, "project_name", projectName),
resource.TestCheckResourceAttr(tfNode, "name", projectName),
resource.TestCheckResourceAttr(tfNode, "version_control", "Git"),
resource.TestCheckResourceAttr(tfNode, "visibility", "private"),
resource.TestCheckResourceAttr(tfNode, "work_item_template", "Agile"),
@ -86,7 +86,7 @@ func TestAccProject_CreateAndUpdateWithFeatures(t *testing.T) {
Config: testutils.HclProjectResourceWithFeature(projectName, "enabled", "disabled"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(tfNode, "process_template_id"),
resource.TestCheckResourceAttr(tfNode, "project_name", projectName),
resource.TestCheckResourceAttr(tfNode, "name", projectName),
resource.TestCheckResourceAttr(tfNode, "version_control", "Git"),
resource.TestCheckResourceAttr(tfNode, "visibility", "private"),
resource.TestCheckResourceAttr(tfNode, "work_item_template", "Agile"),

Просмотреть файл

@ -58,7 +58,7 @@ func HclProjectResource(projectName string) string {
}
return fmt.Sprintf(`
resource "azuredevops_project" "project" {
project_name = "%[1]s"
name = "%[1]s"
description = "%[1]s-description"
visibility = "private"
version_control = "Git"
@ -79,7 +79,7 @@ func HclProjectResourceWithFeature(projectName string, featureStateTestplans str
}
return fmt.Sprintf(`
resource "azuredevops_project" "project" {
project_name = "%s"
name = "%s"
description = "%s-description"
visibility = "private"
version_control = "Git"
@ -114,7 +114,7 @@ func HclProjectsDataSource(projectName string) string {
%s
data "azuredevops_projects" "project-list" {
project_name = azuredevops_project.project.project_name
name = azuredevops_project.project.name
}
`, projectResource)
}
@ -122,7 +122,7 @@ data "azuredevops_projects" "project-list" {
// HclProjectsDataSourceWithStateAndInvalidName creates HCL for a multi value data source for AzDo projects
func HclProjectsDataSourceWithStateAndInvalidName() string {
return `data "azuredevops_projects" "project-list" {
project_name = "_invalid_project_name"
name = "invalid_name"
state = "wellFormed"
}`
}
@ -144,7 +144,7 @@ data "azuredevops_git_repository" "repository" {
func HclProjectGitRepositories(projectName string, gitRepoName string) string {
return fmt.Sprintf(`
data "azuredevops_project" "project" {
project_identifier = azuredevops_project.project.project_name
project_identifier = azuredevops_project.project.name
}
data "azuredevops_git_repositories" "repositories" {
@ -457,12 +457,23 @@ data "azuredevops_agent_pools" "pools" {
}`
}
// HclAgentQueueDataSource HCL describing a data source for an AzDO Agent Queue
func HclAgentQueueDataSource(projectName, queueName string) string {
return fmt.Sprintf(`
%s
data "azuredevops_agent_queue" "queue" {
project_id = azuredevops_project.project.id
name = "%s"
}`, HclProjectResource(projectName), queueName)
}
// HclAgentQueueResource HCL describing an AzDO Agent Pool and Agent Queue
func HclAgentQueueResource(projectName, poolName string) string {
poolHCL := HclAgentPoolResource(poolName)
queueHCL := fmt.Sprintf(`
resource "azuredevops_project" "p" {
project_name = "%s"
name = "%s"
}
resource "azuredevops_agent_queue" "q" {
@ -607,7 +618,7 @@ resource "azuredevops_group_membership" "membership" {
func HclGroupMembershipDependencies(projectName, groupName, userPrincipalName string) string {
return fmt.Sprintf(`
resource "azuredevops_project" "project" {
project_name = "%s"
name = "%s"
}
data "azuredevops_group" "group" {
project_id = azuredevops_project.project.id

Просмотреть файл

@ -19,7 +19,7 @@ func DataProject() *schema.Resource {
Required: true,
ValidateFunc: validation.StringIsNotWhiteSpace,
},
"project_name": {
"name": {
Type: schema.TypeString,
Computed: true,
},

Просмотреть файл

@ -22,7 +22,7 @@ func DataProjects() *schema.Resource {
Read: dataSourceProjectsRead,
Schema: map[string]*schema.Schema{
"project_name": {
"name": {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
@ -81,7 +81,7 @@ func getProjectHash(v interface{}) int {
func dataSourceProjectsRead(d *schema.ResourceData, m interface{}) error {
clients := m.(*client.AggregatedClient)
state := d.Get("state").(string)
name := d.Get("project_name").(string)
name := d.Get("name").(string)
projects, err := getProjectsForStateAndName(clients, state, name)
if err != nil {

Просмотреть файл

@ -110,12 +110,12 @@ func TestDataSourceProjects_Read_TestFindProjectByName(t *testing.T) {
Times(1)
resourceData := schema.TestResourceDataRaw(t, DataProjects().Schema, nil)
resourceData.Set("project_name", "vsteam-0178")
resourceData.Set("name", "vsteam-0178")
resourceData.Set("state", "wellFormed")
err := dataSourceProjectsRead(resourceData, clients)
require.Nil(t, err)
require.Equal(t, "wellFormed", resourceData.Get("state").(string))
require.Equal(t, "vsteam-0178", resourceData.Get("project_name").(string))
require.Equal(t, "vsteam-0178", resourceData.Get("name").(string))
projectSet := resourceData.Get("projects").(*schema.Set)
require.NotNil(t, projectSet)
require.Equal(t, 1, projectSet.Len())
@ -153,7 +153,7 @@ func TestDataSourceProjects_Read_TestEmptyProjectList(t *testing.T) {
err := dataSourceProjectsRead(resourceData, clients)
require.Nil(t, err)
require.Equal(t, "all", resourceData.Get("state").(string))
require.Equal(t, "", resourceData.Get("project_name").(string))
require.Equal(t, "", resourceData.Get("name").(string))
projectSet := resourceData.Get("projects").(*schema.Set)
require.NotNil(t, projectSet)
require.Equal(t, 0, projectSet.Len())
@ -186,7 +186,7 @@ func TestDataSourceProjects_Read_TestFindAllProjects(t *testing.T) {
err := dataSourceProjectsRead(resourceData, clients)
require.Nil(t, err)
require.Equal(t, "all", resourceData.Get("state").(string))
require.Equal(t, "", resourceData.Get("project_name").(string))
require.Equal(t, "", resourceData.Get("name").(string))
projectSet := resourceData.Get("projects").(*schema.Set)
require.NotNil(t, projectSet)
require.Equal(t, 3, projectSet.Len())
@ -219,7 +219,7 @@ func TestDataSourceProjects_Read_TestDuplicateProjectId(t *testing.T) {
err := dataSourceProjectsRead(resourceData, clients)
require.Nil(t, err)
require.Equal(t, "all", resourceData.Get("state").(string))
require.Equal(t, "", resourceData.Get("project_name").(string))
require.Equal(t, "", resourceData.Get("name").(string))
projectSet := resourceData.Get("projects").(*schema.Set)
require.NotNil(t, projectSet)
require.Equal(t, 2, projectSet.Len())
@ -253,7 +253,7 @@ func TestDataSourceProjects_Read_TestFindProjectsWithState(t *testing.T) {
err := dataSourceProjectsRead(resourceData, clients)
require.Nil(t, err)
require.Equal(t, "wellFormed", resourceData.Get("state").(string))
require.Equal(t, "", resourceData.Get("project_name").(string))
require.Equal(t, "", resourceData.Get("name").(string))
projectSet := resourceData.Get("projects").(*schema.Set)
require.NotNil(t, projectSet)
require.Equal(t, 3, projectSet.Len())
@ -325,7 +325,7 @@ func TestDataSourceProjects_Read_TestContinuationToken(t *testing.T) {
err := dataSourceProjectsRead(resourceData, clients)
require.Nil(t, err)
require.Equal(t, "all", resourceData.Get("state").(string))
require.Equal(t, "", resourceData.Get("project_name").(string))
require.Equal(t, "", resourceData.Get("name").(string))
projectSet := resourceData.Get("projects").(*schema.Set)
require.NotNil(t, projectSet)
require.Equal(t, 6, projectSet.Len())

Просмотреть файл

@ -41,7 +41,7 @@ func ResourceProject() *schema.Resource {
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"project_name": {
"name": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringIsNotWhiteSpace,
@ -117,7 +117,7 @@ func resourceProjectCreate(d *schema.ResourceData, m interface{}) error {
}
}
d.Set("project_name", *project.Name)
d.Set("name", *project.Name)
return resourceProjectRead(d, m)
}
@ -191,7 +191,7 @@ func waitForAsyncOperationSuccess(clients *client.AggregatedClient, operationRef
func resourceProjectRead(d *schema.ResourceData, m interface{}) error {
clients := m.(*client.AggregatedClient)
id := d.Id()
name := d.Get("project_name").(string)
name := d.Get("name").(string)
project, err := projectRead(clients, id, name)
if err != nil {
@ -233,7 +233,7 @@ func resourceProjectUpdate(d *schema.ResourceData, m interface{}) error {
}
requiresUpdate := false
if !d.HasChange("project_name") {
if !d.HasChange("name") {
project.Name = nil
} else {
requiresUpdate = true
@ -377,7 +377,7 @@ func expandProject(clients *client.AggregatedClient, d *schema.ResourceData, for
project := &core.TeamProject{
Id: projectID,
Name: converter.String(d.Get("project_name").(string)),
Name: converter.String(d.Get("name").(string)),
Description: converter.String(d.Get("description").(string)),
Visibility: &visibility,
Capabilities: capabilities,
@ -406,7 +406,7 @@ func flattenProject(clients *client.AggregatedClient, d *schema.ResourceData, pr
}
d.SetId(project.Id.String())
d.Set("project_name", project.Name)
d.Set("name", project.Name)
d.Set("visibility", project.Visibility)
d.Set("description", project.Description)
d.Set("version_control", (*project.Capabilities)["versioncontrol"]["sourceControlType"])

Просмотреть файл

@ -0,0 +1,78 @@
package taskagent
import (
"fmt"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/microsoft/azure-devops-go-api/azuredevops/taskagent"
"github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client"
"github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/suppress"
)
// DataAgentQueue schema and implementation for agent queue source
func DataAgentQueue() *schema.Resource {
return &schema.Resource{
Read: dataSourceAgentQueueRead,
Schema: map[string]*schema.Schema{
projectID: {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.NoZeroValues,
DiffSuppressFunc: suppress.CaseDifference,
},
"name": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringIsNotEmpty,
},
agentPoolID: {
Type: schema.TypeInt,
Computed: true,
},
},
}
}
func dataSourceAgentQueueRead(d *schema.ResourceData, m interface{}) error {
agentQueueName := d.Get("name").(string)
projectID := d.Get("project_id").(string)
clients := m.(*client.AggregatedClient)
agentQueue, err := getAgentQueueByName(clients, &agentQueueName, &projectID)
if err != nil {
return fmt.Errorf("Error getting agent queue by name: %v", err)
}
flattenAzureAgentQueue(d, agentQueue)
return nil
}
func flattenAzureAgentQueue(d *schema.ResourceData, agentQueue *taskagent.TaskAgentQueue) {
d.SetId(strconv.Itoa(*agentQueue.Id))
d.Set("name", *agentQueue.Name)
d.Set(agentPoolID, *agentQueue.Pool.Id)
d.Set("project_id", agentQueue.ProjectId.String())
}
func getAgentQueueByName(clients *client.AggregatedClient, name, projectID *string) (*taskagent.TaskAgentQueue, error) {
agentQueues, err := clients.TaskAgentClient.GetAgentQueues(clients.Ctx, taskagent.GetAgentQueuesArgs{
Project: projectID,
QueueName: name,
})
if err != nil {
return nil, err
}
if len(*agentQueues) > 1 {
return nil, fmt.Errorf("Found multiple agent queues for name: %s. Agent queues found: %+v", *name, agentQueues)
}
if len(*agentQueues) == 0 {
return nil, fmt.Errorf("Unable to find agent queues with name: %s", *name)
}
return &(*agentQueues)[0], nil
}

Просмотреть файл

@ -0,0 +1,74 @@
// +build all core data_projects
package taskagent
// The tests in this file use the mock clients in mock_client.go to mock out
// the Azure DevOps client operations.
import (
"context"
"testing"
"github.com/golang/mock/gomock"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/microsoft/azure-devops-go-api/azuredevops/taskagent"
"github.com/microsoft/terraform-provider-azuredevops/azdosdkmocks"
"github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client"
"github.com/stretchr/testify/require"
)
func TestDataSourceAgentQueue_Read_TestAgentQueueNotFound(t *testing.T) {
agentQueueListEmpty := []taskagent.TaskAgentQueue{}
name := "nonexistentAgentQueue"
ctrl := gomock.NewController(t)
defer ctrl.Finish()
taskAgentClient := azdosdkmocks.NewMockTaskagentClient(ctrl)
clients := &client.AggregatedClient{
TaskAgentClient: taskAgentClient,
Ctx: context.Background(),
}
taskAgentClient.
EXPECT().
GetAgentQueues(clients.Ctx, taskagent.GetAgentQueuesArgs{
Project: &agentQueueProject,
QueueName: &name,
}).
Return(&agentQueueListEmpty, nil).
Times(1)
resourceData := schema.TestResourceDataRaw(t, DataAgentQueue().Schema, nil)
resourceData.Set("name", &name)
resourceData.Set("project_id", &agentQueueProject)
err := dataSourceAgentQueueRead(resourceData, clients)
require.Contains(t, err.Error(), "Unable to find agent queue")
}
func TestDataSourceAgentQueue_Read_TestMultipleAgentQueuesFound(t *testing.T) {
agentQueueList := []taskagent.TaskAgentQueue{{}, {}}
name := "multipleQueues"
ctrl := gomock.NewController(t)
defer ctrl.Finish()
taskAgentClient := azdosdkmocks.NewMockTaskagentClient(ctrl)
clients := &client.AggregatedClient{
TaskAgentClient: taskAgentClient,
Ctx: context.Background(),
}
taskAgentClient.
EXPECT().
GetAgentQueues(clients.Ctx, taskagent.GetAgentQueuesArgs{
Project: &agentQueueProject,
QueueName: &name,
}).
Return(&agentQueueList, nil).
Times(1)
resourceData := schema.TestResourceDataRaw(t, DataAgentQueue().Schema, nil)
resourceData.Set("name", &name)
resourceData.Set("project_id", &agentQueueProject)
err := dataSourceAgentQueueRead(resourceData, clients)
require.Contains(t, err.Error(), "Found multiple agent queues for name")
}

Просмотреть файл

@ -49,7 +49,7 @@ func getAgentPoolByName(clients *client.AggregatedClient, name *string) (*taskag
}
if len(*agentPools) > 1 {
return nil, fmt.Errorf("Found multiple agent pools for name: %s. Agent pools found: %v", *name, agentPools)
return nil, fmt.Errorf("Found multiple agent pools for name: %s. Agent pools found: %+v", *name, agentPools)
}
if len(*agentPools) == 0 {

Просмотреть файл

@ -44,8 +44,8 @@ func TestDataSourceAgentPool_Read_TestAgentPoolNotFound(t *testing.T) {
}
func TestDataSourceAgentPool_Read_TestMultipleAgentPoolsFound(t *testing.T) {
agentPoolListEmpty := []taskagent.TaskAgentPool{{}, {}}
name := "nonexistentAgentPool"
agentPoolList := []taskagent.TaskAgentPool{{}, {}}
name := "multiplePools"
ctrl := gomock.NewController(t)
defer ctrl.Finish()
@ -60,7 +60,7 @@ func TestDataSourceAgentPool_Read_TestMultipleAgentPoolsFound(t *testing.T) {
GetAgentPools(clients.Ctx, taskagent.GetAgentPoolsArgs{
PoolName: &name,
}).
Return(&agentPoolListEmpty, nil).
Return(&agentPoolList, nil).
Times(1)
resourceData := schema.TestResourceDataRaw(t, DataAgentPool().Schema, nil)

Просмотреть файл

@ -50,7 +50,7 @@ func UInt64(value uint64) *uint64 {
return &value
}
// ToString Given a pointer return its value, or a default value of the poitner is nil
// ToString Given a pointer return its value, or a default value of the pointer is nil
func ToString(value *string, defaultValue string) string {
if value != nil {
return *value

Просмотреть файл

@ -53,6 +53,7 @@ func Provider() *schema.Provider {
DataSourcesMap: map[string]*schema.Resource{
"azuredevops_agent_pool": taskagent.DataAgentPool(),
"azuredevops_agent_pools": taskagent.DataAgentPools(),
"azuredevops_agent_queue": taskagent.DataAgentQueue(),
"azuredevops_client_config": service.DataClientConfig(),
"azuredevops_group": graph.DataGroup(),
"azuredevops_project": core.DataProject(),

Просмотреть файл

@ -60,6 +60,7 @@ func TestProvider_HasChildDataSources(t *testing.T) {
"azuredevops_users",
"azuredevops_agent_pool",
"azuredevops_agent_pools",
"azuredevops_agent_queue",
"azuredevops_area",
"azuredevops_iteration",
}

Просмотреть файл

@ -8,7 +8,7 @@ provider "azuredevops" {
// This section creates a project
resource "azuredevops_project" "project" {
project_name = "Sample Project"
name = "Sample Project"
visibility = "private"
version_control = "Git"
work_item_template = "Agile"

Просмотреть файл

@ -8,7 +8,7 @@ provider "azuredevops" {
}
resource "azuredevops_project" "project" {
project_name = "Sample Project"
name = "Sample Project"
visibility = "private"
version_control = "Git"
work_item_template = "Agile"

Просмотреть файл

@ -34,6 +34,9 @@
<li>
<a href="/docs/providers/azuredevops/d/data_agent_pools.html">azuredevops_agent_pools</a>
</li>
<li>
<a href="/docs/providers/azuredevops/d/data_agent_queue.html">azuredevops_agent_queue</a>
</li>
<li>
<a href="/docs/providers/azuredevops/d/data_area.html">azuredevops_area</a>
</li>

Просмотреть файл

@ -0,0 +1,55 @@
---
layout: "azuredevops"
page_title: "AzureDevops: azuredevops_agent_queue"
description: |-
Use this data source to access information about an existing Agent Queue within Azure DevOps.
---
# Data Source: azuredevops_agent_queue
Use this data source to access information about an existing Agent Queue within Azure DevOps.
## Example Usage
```hcl
# Azure DevOps project
resource "azuredevops_project" "project" {
name = "Sample Project"
work_item_template = "Agile"
version_control = "Git"
visibility = "private"
description = "Managed by Terraform"
}
data "azuredevops_agent_queue" "queue" {
project_id = azuredevops_project.project.id
name = "Sample Agent Queue"
}
output "name" {
value = data.azuredevops_agent_queue.queue.name
}
output "pool_id" {
value = data.azuredevops_agent_queue.queue.agent_pool_id
}
```
## Argument Reference
The following arguments are supported:
- `project_id` - (Required) The Project Id.
- `name` - (Required) Name of the Agent Queue.
## Attributes Reference
The following attributes are exported:
- `id` - The id of the agent queue.
- `name` - The name of the agent queue.
- `project_id` - Project identifier to which the agent queue belongs.
- `agent_pool_id` - Agent pool identifier to which the agent queue belongs.
## Relevant Links
- [Azure DevOps Service REST API 5.1 - Agent Queues - Get](https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/queues/get?view=azure-devops-rest-5.1)

Просмотреть файл

@ -15,7 +15,7 @@ Use this data source to access information about an existing Area (Component) wi
#---------------------------------------------------------------------------
# Azure DevOps project
resource "azuredevops_project" "project" {
project_name = "Sample Project"
name = "Sample Project"
work_item_template = "Agile"
version_control = "Git"
visibility = "private"

Просмотреть файл

@ -15,7 +15,7 @@ To read informations about a **single** Git Repository use the data source [`azu
```hcl
# Load all projects of an organization, that are accessible by the current user
data "azuredevops_project" "p" {
project_name = "contoso-project"
name = "contoso-project"
}
# Load all Git repositories of a project, which are accessible for the current user

Просмотреть файл

@ -15,7 +15,7 @@ To read information about **multiple** Git Repositories use the data source [`az
```hcl
# Load all projects of an organization, that are accessible by the current user
data "azuredevops_project" "project" {
project_name = "contoso-project"
name = "contoso-project"
}
# Load a specific Git repository by name

Просмотреть файл

@ -13,7 +13,7 @@ Use this data source to access information about an existing Group within Azure
```hcl
data "azuredevops_project" "p" {
project_name = "contoso-project"
name = "contoso-project"
}
data "azuredevops_group" "test" {

Просмотреть файл

@ -13,7 +13,7 @@ Use this data source to access information about an existing Iteration (Sprint)
```hcl
resource "azuredevops_project" "project" {
project_name = "Sample Project"
name = "Sample Project"
work_item_template = "Agile"
version_control = "Git"
visibility = "private"

Просмотреть файл

@ -20,8 +20,8 @@ output "id" {
value = data.azuredevops_project.p.id
}
output "project_name" {
value = data.azuredevops_project.p.project_name
output "name" {
value = data.azuredevops_project.p.name
}
output "visibility" {
@ -51,7 +51,7 @@ The following arguments are supported:
The following attributes are exported:
`project_name` - The name of the referenced project
`name` - The name of the referenced project
`description` - The description of the referenced project
`visibility` - The visibility of the referenced project
`version_control` - The version control of the referenced project

Просмотреть файл

@ -13,7 +13,7 @@ Use this data source to access information about existing Projects within Azure
```hcl
data "azuredevops_projects" "test" {
project_name = "contoso"
name = "contoso"
state = "wellFormed"
}
@ -21,7 +21,7 @@ output "project_id" {
value = data.azuredevops_projects.test.projects.*.project_id
}
output "project_name" {
output "name" {
value = data.azuredevops_projects.test.projects.*.name
}
@ -38,7 +38,7 @@ output "state" {
The following arguments are supported:
- `project_name` - (Optional) Name of the Project, if not specified all projects will be returned.
- `name` - (Optional) Name of the Project, if not specified all projects will be returned.
- `state` - (Optional) State of the Project, if not specified all projects will be returned. Valid values are `all`, `deleting`, `new`, `wellFormed`, `createPending`, `unchanged`,`deleted`.

Просмотреть файл

@ -31,7 +31,7 @@ provider "azuredevops" {
}
resource "azuredevops_project" "project" {
project_name = "Test Project"
name = "Test Project"
description = "Test Project Description"
}
```

Просмотреть файл

@ -21,7 +21,7 @@ provider "azuredevops" {
}
resource "azuredevops_project" "project" {
project_name = "Project Name"
name = "Project Name"
description = "Project Description"
}
```

Просмотреть файл

@ -17,7 +17,7 @@ the `azuredevops_resource_authorization` resource can be used to grant authoriza
```hcl
resource "azuredevops_project" "project" {
project_name = "Sample Project"
name = "Sample Project"
}
data "azuredevops_agent_pool" "pool" {

Просмотреть файл

@ -20,7 +20,7 @@ Those levels are reflected by specifying (or omitting) values for the arguments
```hcl
resource "azuredevops_project" "project" {
project_name = "Sample Project"
name = "Sample Project"
work_item_template = "Agile"
version_control = "Git"
visibility = "private"

Просмотреть файл

@ -15,7 +15,7 @@ Manages a git repository within Azure DevOps.
```hcl
resource "azuredevops_project" "project" {
project_name = "Sample Project"
name = "Sample Project"
visibility = "private"
version_control = "Git"
work_item_template = "Agile"

Просмотреть файл

@ -13,7 +13,7 @@ Manages required reviewer policy branch policy within Azure DevOps.
```hcl
resource "azuredevops_project" "p" {
project_name = "Sample Project"
name = "Sample Project"
}
resource "azuredevops_git_repository" "r" {

Просмотреть файл

@ -13,7 +13,7 @@ Manages a build validation branch policy within Azure DevOps.
```hcl
resource "azuredevops_project" "p" {
project_name = "Sample Project"
name = "Sample Project"
}
resource "azuredevops_git_repository" "r" {

Просмотреть файл

@ -13,7 +13,7 @@ Configure a comment resolution policy for your branch within Azure DevOps projec
```hcl
resource "azuredevops_project" "p" {
project_name = "Sample Project"
name = "Sample Project"
}
resource "azuredevops_git_repository" "r" {

Просмотреть файл

@ -13,7 +13,7 @@ Manages a minimum reviewer branch policy within Azure DevOps.
```hcl
resource "azuredevops_project" "p" {
project_name = "Sample Project"
name = "Sample Project"
}
resource "azuredevops_git_repository" "r" {

Просмотреть файл

@ -13,7 +13,7 @@ Require associations between branches and a work item within Azure DevOps.
```hcl
resource "azuredevops_project" "p" {
project_name = "Sample Project"
name = "Sample Project"
}
resource "azuredevops_git_repository" "r" {

Просмотреть файл

@ -14,7 +14,7 @@ Manages a Build Definition within Azure DevOps.
### Tfs
```hcl
resource "azuredevops_project" "project" {
project_name = "Sample Project"
name = "Sample Project"
visibility = "private"
version_control = "Git"
work_item_template = "Agile"

Просмотреть файл

@ -77,7 +77,7 @@ resource "azuredevops_git_permissions" "project-git-branch-permissions" {
```hcl
resource "azuredevops_project" "project" {
project_name = "Test Project"
name = "Test Project"
description = "Test Project Description"
visibility = "private"
version_control = "Git"

Просмотреть файл

@ -13,7 +13,7 @@ Manages a group within Azure DevOps.
```hcl
resource "azuredevops_project" "p" {
project_name = "Test Project"
name = "Test Project"
}
data "azuredevops_group" "tf-project-readers" {

Просмотреть файл

@ -13,7 +13,7 @@ Manages group membership within Azure DevOps.
```hcl
resource "azuredevops_project" "project" {
project_name = "Test Project"
name = "Test Project"
}
resource "azuredevops_user_entitlement" "user" {

Просмотреть файл

@ -21,7 +21,7 @@ Those levels are reflected by specifying (or omitting) values for the arguments
```hcl
resource "azuredevops_project" "project" {
project_name = "Sample Project"
name = "Sample Project"
work_item_template = "Agile"
version_control = "Git"
visibility = "private"

Просмотреть файл

@ -13,7 +13,7 @@ Manages a project within Azure DevOps.
```hcl
resource "azuredevops_project" "project" {
project_name = "Test Project"
name = "Test Project"
description = "Test Project Description"
visibility = "private"
version_control = "Git"
@ -30,7 +30,7 @@ resource "azuredevops_project" "project" {
The following arguments are supported:
- `project_name` - (Required) The Project Name.
- `name` - (Required) The Project Name.
- `description` - (Optional) The Description of the Project.
- `visibility` - (Optional) Specifies the visibility of the Project. Valid values: `private` or `public`. Defaults to `private`.
- `version_control` - (Optional) Specifies the version control system. Valid values: `Git` or `Tfvc`. Defaults to `Git`.

Просмотреть файл

@ -17,7 +17,7 @@ provider "azuredevops" {
}
data "azuredevops_project" "tf-project-test-001" {
project_name = "Test Project"
name = "Test Project"
}
resource "azuredevops_project_features" "my-project-features" {

Просмотреть файл

@ -15,7 +15,7 @@ Manages permissions for a AzureDevOps project
```hcl
resource "azuredevops_project" "project" {
project_name = "Test Project"
name = "Test Project"
description = "Test Project Description"
visibility = "private"
version_control = "Git"

Просмотреть файл

@ -15,7 +15,7 @@ Currently supported resources: service endpoint (aka service connection, endpoin
```hcl
resource "azuredevops_project" "project" {
project_name = "Test Project"
name = "Test Project"
}
resource "azuredevops_serviceendpoint_bitbucket" "bitbucket_account" {

Просмотреть файл

@ -12,7 +12,7 @@ Manages a AWS service endpoint within Azure DevOps. Using this service endpoint
```hcl
resource "azuredevops_project" "project" {
project_name = "Sample Project"
name = "Sample Project"
visibility = "private"
version_control = "Git"
work_item_template = "Agile"

Просмотреть файл

@ -13,7 +13,7 @@ Manages a Azure Container Registry service endpoint within Azure DevOps.
```hcl
resource "azuredevops_project" "project" {
project_name = "Sample Project"
name = "Sample Project"
visibility = "private"
version_control = "Git"
work_item_template = "Agile"

Просмотреть файл

@ -21,7 +21,7 @@ For detailed steps to create a service principal with Azure cli see the [documen
```hcl
resource "azuredevops_project" "project" {
project_name = "Sample Project"
name = "Sample Project"
visibility = "private"
version_control = "Git"
work_item_template = "Agile"
@ -45,7 +45,7 @@ resource "azuredevops_serviceendpoint_azurerm" "endpointazure" {
```hcl
resource "azuredevops_project" "project" {
project_name = "Sample Project"
name = "Sample Project"
visibility = "private"
version_control = "Git"
work_item_template = "Agile"

Просмотреть файл

@ -13,7 +13,7 @@ Manages a Bitbucket service endpoint within Azure DevOps.
```hcl
resource "azuredevops_project" "project" {
project_name = "Sample Project"
name = "Sample Project"
visibility = "private"
version_control = "Git"
work_item_template = "Agile"

Просмотреть файл

@ -13,7 +13,7 @@ Manages a Docker Registry service endpoint within Azure DevOps.
```hcl
resource "azuredevops_project" "project" {
project_name = "Sample Project"
name = "Sample Project"
visibility = "private"
version_control = "Git"
work_item_template = "Agile"

Просмотреть файл

@ -13,7 +13,7 @@ Manages a GitHub service endpoint within Azure DevOps.
```hcl
resource "azuredevops_project" "project" {
project_name = "Sample Project"
name = "Sample Project"
visibility = "private"
version_control = "Git"
work_item_template = "Agile"

Просмотреть файл

@ -13,7 +13,7 @@ Manages a Kubernetes service endpoint within Azure DevOps.
```hcl
data "azuredevops_project" "p" {
project_name = "contoso"
name = "contoso"
}
resource "azuredevops_serviceendpoint_kubernetes" "se_azure_sub" {

Просмотреть файл

@ -13,7 +13,7 @@ Manages variable groups within Azure DevOps.
```hcl
resource "azuredevops_project" "project" {
project_name = "Test Project"
name = "Test Project"
}
resource "azuredevops_variable_group" "variablegroup" {

Просмотреть файл

@ -59,7 +59,7 @@ resource "azuredevops_workitemquery_permissions" "wiq-folder-permissions" {
```hcl
resource "azuredevops_project" "project" {
project_name = "Test Project"
name = "Test Project"
description = "Test Project Description"
visibility = "private"
version_control = "Git"