{ // Place your terraform-provider-azuredevops workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is // used to trigger the snippet and the body will be expanded and inserted. Possible variables are: // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. // Placeholders with the same ids are connected. // Example: // "Print to console": { // "scope": "javascript,typescript", // "prefix": "log", // "body": [ // "console.log('$1');", // "$2" // ], // "description": "Log output to console" // } "Resource Template": { "scope": "go", "prefix": "tf-azdo-rs", "body": [ "package azuredevops", "", "import (", " \"fmt\"", "", " \"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema\"", " \"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation\"", "", " \"github.com/microsoft/azure-devops-go-api/azuredevops/v6/core\"", " \"github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client\"", " \"github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/converter\"", " \"github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/validate\"", ")", "", "func resource${1}() *schema.Resource {", " return &schema.Resource{", " Create: resource${1}Create,", " Read: resource${1}Read,", " Update: resource${1}Update,", " Delete: resource${1}Delete,", "", " Schema: map[string]*schema.Schema{", " // add properties here", " },", " }", "}", "", "func resource${1}Create(d *schema.ResourceData, m interface{}) error {", "", " return resource${1}Read(d, m)", "}", "", "func resource${1}Read(d *schema.ResourceData, m interface{}) error {", " clients := m.(*client.AggregatedClient)", "", " return nil", "}", "", "func resource${1}Update(d *schema.ResourceData, m interface{}) error {", " return resource${1}Read(d, m)", "}", "", "func resource${1}Delete(d *schema.ResourceData, m interface{}) error {", " return nil", "}", "" ], "description": "Resource Template" }, "Data Source Template": { "scope": "go", "prefix": "tf-azdo-ds", "body": [ "package azuredevops", "", "import (", " \"fmt\"", "", " \"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema\"", " \"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation\"", "", " \"github.com/microsoft/azure-devops-go-api/azuredevops/v6/core\"", " \"github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client\"", " \"github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/converter\"", " \"github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/validate\"", ")", "", "func dataSource${1}() *schema.Resource {", " return &schema.Resource{", " Read: dataSource${1}Read,", "", " //https://godoc.org/github.com/hashicorp/terraform/helper/schema#Schema", " Schema: map[string]*schema.Schema{", " // add properties here", " },", "", " }", "}", "", "func dataSource${1}Read(d *schema.ResourceData, m interface{}) error {", " clients := m.(*client.AggregatedClient)", " ${1}s := make([]map[string]interface{}, 0)", " ", " // read data into map ${1}s", "", " d.SetId(\"${1}s\")", " if err := d.Set(\"${1}s\", ${1}s); err != nil {", " return fmt.Errorf(\"Error setting `${1}s`: %+v\", err)", " }", "", " return nil", "}", "" ], "description": "Data Source Template" }, "Test Template": { "scope": "go", "prefix": "tf-azdo-test", "body": [ "// +build all", "", "package azuredevops", "", "// The tests in this file use the mock clients in mock_client.go to mock out", "// the Azure DevOps client operations.", "", "import (", " \"context\"", " \"errors\"", " \"fmt\"", " \"testing\"", "", " \"github.com/microsoft/terraform-provider-azuredevops/azdosdkmocks\"", " \"github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client\"", " \"github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/converter\"", "", " \"github.com/golang/mock/gomock\"", " \"github.com/google/uuid\"", " \"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest\"", " \"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource\"", " \"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema\"", " \"github.com/hashicorp/terraform-plugin-sdk/v2/terraform\"", " \"github.com/microsoft/azure-devops-go-api/azuredevops/v6/core\"", " \"github.com/microsoft/azure-devops-go-api/azuredevops/v6/operations\"", " \"github.com/stretchr/testify/require\"", ")", "", "func Test${1:Resource}_${2:Function}_Test${3:Subject}(t *testing.T) {", " ctrl := gomock.NewController(t)", " defer ctrl.Finish()", "", " coreClient := azdosdkmocks.NewMockCoreClient(ctrl)", " clients := &client.AggregatedClient{", " CoreClient: coreClient,", " Ctx: context.Background(),", " }", "", " /* start writing test here */", "}", "" ], "description": "Test Template" }, "Test Function Template": { "scope": "go", "prefix": "tf-azdo-test-func", "body": [ "func Test${1:Resource}_${2:Function}_Test${3:Subject}(t *testing.T) {", " ctrl := gomock.NewController(t)", " defer ctrl.Finish()", "", " coreClient := azdosdkmocks.NewMockCoreClient(ctrl)", " clients := &client.AggregatedClient{", " CoreClient: coreClient,", " Ctx: context.Background(),", " }", "", " /* start writing test here */", "}", "" ], "description": "Test Function Template" } }