4.11.0
This commit is contained in:
@@ -85,7 +85,7 @@ func flattenUserResource(d *schema.ResourceData, details *user.ItemUser) {
|
||||
d.Set("data", details.Data)
|
||||
d.Set("description", details.Description)
|
||||
d.Set("domain", details.Domain)
|
||||
d.Set("emailaddress", details.Emails)
|
||||
d.Set("emailaddress", details.Emails[0])
|
||||
d.Set("gid", details.GID)
|
||||
d.Set("groups", details.Groups)
|
||||
d.Set("guid", details.GUID)
|
||||
|
||||
156
internal/service/cloudbroker/user/old_schemas.go
Normal file
156
internal/service/cloudbroker/user/old_schemas.go
Normal file
@@ -0,0 +1,156 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||
)
|
||||
|
||||
func resourceUserV1() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"username": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "ID of user",
|
||||
},
|
||||
"emailaddress": {
|
||||
Type: schema.TypeList,
|
||||
Required: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
Description: "Email address of the user",
|
||||
},
|
||||
"password": {
|
||||
Type: schema.TypeString,
|
||||
Default: "strongpassword",
|
||||
Optional: true,
|
||||
Description: "password of user",
|
||||
},
|
||||
"provider_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "provider",
|
||||
ValidateFunc: validation.StringInSlice([]string{"bvs", "decs3o"}, false),
|
||||
},
|
||||
"groups": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
Description: "list of groups this user belongs to",
|
||||
},
|
||||
"ckey": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "ckey",
|
||||
},
|
||||
"meta": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
Description: "meta",
|
||||
},
|
||||
"active": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "active",
|
||||
},
|
||||
"apiaccess": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
Description: "list of apiaccess groups this user belongs to",
|
||||
},
|
||||
"blocked": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "is the user blocked",
|
||||
},
|
||||
"authkey": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "authkey",
|
||||
},
|
||||
"auth_keys": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
Description: "authkeys",
|
||||
},
|
||||
"data": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "data",
|
||||
},
|
||||
"description": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "description",
|
||||
},
|
||||
"domain": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "domain",
|
||||
},
|
||||
"gid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "gid",
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "guid",
|
||||
},
|
||||
"last_check": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "last_check",
|
||||
},
|
||||
"mobile": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
Description: "mobile",
|
||||
},
|
||||
"protected": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "protected",
|
||||
},
|
||||
"roles": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
Description: "roles",
|
||||
},
|
||||
"service_account": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "service_account",
|
||||
},
|
||||
"xmpp": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
Description: "xmpp",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -19,18 +19,11 @@ func resourceUserCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
|
||||
username := d.Get("username").(string)
|
||||
|
||||
emails := d.Get("emailaddress").([]interface{})
|
||||
|
||||
emailAddress := make([]string, 0, len(emails))
|
||||
|
||||
for _, v := range emails {
|
||||
|
||||
emailAddress = append(emailAddress, v.(string))
|
||||
}
|
||||
email := d.Get("emailaddress").(string)
|
||||
|
||||
createReq := user.CreateRequest{
|
||||
Username: username,
|
||||
EmailAddress: emailAddress,
|
||||
EmailAddress: email,
|
||||
}
|
||||
|
||||
if passwd, ok := d.GetOk("password"); ok {
|
||||
@@ -144,7 +137,7 @@ func resourceUserDelete(ctx context.Context, d *schema.ResourceData, m interface
|
||||
|
||||
func ResourceUser() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
SchemaVersion: 2,
|
||||
|
||||
CreateContext: resourceUserCreate,
|
||||
ReadContext: resourceUserRead,
|
||||
@@ -163,6 +156,14 @@ func ResourceUser() *schema.Resource {
|
||||
Default: &constants.Timeout600s,
|
||||
},
|
||||
|
||||
StateUpgraders: []schema.StateUpgrader{
|
||||
{
|
||||
Version: 1,
|
||||
Type: resourceUserV1().CoreConfigSchema().ImpliedType(),
|
||||
Upgrade: resourceUserUpgradeV1,
|
||||
},
|
||||
},
|
||||
|
||||
Schema: resourceUserSchemaMake(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,6 +167,11 @@ func dataSourceUserGetAuditSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "find all audits after point in time (unixtime)",
|
||||
},
|
||||
"sort_by": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "sort by one of supported fields, format ±",
|
||||
},
|
||||
"timestamp_to": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -416,12 +421,9 @@ func resourceUserSchemaMake() map[string]*schema.Schema {
|
||||
Description: "ID of user",
|
||||
},
|
||||
"emailaddress": {
|
||||
Type: schema.TypeList,
|
||||
Required: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
Description: "email addresses of the user",
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "email address of the user",
|
||||
},
|
||||
"password": {
|
||||
Type: schema.TypeString,
|
||||
|
||||
20
internal/service/cloudbroker/user/state_upgrader.go
Normal file
20
internal/service/cloudbroker/user/state_upgrader.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func resourceUserUpgradeV1(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
|
||||
log.Debug("resourceUserUpgradeV1: upgrading state from list to string")
|
||||
|
||||
if oldVal, ok := rawState["emailaddress"].([]interface{}); ok && len(oldVal) > 0 {
|
||||
if firstEmail, ok := oldVal[0].(string); ok {
|
||||
rawState["emailaddress"] = firstEmail
|
||||
log.Debugf("resourceUserUpgradeV1: converted emailaddress from list to string: %s", firstEmail)
|
||||
}
|
||||
}
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
@@ -60,6 +60,9 @@ func utilityUserGetAuditCheckPresence(ctx context.Context, d *schema.ResourceDat
|
||||
if timestampTo, ok := d.GetOk("timestamp_to"); ok {
|
||||
req.TimestampTo = uint64(timestampTo.(int))
|
||||
}
|
||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
||||
req.SortBy = sortBy.(string)
|
||||
}
|
||||
|
||||
if Page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(Page.(int))
|
||||
|
||||
Reference in New Issue
Block a user