Open louich opened 5 years ago
👋 @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 https://github.com/Mongey/ksql/pull/7 code including the describe
and the fix for drop
on streams & tables running underlying persistent queries & so far so good... just a little struggle with go modules but it seems ok now
@Mongey I'm starting to have a concern when writing the same code twice as STREAM
& TABLE
KSQL
objects are on the same form (returning the same described payload for the matter). How would you feel going the path of a parametrized resource builder, something along the line of:
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(),
},
}
}
:thinking: ?!?
Refers to the issue #2