Object storage misc fixes (#82)
* Fix wrong reference * Fix schema * Fix mapFields not fetching credentials group id * Change expiration timestamp * Fix schema * Remove fields that don't come in the GET response * Add RFC3339SecondsOnly * Change expiration timestamp to not support fractional seconds * Set retry timeout * Harmonize expiration timestamp * Skip import check on credential keys * Add error check * Update docs * Change field description * Add test case, simplify test * Add test case, simplify test * Rename variable * Generate docs --------- Co-authored-by: Henrique Santos <henrique.santos@freiheit.com>
This commit is contained in:
parent
5a5ac6640c
commit
248b9834ff
11 changed files with 229 additions and 73 deletions
|
|
@ -270,21 +270,34 @@ func mapFields(credentialsGroupResp *objectstorage.CreateCredentialsGroupRespons
|
|||
}
|
||||
credentialsGroup := credentialsGroupResp.CredentialsGroup
|
||||
|
||||
mapCredentialsGroup(*credentialsGroup, model)
|
||||
err := mapCredentialsGroup(*credentialsGroup, model)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func mapCredentialsGroup(credentialsGroup objectstorage.CredentialsGroup, model *Model) {
|
||||
model.URN = types.StringPointerValue(credentialsGroup.Urn)
|
||||
model.Name = types.StringPointerValue(credentialsGroup.DisplayName)
|
||||
func mapCredentialsGroup(credentialsGroup objectstorage.CredentialsGroup, model *Model) error {
|
||||
var credentialsGroupId string
|
||||
if model.CredentialsGroupId.ValueString() != "" {
|
||||
credentialsGroupId = model.CredentialsGroupId.ValueString()
|
||||
} else if credentialsGroup.CredentialsGroupId != nil {
|
||||
credentialsGroupId = *credentialsGroup.CredentialsGroupId
|
||||
} else {
|
||||
return fmt.Errorf("credential id not present")
|
||||
}
|
||||
|
||||
idParts := []string{
|
||||
model.ProjectId.ValueString(),
|
||||
model.CredentialsGroupId.ValueString(),
|
||||
credentialsGroupId,
|
||||
}
|
||||
model.Id = types.StringValue(
|
||||
strings.Join(idParts, core.Separator),
|
||||
)
|
||||
model.CredentialsGroupId = types.StringValue(credentialsGroupId)
|
||||
model.URN = types.StringPointerValue(credentialsGroup.Urn)
|
||||
model.Name = types.StringPointerValue(credentialsGroup.DisplayName)
|
||||
return nil
|
||||
}
|
||||
|
||||
type objectStorageClient interface {
|
||||
|
|
@ -327,7 +340,10 @@ func readCredentialsGroups(ctx context.Context, model *Model, client objectStora
|
|||
continue
|
||||
}
|
||||
found = true
|
||||
mapCredentialsGroup(credentialsGroup, model)
|
||||
err = mapCredentialsGroup(credentialsGroup, model)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue