Skip to content

Commit

Permalink
Add support for ephemeral resources (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko authored Oct 2, 2024
1 parent 3b3d508 commit 51492df
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ type ProviderSchema struct {
// The schemas for any data sources in this provider.
DataSourceSchemas map[string]*Schema `json:"data_source_schemas,omitempty"`

// The schemas for any ephemeral resources in this provider.
EphemeralResourceSchemas map[string]*Schema `json:"ephemeral_resource_schemas,omitempty"`

// The definitions for any functions in this provider.
Functions map[string]*FunctionSignature `json:"functions,omitempty"`
}
Expand Down
17 changes: 17 additions & 0 deletions schemas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@ func TestProviderSchemasValidate_functions(t *testing.T) {
}
}

func TestProviderSchemasValidate_ephemeralResources(t *testing.T) {
f, err := os.Open("testdata/ephemeral_resources/schemas.json")
if err != nil {
t.Fatal(err)
}
defer f.Close()

var schemas *ProviderSchemas
if err := json.NewDecoder(f).Decode(&schemas); err != nil {
t.Fatal(err)
}

if err := schemas.Validate(); err != nil {
t.Fatal(err)
}
}

func TestProviderSchemasValidate_nestedAttributes(t *testing.T) {
f, err := os.Open("testdata/nested_attributes/schemas.json")
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions testdata/ephemeral_resources/schemas.json
Original file line number Diff line number Diff line change
@@ -0,0 +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 comments on commit 51492df

Please sign in to comment.