Skip to content

Commit b9dc247

Browse files
Refactored to use 'any' instead of 'interface{}' in secret_v1_data
1 parent 3602880 commit b9dc247

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

kubernetes/resource_kubernetes_secret_v1_data.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func resourceKubernetesSecretV1Data() *schema.Resource {
7373
}
7474

7575
func resourceKubernetesSecretV1DataCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
76-
metadata := expandMetadata(d.Get("metadata").([]interface{}))
76+
metadata := expandMetadata(d.Get("metadata").([]any))
7777
// Sets the resource id based on the metadata
7878
d.SetId(buildId(metadata))
7979

@@ -110,7 +110,7 @@ func resourceKubernetesSecretV1DataRead(ctx context.Context, d *schema.ResourceD
110110
return diag.FromErr(err)
111111
}
112112

113-
configuredData := d.Get("data").(map[string]interface{})
113+
configuredData := d.Get("data").(map[string]any)
114114

115115
// stripping out the data not managed by Terraform
116116
fieldManagerName := d.Get("field_manager").(string)
@@ -140,19 +140,19 @@ func resourceKubernetesSecretV1DataRead(ctx context.Context, d *schema.ResourceD
140140

141141
// getManagedSecretData reads the field manager metadata to discover which fields we're managing
142142
func getManagedSecretData(managedFields []v1.ManagedFieldsEntry, manager string) (map[string]interface{}, error) {
143-
var data map[string]interface{}
143+
var data map[string]any
144144
for _, m := range managedFields {
145145
// Only consider entries managed by the specified manager
146146
if m.Manager != manager {
147147
continue
148148
}
149-
var mm map[string]interface{}
149+
var mm map[string]any
150150
err := json.Unmarshal(m.FieldsV1.Raw, &mm)
151151
if err != nil {
152152
return nil, err
153153
}
154154
// Check if the "data" field exists and extract it
155-
if l, ok := mm["f:data"].(map[string]interface{}); ok {
155+
if l, ok := mm["f:data"].(map[string]any); ok {
156156
data = l
157157
}
158158
}
@@ -165,7 +165,7 @@ func resourceKubernetesSecretV1DataUpdate(ctx context.Context, d *schema.Resourc
165165
return diag.FromErr(err)
166166
}
167167

168-
metadata := expandMetadata(d.Get("metadata").([]interface{}))
168+
metadata := expandMetadata(d.Get("metadata").([]any))
169169
name := metadata.GetName()
170170
namespace := metadata.GetNamespace()
171171

@@ -182,11 +182,7 @@ func resourceKubernetesSecretV1DataUpdate(ctx context.Context, d *schema.Resourc
182182
}
183183

184184
// Craft the patch to update the data
185-
dataInterface := d.Get("data")
186-
data, ok := dataInterface.(map[string]interface{})
187-
if !ok {
188-
return diag.Errorf("Error casting data to map[string]interface{}")
189-
}
185+
data := d.Get("data").(map[string]any)
190186
if d.Id() == "" {
191187
// If we're deleting then we just patch with an empty data map
192188
data = map[string]interface{}{}
@@ -197,10 +193,10 @@ func resourceKubernetesSecretV1DataUpdate(ctx context.Context, d *schema.Resourc
197193
encodedData[k] = []byte(v.(string))
198194
}
199195

200-
patchobj := map[string]interface{}{
196+
patchobj := map[string]any{
201197
"apiVersion": "v1",
202198
"kind": "Secret",
203-
"metadata": map[string]interface{}{
199+
"metadata": map[string]any{
204200
"name": name,
205201
"namespace": namespace,
206202
},

0 commit comments

Comments
 (0)