@@ -5,7 +5,6 @@ package kubernetes
55
66import (
77 "context"
8- "fmt"
98 "log"
109
1110 "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -26,29 +25,7 @@ func resourceKubernetesConfigMapV1() *schema.Resource {
2625 UpdateContext : resourceKubernetesConfigMapV1Update ,
2726 DeleteContext : resourceKubernetesConfigMapV1Delete ,
2827 Importer : & schema.ResourceImporter {
29- StateContext : func (ctx context.Context , rd * schema.ResourceData , i interface {}) ([]* schema.ResourceData , error ) {
30- if rd .Id () != "" {
31- return []* schema.ResourceData {rd }, nil
32- }
33-
34- rid , err := rd .Identity ()
35- if err != nil {
36- return nil , err
37- }
38-
39- namespace , ok := rid .Get ("namespace" ).(string )
40- if ! ok {
41- return nil , fmt .Errorf ("could not get namespace from resource identity" )
42- }
43- name , ok := rid .Get ("name" ).(string )
44- if ! ok {
45- return nil , fmt .Errorf ("could not get name from resource identity" )
46- }
47-
48- rd .SetId (fmt .Sprintf ("%s/%s" , namespace , name ))
49-
50- return []* schema.ResourceData {rd }, nil
51- },
28+ StateContext : resourceIdentityImportNamespaced ,
5229 },
5330 CustomizeDiff : func (ctx context.Context , diff * schema.ResourceDiff , meta interface {}) error {
5431 if diff .Id () == "" {
@@ -73,29 +50,7 @@ func resourceKubernetesConfigMapV1() *schema.Resource {
7350
7451 return nil
7552 },
76- Identity : & schema.ResourceIdentity {
77- Version : 1 ,
78- SchemaFunc : func () map [string ]* schema.Schema {
79- return map [string ]* schema.Schema {
80- "namespace" : {
81- Type : schema .TypeString ,
82- OptionalForImport : true ,
83- },
84- "name" : {
85- Type : schema .TypeString ,
86- RequiredForImport : true ,
87- },
88- "api_version" : {
89- Type : schema .TypeString ,
90- RequiredForImport : true ,
91- },
92- "kind" : {
93- Type : schema .TypeString ,
94- RequiredForImport : true ,
95- },
96- }
97- },
98- },
53+ Identity : resourceIdentitySchemaNamespaced (),
9954 Schema : map [string ]* schema.Schema {
10055 "metadata" : namespacedMetadataSchema ("config map" , true ),
10156 "binary_data" : {
0 commit comments