@@ -11,35 +11,25 @@ import (
11
11
)
12
12
13
13
func dataSourceScalewayAccountSSHKey () * schema.Resource {
14
+ dsSchema := datasourceSchemaFromResourceSchema (resourceScalewayAccountSSKKey ().Schema )
15
+ addOptionalFieldsToSchema (dsSchema , "name" )
16
+
17
+ dsSchema ["name" ].ConflictsWith = []string {"ssh_key_id" }
18
+ dsSchema ["ssh_key_id" ] = & schema.Schema {
19
+ Type : schema .TypeString ,
20
+ Optional : true ,
21
+ Description : "The ID of the SSH key" ,
22
+ ValidateFunc : validationUUID (),
23
+ }
24
+
14
25
return & schema.Resource {
15
26
ReadContext : dataSourceScalewayAccountSSHKeyRead ,
16
- Schema : map [string ]* schema.Schema {
17
- "name" : {
18
- Type : schema .TypeString ,
19
- Optional : true ,
20
- Computed : true ,
21
- Description : "The name of the SSH key" ,
22
- },
23
- "ssh_key_id" : {
24
- Type : schema .TypeString ,
25
- Optional : true ,
26
- Computed : true ,
27
- Description : "The ID of the SSH key" ,
28
- ValidateFunc : validationUUIDorUUIDWithLocality (),
29
- },
30
- "public_key" : {
31
- Type : schema .TypeString ,
32
- Computed : true ,
33
- Description : "The public SSH key" ,
34
- },
35
- "organization_id" : organizationIDSchema (),
36
- "project_id" : projectIDSchema (),
37
- },
27
+ Schema : dsSchema ,
38
28
}
39
29
}
40
30
41
- func dataSourceScalewayAccountSSHKeyRead (ctx context.Context , d * schema.ResourceData , m interface {}) diag.Diagnostics {
42
- accountAPI := accountAPI (m )
31
+ func dataSourceScalewayAccountSSHKeyRead (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
32
+ accountAPI := accountAPI (meta )
43
33
44
34
var sshKey * account.SSHKey
45
35
sshKeyID , ok := d .GetOk ("ssh_key_id" )
@@ -67,11 +57,7 @@ func dataSourceScalewayAccountSSHKeyRead(ctx context.Context, d *schema.Resource
67
57
}
68
58
69
59
d .SetId (sshKey .ID )
70
- _ = d .Set ("name" , sshKey .Name )
71
60
_ = d .Set ("ssh_key_id" , sshKey .ID )
72
- _ = d .Set ("public_key" , sshKey .PublicKey )
73
- _ = d .Set ("organization_id" , sshKey .OrganizationID )
74
- _ = d .Set ("project_id" , sshKey .ProjectID )
75
61
76
- return nil
62
+ return resourceScalewayAccountSSHKeyRead ( ctx , d , meta )
77
63
}
0 commit comments