Skip to content

Commit 51492df

Browse files
authored
Add support for ephemeral resources (#138)
1 parent 3b3d508 commit 51492df

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

schemas.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ type ProviderSchema struct {
8787
// The schemas for any data sources in this provider.
8888
DataSourceSchemas map[string]*Schema `json:"data_source_schemas,omitempty"`
8989

90+
// The schemas for any ephemeral resources in this provider.
91+
EphemeralResourceSchemas map[string]*Schema `json:"ephemeral_resource_schemas,omitempty"`
92+
9093
// The definitions for any functions in this provider.
9194
Functions map[string]*FunctionSignature `json:"functions,omitempty"`
9295
}

schemas_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,23 @@ func TestProviderSchemasValidate_functions(t *testing.T) {
4343
}
4444
}
4545

46+
func TestProviderSchemasValidate_ephemeralResources(t *testing.T) {
47+
f, err := os.Open("testdata/ephemeral_resources/schemas.json")
48+
if err != nil {
49+
t.Fatal(err)
50+
}
51+
defer f.Close()
52+
53+
var schemas *ProviderSchemas
54+
if err := json.NewDecoder(f).Decode(&schemas); err != nil {
55+
t.Fatal(err)
56+
}
57+
58+
if err := schemas.Validate(); err != nil {
59+
t.Fatal(err)
60+
}
61+
}
62+
4663
func TestProviderSchemasValidate_nestedAttributes(t *testing.T) {
4764
f, err := os.Open("testdata/nested_attributes/schemas.json")
4865
if err != nil {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"format_version":"1.0","provider_schemas":{"registry.terraform.io/hashicorp/random":{"provider":{"version":0,"block":{"description_kind":"plain"}},"ephemeral_resource_schemas":{"random_password":{"version":0,"block":{"attributes":{"bcrypt_hash":{"type":"string","description":"A bcrypt hash of the generated random string. **NOTE**: If the generated random string is greater than 72 bytes in length, `bcrypt_hash` will contain a hash of the first 72 bytes.","description_kind":"plain","computed":true,"sensitive":true},"length":{"type":"number","description":"The length of the string desired. The minimum value for length is 1 and, length must also be \u003e= (`min_upper` + `min_lower` + `min_numeric` + `min_special`).","description_kind":"plain","required":true},"lower":{"type":"bool","description":"Include lowercase alphabet characters in the result. Default value is `true`.","description_kind":"plain","optional":true,"computed":true},"min_lower":{"type":"number","description":"Minimum number of lowercase alphabet characters in the result. Default value is `0`.","description_kind":"plain","optional":true,"computed":true},"min_numeric":{"type":"number","description":"Minimum number of numeric characters in the result. Default value is `0`.","description_kind":"plain","optional":true,"computed":true},"min_special":{"type":"number","description":"Minimum number of special characters in the result. Default value is `0`.","description_kind":"plain","optional":true,"computed":true},"min_upper":{"type":"number","description":"Minimum number of uppercase alphabet characters in the result. Default value is `0`.","description_kind":"plain","optional":true,"computed":true},"numeric":{"type":"bool","description":"Include numeric characters in the result. Default value is `true`. If `numeric`, `upper`, `lower`, and `special` are all configured, at least one of them must be set to `true`.","description_kind":"plain","optional":true,"computed":true},"override_special":{"type":"string","description":"Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument. The `special` argument must still be set to true for any overwritten characters to be used in generation.","description_kind":"plain","optional":true},"result":{"type":"string","description":"The generated random string.","description_kind":"plain","computed":true,"sensitive":true},"special":{"type":"bool","description":"Include special characters in the result. These are `!@#$%\u0026*()-_=+[]{}\u003c\u003e:?`. Default value is `true`.","description_kind":"plain","optional":true,"computed":true},"upper":{"type":"bool","description":"Include uppercase alphabet characters in the result. Default value is `true`.","description_kind":"plain","optional":true,"computed":true}},"description_kind":"plain"}}}}}}

0 commit comments

Comments
 (0)