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:
Henrique Santos 2023-10-13 15:02:48 +01:00 committed by GitHub
parent 5a5ac6640c
commit 248b9834ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 229 additions and 73 deletions

View file

@ -6,6 +6,7 @@ import (
"net"
"regexp"
"strings"
"time"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag"
@ -108,3 +109,31 @@ func MinorVersionNumber() *Validator {
},
}
}
func RFC3339SecondsOnly() *Validator {
description := "value must be in RFC339 format (seconds only)"
return &Validator{
description: description,
validate: func(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) {
t, err := time.Parse(time.RFC3339, req.ConfigValue.ValueString())
if err != nil {
resp.Diagnostics.Append(validatordiag.InvalidAttributeValueDiagnostic(
req.Path,
description,
req.ConfigValue.ValueString(),
))
return
}
// Check if it failed because it has nanoseconds
if t.Nanosecond() != 0 {
resp.Diagnostics.Append(validatordiag.InvalidAttributeValueDiagnostic(
req.Path,
"value can't have fractional seconds",
req.ConfigValue.ValueString(),
))
}
},
}
}