-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Update ressources state handling (& fix CREATE AS SELECT drop) #3
base: master
Are you sure you want to change the base?
WIP: Update ressources state handling (& fix CREATE AS SELECT drop) #3
Conversation
"The create and update function should always return the read function to ensure the state is reflected": https://www.terraform.io/docs/extend/writing-custom-providers.html#defining-resources
Note: It also fixes the `CREATE AS SELECT` drop problem at the same time
👋 @louich sorry I haven't had a change to take a look at the PR's, I should get some time time weekend |
@Mongey no problem. I just changed the reference here to use the Mongey/ksql#7 code including the |
@Mongey I'm starting to have a concern when writing the same code twice as type Resource struct {
Type string
}
func (r *Resource) GenerateResource() *schema.Resource {
return &schema.Resource{
Create: r.create,
Read: r.read,
Delete: r.delete,
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The name of the stream<Plug>_",
DiffSuppressFunc: DiffSuppressCaseSensitivity,
},
"query": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The query",
},
},
}
}
func (r *Resource) create(d *schema.ResourceData, meta interface{}) error {
...
return r.Read(d, meta)
}
func (r *Resource) read(d *schema.ResourceData, meta interface{}) error {
...
return nil
}
func (r *Resource) delete(d *schema.ResourceData, meta interface{}) error {
...
return nil
} and then use it like this: func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"url": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("KSQL_SERVER_URL", "http://localhost:8088"),
},
},
ConfigureFunc: providerConfigure,
ResourcesMap: map[string]*schema.Resource{
"ksql_table": Resource{"table"}.GenerateResource(),
"ksql_stream": Resource{"stream"}.GenerateResource(),
},
}
} 🤔 ?!? |
Refers to the issue #2