Skip to content

Commit a72f8e0

Browse files
dak1n1alexsomesan
authored andcommitted
Remove StateUpgraders from data sources (#1109)
Remove StateUpgraders from data sources Data sources don't need their own StateUpgraders, since they are able to read data from resources that have had their states upgraded. Add a test to ensure a state-upgraded resource is readable by its corresponding data source.
1 parent d834dd9 commit a72f8e0

File tree

5 files changed

+297
-544
lines changed

5 files changed

+297
-544
lines changed

kubernetes/data_source_kubernetes_ingress.go

Lines changed: 80 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -10,66 +10,54 @@ import (
1010
)
1111

1212
func dataSourceKubernetesIngress() *schema.Resource {
13-
return &schema.Resource{
14-
ReadContext: dataSourceKubernetesIngressRead,
15-
StateUpgraders: []schema.StateUpgrader{
16-
{
17-
Type: dataSourceKubernetesIngressV0().CoreConfigSchema().ImpliedType(),
18-
Upgrade: dataSourceKubernetesIngressStateUpgradeV0,
19-
Version: 0,
20-
},
21-
},
22-
SchemaVersion: 1,
23-
Schema: dataSourceKubernetesIngressSchemaV1(),
24-
}
25-
}
26-
27-
func dataSourceKubernetesIngressSchemaV1() map[string]*schema.Schema {
2813
docHTTPIngressPath := networking.HTTPIngressPath{}.SwaggerDoc()
2914
docHTTPIngressRuleValue := networking.HTTPIngressPath{}.SwaggerDoc()
3015
docIngress := networking.Ingress{}.SwaggerDoc()
3116
docIngressTLS := networking.IngressTLS{}.SwaggerDoc()
3217
docIngressRule := networking.IngressRule{}.SwaggerDoc()
3318
docIngressSpec := networking.IngressSpec{}.SwaggerDoc()
3419

35-
return map[string]*schema.Schema{
36-
"metadata": namespacedMetadataSchema("ingress", false),
37-
"spec": {
38-
Type: schema.TypeList,
39-
Description: docIngress["spec"],
40-
Computed: true,
41-
Elem: &schema.Resource{
42-
Schema: map[string]*schema.Schema{
43-
"backend": backendSpecFields(defaultBackendDescription),
44-
"rule": {
45-
Type: schema.TypeList,
46-
Description: docIngressSpec["rules"],
47-
Computed: true,
48-
Elem: &schema.Resource{
49-
Schema: map[string]*schema.Schema{
50-
"host": {
51-
Type: schema.TypeString,
52-
Description: docIngressRule["host"],
53-
Computed: true,
54-
},
55-
"http": {
56-
Type: schema.TypeList,
57-
Computed: true,
58-
Description: docIngressRule[""],
59-
Elem: &schema.Resource{
60-
Schema: map[string]*schema.Schema{
61-
"path": {
62-
Type: schema.TypeList,
63-
Computed: true,
64-
Description: docHTTPIngressRuleValue["paths"],
65-
Elem: &schema.Resource{
66-
Schema: map[string]*schema.Schema{
67-
"path": {
68-
Type: schema.TypeString,
69-
Description: docHTTPIngressPath["path"],
70-
Computed: true,
20+
return &schema.Resource{
21+
ReadContext: dataSourceKubernetesIngressRead,
22+
Schema: map[string]*schema.Schema{
23+
"metadata": namespacedMetadataSchema("ingress", false),
24+
"spec": {
25+
Type: schema.TypeList,
26+
Description: docIngress["spec"],
27+
Computed: true,
28+
Elem: &schema.Resource{
29+
Schema: map[string]*schema.Schema{
30+
"backend": backendSpecFields(defaultBackendDescription),
31+
"rule": {
32+
Type: schema.TypeList,
33+
Description: docIngressSpec["rules"],
34+
Computed: true,
35+
Elem: &schema.Resource{
36+
Schema: map[string]*schema.Schema{
37+
"host": {
38+
Type: schema.TypeString,
39+
Description: docIngressRule["host"],
40+
Computed: true,
41+
},
42+
"http": {
43+
Type: schema.TypeList,
44+
Computed: true,
45+
Description: docIngressRule[""],
46+
Elem: &schema.Resource{
47+
Schema: map[string]*schema.Schema{
48+
"path": {
49+
Type: schema.TypeList,
50+
Computed: true,
51+
Description: docHTTPIngressRuleValue["paths"],
52+
Elem: &schema.Resource{
53+
Schema: map[string]*schema.Schema{
54+
"path": {
55+
Type: schema.TypeString,
56+
Description: docHTTPIngressPath["path"],
57+
Computed: true,
58+
},
59+
"backend": backendSpecFields(ruleBackedDescription),
7160
},
72-
"backend": backendSpecFields(ruleBackedDescription),
7361
},
7462
},
7563
},
@@ -78,52 +66,52 @@ func dataSourceKubernetesIngressSchemaV1() map[string]*schema.Schema {
7866
},
7967
},
8068
},
81-
},
82-
"tls": {
83-
Type: schema.TypeList,
84-
Description: docIngressSpec["tls"],
85-
Computed: true,
86-
Elem: &schema.Resource{
87-
Schema: map[string]*schema.Schema{
88-
"hosts": {
89-
Type: schema.TypeList,
90-
Description: docIngressTLS["hosts"],
91-
Computed: true,
92-
Elem: &schema.Schema{Type: schema.TypeString},
93-
},
94-
"secret_name": {
95-
Type: schema.TypeString,
96-
Description: docIngressTLS["secretName"],
97-
Computed: true,
69+
"tls": {
70+
Type: schema.TypeList,
71+
Description: docIngressSpec["tls"],
72+
Computed: true,
73+
Elem: &schema.Resource{
74+
Schema: map[string]*schema.Schema{
75+
"hosts": {
76+
Type: schema.TypeList,
77+
Description: docIngressTLS["hosts"],
78+
Computed: true,
79+
Elem: &schema.Schema{Type: schema.TypeString},
80+
},
81+
"secret_name": {
82+
Type: schema.TypeString,
83+
Description: docIngressTLS["secretName"],
84+
Computed: true,
85+
},
9886
},
9987
},
10088
},
10189
},
10290
},
10391
},
104-
},
105-
"status": {
106-
Type: schema.TypeList,
107-
Computed: true,
108-
Elem: &schema.Resource{
109-
Schema: map[string]*schema.Schema{
110-
"load_balancer": {
111-
Type: schema.TypeList,
112-
Computed: true,
113-
Elem: &schema.Resource{
114-
Schema: map[string]*schema.Schema{
115-
"ingress": {
116-
Type: schema.TypeList,
117-
Computed: true,
118-
Elem: &schema.Resource{
119-
Schema: map[string]*schema.Schema{
120-
"ip": {
121-
Type: schema.TypeString,
122-
Computed: true,
123-
},
124-
"hostname": {
125-
Type: schema.TypeString,
126-
Computed: true,
92+
"status": {
93+
Type: schema.TypeList,
94+
Computed: true,
95+
Elem: &schema.Resource{
96+
Schema: map[string]*schema.Schema{
97+
"load_balancer": {
98+
Type: schema.TypeList,
99+
Computed: true,
100+
Elem: &schema.Resource{
101+
Schema: map[string]*schema.Schema{
102+
"ingress": {
103+
Type: schema.TypeList,
104+
Computed: true,
105+
Elem: &schema.Resource{
106+
Schema: map[string]*schema.Schema{
107+
"ip": {
108+
Type: schema.TypeString,
109+
Computed: true,
110+
},
111+
"hostname": {
112+
Type: schema.TypeString,
113+
Computed: true,
114+
},
127115
},
128116
},
129117
},

kubernetes/data_source_kubernetes_ingress_migrate.go

Lines changed: 0 additions & 141 deletions
This file was deleted.

0 commit comments

Comments
 (0)