Skip to content

Commit 0956f56

Browse files
josephholstencodycushing
authored andcommitted
console_history: validate length >= 10240 (#156)
1 parent 7598f30 commit 0956f56

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

data_source_obmcs_core_console_history_data.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ func ConsoleHistoryDataDatasource() *schema.Resource {
2727
"length": {
2828
Type: schema.TypeInt,
2929
Optional: true,
30+
// ShowConsoleHistoryData returns an error with length < 10240, though this is not documented in the API doc.
31+
ValidateFunc: func(i interface{}, k string) (s []string, es []error) {
32+
v, ok := i.(int)
33+
if !ok {
34+
es = append(es, fmt.Errorf("expected type of %s to be int", k))
35+
return
36+
}
37+
38+
if v < 10240 {
39+
es = append(es, fmt.Errorf("expected %s to be in the range (%d - %d), got %d", k, min, max, v))
40+
return
41+
}
42+
43+
return
44+
},
3045
},
3146
"offset": {
3247
Type: schema.TypeInt,

0 commit comments

Comments
 (0)