feat: add model serving resource

* add model serving

* add right provider config

* rename model_serving to modelserving

* add model serving custom endpoint everywhere

* rename file

* add default region, docs for model serving

* add right order of wait handler

* rotate after to token

* fixes

* add initial doc files

* address code comments

* refactor region description

* remove warning for not found resources

* add service enablement

* address code comments

* address code comments

* fix datasource

* fix acc test

* review changes

* review changes

* review changes

* review changes

* review changes

* review changes

* review changes

* review changes

* review changes

* embed markdown description

* go tidy

---------

Co-authored-by: Mauritz Uphoff <mauritz.uphoff@me.com>
Co-authored-by: Mauritz Uphoff <39736813+h3adex@users.noreply.github.com>
This commit is contained in:
Patrick Koss 2025-03-28 16:20:25 +01:00 committed by GitHub
parent 68859a3fad
commit 435de4c9eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 1436 additions and 45 deletions

View file

@ -295,3 +295,21 @@ func FileExists() *Validator {
},
}
}
func ValidDurationString() *Validator {
description := "value must be in a valid duration string. Such as \"300ms\", \"-1.5h\" or \"2h45m\".\nValid time units are \"ns\", \"us\" (or \"µs\"), \"ms\", \"s\", \"m\", \"h\"."
return &Validator{
description: description,
validate: func(_ context.Context, req validator.StringRequest, resp *validator.StringResponse) {
_, err := time.ParseDuration(req.ConfigValue.ValueString())
if err != nil {
resp.Diagnostics.Append(validatordiag.InvalidAttributeValueDiagnostic(
req.Path,
description,
req.ConfigValue.ValueString(),
))
}
},
}
}

View file

@ -769,3 +769,79 @@ func TestFileExists(t *testing.T) {
})
}
}
func TestValidTtlDuration(t *testing.T) {
tests := []struct {
description string
input string
isValid bool
}{
{
"valid duration with hours, minutes, and seconds",
"5h30m40s",
true,
},
{
"valid duration with hours only",
"5h",
true,
},
{
"valid duration with hours and minutes",
"5h30m",
true,
},
{
"valid duration with minutes only",
"30m",
true,
},
{
"valid duration with seconds only",
"30s",
true,
},
{
"invalid duration with incorrect unit",
"30o",
false,
},
{
"invalid duration without unit",
"30",
false,
},
{
"invalid duration with invalid letters",
"30e",
false,
},
{
"invalid duration with letters in middle",
"1h30x",
false,
},
{
"empty string",
"",
false,
},
}
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
r := validator.StringResponse{}
va := ValidDurationString()
va.ValidateString(context.Background(), validator.StringRequest{
ConfigValue: types.StringValue(tt.input),
}, &r)
if !tt.isValid && !r.Diagnostics.HasError() {
t.Fatalf("Expected validation to fail for input: %v", tt.input)
}
if tt.isValid && r.Diagnostics.HasError() {
t.Fatalf("Expected validation to succeed for input: %v, but got errors: %v", tt.input, r.Diagnostics.Errors())
}
})
}
}