forked from christianbumann/terraform-provider-azuredevops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterraform.code-snippets
194 lines (194 loc) · 5.97 KB
/
terraform.code-snippets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
{
// 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/helper/schema\"",
" \"github.com/hashicorp/terraform-plugin-sdk/helper/validation\"",
"",
" \"github.com/microsoft/azure-devops-go-api/azuredevops/core\"",
" \"github.com/microsoft/terraform-provider-azuredevops/azuredevops/utils/config\"",
" \"github.com/microsoft/terraform-provider-azuredevops/azuredevops/utils/converter\"",
" \"github.com/microsoft/terraform-provider-azuredevops/azuredevops/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.(*config.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/helper/schema\"",
" \"github.com/hashicorp/terraform-plugin-sdk/helper/validation\"",
"",
" \"github.com/microsoft/azure-devops-go-api/azuredevops/core\"",
" \"github.com/microsoft/terraform-provider-azuredevops/azuredevops/utils/config\"",
" \"github.com/microsoft/terraform-provider-azuredevops/azuredevops/utils/converter\"",
" \"github.com/microsoft/terraform-provider-azuredevops/azuredevops/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.(*config.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/utils/config\"",
" \"github.com/microsoft/terraform-provider-azuredevops/azuredevops/utils/converter\"",
"",
" \"github.com/golang/mock/gomock\"",
" \"github.com/google/uuid\"",
" \"github.com/hashicorp/terraform-plugin-sdk/helper/acctest\"",
" \"github.com/hashicorp/terraform-plugin-sdk/helper/resource\"",
" \"github.com/hashicorp/terraform-plugin-sdk/helper/schema\"",
" \"github.com/hashicorp/terraform-plugin-sdk/terraform\"",
" \"github.com/microsoft/azure-devops-go-api/azuredevops/core\"",
" \"github.com/microsoft/azure-devops-go-api/azuredevops/operations\"",
" \"github.com/stretchr/testify/require\"",
")",
"",
"func init() {",
" /* add code for test setup here */",
"}",
"",
"/**",
" * Begin unit tests",
" */",
"",
"func Test${1:Resource}_${2:Function}_Test${3:Subject}(t *testing.T) {",
" ctrl := gomock.NewController(t)",
" defer ctrl.Finish()",
"",
" coreClient := azdosdkmocks.NewMockCoreClient(ctrl)",
" clients := &config.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 := &config.AggregatedClient{",
" CoreClient: coreClient,",
" Ctx: context.Background(),",
" }",
"",
" /* start writing test here */",
"}",
""
],
"description": "Test Function Template"
}
}