Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 263ec8c

Browse files
authored
Data source results must not be optional (#706)
* The collection returned by data sources must not be optional * Updated test framework * Fixed modules
1 parent 70a6a5f commit 263ec8c

33 files changed

+65
-38
lines changed

go.mod

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.21
44

55
require (
66
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.43.0
7-
github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240622231527-24df7b6eaa48
7+
github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240729041805-46db6fb717b4
88
github.com/google/uuid v1.6.0
99
github.com/gruntwork-io/terratest v0.41.11
1010
github.com/hashicorp/go-cty v1.4.1-0.20200723130312-85980079f637
@@ -29,8 +29,8 @@ require (
2929
github.com/Masterminds/goutils v1.1.1 // indirect
3030
github.com/Masterminds/semver/v3 v3.2.0 // indirect
3131
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
32-
github.com/Microsoft/go-winio v0.6.1 // indirect
33-
github.com/Microsoft/hcsshim v0.11.4 // indirect
32+
github.com/Microsoft/go-winio v0.6.2 // indirect
33+
github.com/Microsoft/hcsshim v0.11.5 // indirect
3434
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
3535
github.com/agext/levenshtein v1.2.3 // indirect
3636
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
@@ -43,13 +43,14 @@ require (
4343
github.com/buger/jsonparser v1.1.1 // indirect
4444
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
4545
github.com/cloudflare/circl v1.3.7 // indirect
46-
github.com/containerd/containerd v1.7.15 // indirect
46+
github.com/containerd/containerd v1.7.18 // indirect
47+
github.com/containerd/errdefs v0.1.0 // indirect
4748
github.com/containerd/log v0.1.0 // indirect
4849
github.com/cpuguy83/dockercfg v0.3.1 // indirect
4950
github.com/davecgh/go-spew v1.1.1 // indirect
5051
github.com/dghubble/sling v1.4.1 // indirect
51-
github.com/distribution/reference v0.5.0 // indirect
52-
github.com/docker/docker v25.0.5+incompatible // indirect
52+
github.com/distribution/reference v0.6.0 // indirect
53+
github.com/docker/docker v27.0.3+incompatible // indirect
5354
github.com/docker/go-connections v0.5.0 // indirect
5455
github.com/docker/go-units v0.5.0 // indirect
5556
github.com/fatih/color v1.16.0 // indirect
@@ -91,7 +92,7 @@ require (
9192
github.com/imdario/mergo v0.3.15 // indirect
9293
github.com/jinzhu/copier v0.3.5 // indirect
9394
github.com/jmespath/go-jmespath v0.4.0 // indirect
94-
github.com/klauspost/compress v1.16.0 // indirect
95+
github.com/klauspost/compress v1.17.4 // indirect
9596
github.com/leodido/go-urn v1.2.2 // indirect
9697
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
9798
github.com/magiconair/properties v1.8.7 // indirect
@@ -106,6 +107,7 @@ require (
106107
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
107108
github.com/mitchellh/mapstructure v1.5.0 // indirect
108109
github.com/mitchellh/reflectwalk v1.0.2 // indirect
110+
github.com/moby/docker-image-spec v1.3.1 // indirect
109111
github.com/moby/patternmatcher v0.6.0 // indirect
110112
github.com/moby/sys/sequential v0.5.0 // indirect
111113
github.com/moby/sys/user v0.1.0 // indirect
@@ -125,7 +127,7 @@ require (
125127
github.com/shopspring/decimal v1.3.1 // indirect
126128
github.com/sirupsen/logrus v1.9.3 // indirect
127129
github.com/spf13/cast v1.5.0 // indirect
128-
github.com/testcontainers/testcontainers-go v0.31.0 // indirect
130+
github.com/testcontainers/testcontainers-go v0.32.0 // indirect
129131
github.com/tklauser/go-sysconf v0.3.12 // indirect
130132
github.com/tklauser/numcpus v0.6.1 // indirect
131133
github.com/tmccombs/hcl2json v0.3.6 // indirect

go.sum

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,20 @@ github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj
3636
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
3737
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
3838
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
39+
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
40+
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
3941
github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8=
4042
github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w=
43+
github.com/Microsoft/hcsshim v0.11.5 h1:haEcLNpj9Ka1gd3B3tAEs9CpE0c+1IhoL59w/exYU38=
44+
github.com/Microsoft/hcsshim v0.11.5/go.mod h1:MV8xMfmECjl5HdO7U/3/hFVnkmSBjAjmA09d4bExKcU=
4145
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.43.0 h1:fYwGBqG88xy3qHp5j1ySCztdqfw2NLfg2yp0N3XcBYg=
4246
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.43.0/go.mod h1:GZmFu6LmN8Yg0tEoZx3ytk9FnaH+84cWm7u5TdWZC6E=
4347
github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240502041300-f71244db277d h1:E0Rm52/XBlVzdkHET/+Js1FVVgf5/0oRk1tNkI4jcyk=
4448
github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240502041300-f71244db277d/go.mod h1:Nyg+7cyTrSQ/lMIy5YY1UdJekRuoMWf4uHIPfaGmgTM=
4549
github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240622231527-24df7b6eaa48 h1:lxcmT+JUYCe2pA7owBK47/z0jY3va03yl1sQA3n0/Xo=
4650
github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240622231527-24df7b6eaa48/go.mod h1:/QwYrEWP690YoKAR9lUVEv2y1Ta0HY08OaWb4LMZCAw=
51+
github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240729041805-46db6fb717b4 h1:QfbVf0bOIRMp/WHAWsuVDB7KHoWnRsGbvDuOf2ua7k4=
52+
github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240729041805-46db6fb717b4/go.mod h1:Oq9KbiRNDBB5jFmrwnrgLX0urIqR/1ptY18TzkqXm7M=
4753
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg=
4854
github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
4955
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
@@ -87,6 +93,10 @@ github.com/containerd/containerd v1.7.12 h1:+KQsnv4VnzyxWcfO9mlxxELaoztsDEjOuCMP
8793
github.com/containerd/containerd v1.7.12/go.mod h1:/5OMpE1p0ylxtEUGY8kuCYkDRzJm9NO1TFMWjUpdevk=
8894
github.com/containerd/containerd v1.7.15 h1:afEHXdil9iAm03BmhjzKyXnnEBtjaLJefdU7DV0IFes=
8995
github.com/containerd/containerd v1.7.15/go.mod h1:ISzRRTMF8EXNpJlTzyr2XMhN+j9K302C21/+cr3kUnY=
96+
github.com/containerd/containerd v1.7.18 h1:jqjZTQNfXGoEaZdW1WwPU0RqSn1Bm2Ay/KJPUuO8nao=
97+
github.com/containerd/containerd v1.7.18/go.mod h1:IYEk9/IO6wAPUz2bCMVUbsfXjzw5UNP5fLz4PsUygQ4=
98+
github.com/containerd/errdefs v0.1.0 h1:m0wCRBiu1WJT/Fr+iOoQHMQS/eP5myQ8lCv4Dz5ZURM=
99+
github.com/containerd/errdefs v0.1.0/go.mod h1:YgWiiHtLmSeBrvpw+UfPijzbLaB77mEG1WwJTDETIV0=
90100
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
91101
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
92102
github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E=
@@ -103,8 +113,12 @@ github.com/dghubble/sling v1.4.1 h1:AxjTubpVyozMvbBCtXcsWEyGGgUZutC5YGrfxPNVOcQ=
103113
github.com/dghubble/sling v1.4.1/go.mod h1:QoMB1KL3GAo+7HsD8Itd6S+6tW91who8BGZzuLvpOyc=
104114
github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0=
105115
github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
116+
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
117+
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
106118
github.com/docker/docker v25.0.5+incompatible h1:UmQydMduGkrD5nQde1mecF/YnSbTOaPeFIeP5C4W+DE=
107119
github.com/docker/docker v25.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
120+
github.com/docker/docker v27.0.3+incompatible h1:aBGI9TeQ4MPlhquTQKq9XbK79rKFVwXNUAYz9aXyEBE=
121+
github.com/docker/docker v27.0.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
108122
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
109123
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
110124
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
@@ -296,6 +310,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
296310
github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
297311
github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4=
298312
github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
313+
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
314+
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
299315
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
300316
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
301317
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
@@ -348,6 +364,8 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
348364
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
349365
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
350366
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
367+
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
368+
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
351369
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
352370
github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
353371
github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc=
@@ -425,6 +443,8 @@ github.com/testcontainers/testcontainers-go v0.30.0 h1:jmn/XS22q4YRrcMwWg0pAwlCl
425443
github.com/testcontainers/testcontainers-go v0.30.0/go.mod h1:K+kHNGiM5zjklKjgTtcrEetF3uhWbMUyqAQoyoh8Pf0=
426444
github.com/testcontainers/testcontainers-go v0.31.0 h1:W0VwIhcEVhRflwL9as3dhY6jXjVCA27AkmbnZ+UTh3U=
427445
github.com/testcontainers/testcontainers-go v0.31.0/go.mod h1:D2lAoA0zUFiSY+eAflqK5mcUx/A5hrrORaEQrd0SefI=
446+
github.com/testcontainers/testcontainers-go v0.32.0 h1:ug1aK08L3gCHdhknlTTwWjPHPS+/alvLJU/DRxTD/ME=
447+
github.com/testcontainers/testcontainers-go v0.32.0/go.mod h1:CRHrzHLQhlXUsa5gXjTOfqIEJcrK5+xMDmBr/WMI88E=
428448
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
429449
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
430450
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=

octopusdeploy/data_source_tenants.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ func dataSourceTenantsRead(ctx context.Context, d *schema.ResourceData, meta int
4444
flattenedTenants = append(flattenedTenants, flattenTenant(tenant))
4545
}
4646

47-
d.Set("tenants", flattenedTenants)
47+
err = d.Set("tenants", flattenedTenants)
48+
if err != nil {
49+
return diag.FromErr(err)
50+
}
51+
4852
d.SetId("Tenants " + time.Now().UTC().String())
4953

5054
return nil

octopusdeploy/schema_account_resource.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func getAccountResourceDataSchema() map[string]*schema.Schema {
5050
Description: "A list of accounts that match the filter(s).",
5151
Elem: &schema.Resource{Schema: dataSchema},
5252
Type: schema.TypeList,
53+
Optional: false,
5354
},
5455
"id": getDataSchemaID(),
5556
"space_id": getQuerySpaceID(),

octopusdeploy/schema_azure_cloud_service_deployment_target.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func getAzureCloudServiceDeploymentTargetDataSchema() map[string]*schema.Schema
7070
Computed: true,
7171
Description: "A list of Azure cloud service deployment targets that match the filter(s).",
7272
Elem: &schema.Resource{Schema: dataSchema},
73-
Optional: true,
73+
Optional: false,
7474
Type: schema.TypeList,
7575
}
7676

octopusdeploy/schema_azure_service_fabric_cluster_deployment_target.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func getAzureServiceFabricClusterDeploymentTargetDataSchema() map[string]*schema
8585
Computed: true,
8686
Description: "A list of Azure service fabric cluster deployment targets that match the filter(s).",
8787
Elem: &schema.Resource{Schema: dataSchema},
88-
Optional: true,
88+
Optional: false,
8989
Type: schema.TypeList,
9090
}
9191

octopusdeploy/schema_azure_web_app_deployment_target.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func getAzureWebAppDeploymentTargetDataSchema() map[string]*schema.Schema {
5555
Computed: true,
5656
Description: "A list of Azure web app deployment targets that match the filter(s).",
5757
Elem: &schema.Resource{Schema: dataSchema},
58-
Optional: true,
58+
Optional: false,
5959
Type: schema.TypeList,
6060
}
6161

octopusdeploy/schema_certificate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func getCertificateDataSchema() map[string]*schema.Schema {
170170
Computed: true,
171171
Description: "A list of certificates that match the filter(s).",
172172
Elem: &schema.Resource{Schema: dataSchema},
173-
Optional: true,
173+
Optional: false,
174174
Type: schema.TypeList,
175175
},
176176
"first_result": getQueryFirstResult(),

octopusdeploy/schema_channel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func getChannelDataSchema() map[string]*schema.Schema {
7373
Computed: true,
7474
Description: "A channel that matches the specified filter(s).",
7575
Elem: &schema.Resource{Schema: dataSchema},
76-
Optional: true,
76+
Optional: false,
7777
Type: schema.TypeList,
7878
},
7979
"ids": getQueryIDs(),

octopusdeploy/schema_cloud_region_deployment_target.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func getCloudRegionDeploymentTargetDataSchema() map[string]*schema.Schema {
4040
Computed: true,
4141
Description: "A list of cloud region deployment targets that match the filter(s).",
4242
Elem: &schema.Resource{Schema: dataSchema},
43-
Optional: true,
43+
Optional: false,
4444
Type: schema.TypeList,
4545
}
4646

0 commit comments

Comments
 (0)