@@ -141,19 +141,23 @@ func (b *backend) staticRoleExistenceCheck(ctx context.Context, r *logical.Reque
141141}
142142
143143type roleStaticEntry struct {
144- Name string `json:"name"`
145- Cloud string `json:"cloud"`
146- TTL time.Duration `json:"ttl,omitempty"`
147- RotationDuration time.Duration `json:"rotation_duration,omitempty"`
148- SecretType secretType `json:"secret_type"`
149- Secret string `json:"secret"`
150- Username string `json:"username"`
151- UserID string `json:"user_id"`
152- ProjectID string `json:"project_id"`
153- ProjectName string `json:"project_name"`
154- DomainID string `json:"domain_id"`
155- DomainName string `json:"domain_name"`
156- Extensions map [string ]string `json:"extensions"`
144+ Name string `json:"name"`
145+ Cloud string `json:"cloud"`
146+ TTL time.Duration `json:"ttl,omitempty"`
147+ RotationDuration time.Duration `json:"rotation_duration,omitempty"`
148+ SecretType secretType `json:"secret_type"`
149+ Secret string `json:"secret"`
150+ Username string `json:"username"`
151+ UserID string `json:"user_id"`
152+ ProjectID string `json:"project_id"`
153+ ProjectName string `json:"project_name"`
154+ DomainID string `json:"domain_id"`
155+ DomainName string `json:"domain_name"`
156+ UserDomainID string `json:"user_domain_id"`
157+ UserDomainName string `json:"user_domain_name"`
158+ ProjectDomainID string `json:"project_domain_id"`
159+ ProjectDomainName string `json:"project_domain_name"`
160+ Extensions map [string ]string `json:"extensions"`
157161}
158162
159163func roleStaticStoragePath (name string ) string {
@@ -193,15 +197,19 @@ func getStaticRoleByName(ctx context.Context, name string, s *logical.Request) (
193197
194198func staticRoleToMap (src * roleStaticEntry ) map [string ]interface {} {
195199 return map [string ]interface {}{
196- "cloud" : src .Cloud ,
197- "rotation_duration" : src .RotationDuration ,
198- "secret_type" : string (src .SecretType ),
199- "username" : src .Username ,
200- "project_id" : src .ProjectID ,
201- "project_name" : src .ProjectName ,
202- "domain_id" : src .DomainID ,
203- "domain_name" : src .DomainName ,
204- "extensions" : src .Extensions ,
200+ "cloud" : src .Cloud ,
201+ "rotation_duration" : src .RotationDuration ,
202+ "secret_type" : string (src .SecretType ),
203+ "username" : src .Username ,
204+ "project_id" : src .ProjectID ,
205+ "project_name" : src .ProjectName ,
206+ "domain_id" : src .DomainID ,
207+ "domain_name" : src .DomainName ,
208+ "user_domain_id" : src .UserDomainID ,
209+ "user_domain_name" : src .UserDomainName ,
210+ "project_domain_id" : src .ProjectDomainID ,
211+ "project_domain_name" : src .ProjectDomainName ,
212+ "extensions" : src .Extensions ,
205213 }
206214}
207215
@@ -255,16 +263,25 @@ func (b *backend) pathStaticRoleUpdate(ctx context.Context, req *logical.Request
255263 entry = & roleStaticEntry {Name : name , Cloud : cloudName }
256264 }
257265
266+ if name , ok := d .GetOk ("user_domain_name" ); ok {
267+ entry .UserDomainName = name .(string )
268+ }
269+
270+ if id , ok := d .GetOk ("user_domain_id" ); ok {
271+ entry .UserDomainID = id .(string )
272+ }
273+
258274 if username , ok := d .GetOk ("username" ); ok {
259275 entry .Username = username .(string )
260276 password , err := Passwords {}.Generate (ctx )
261277 if err != nil {
262278 return nil , err
263279 }
264280
281+ // TODO: implement situation where userDomainId != currentDomainID
265282 userId , err := b .rotateUserPassword (ctx , req , cloud , username .(string ), password )
266283 if err != nil {
267- return logical .ErrorResponse ("error during role creation: %s " , err ), nil
284+ return logical .ErrorResponse ("error during role creation: %w " , err ), nil
268285 }
269286
270287 entry .UserID = userId
@@ -304,6 +321,14 @@ func (b *backend) pathStaticRoleUpdate(ctx context.Context, req *logical.Request
304321 entry .DomainID = id .(string )
305322 }
306323
324+ if name , ok := d .GetOk ("project_domain_name" ); ok {
325+ entry .ProjectDomainName = name .(string )
326+ }
327+
328+ if id , ok := d .GetOk ("project_domain_id" ); ok {
329+ entry .ProjectDomainID = id .(string )
330+ }
331+
307332 if ext , ok := d .GetOk ("extensions" ); ok {
308333 entry .Extensions = ext .(map [string ]string )
309334 }
0 commit comments