feat: added working rendering with plugins

This commit is contained in:
David Allen 2025-08-26 22:11:17 -06:00
parent fbdaf218eb
commit 1ebea8cb73
Signed by: towk
GPG key ID: 0430CDBE22619155
7 changed files with 139 additions and 81 deletions

View file

@ -82,21 +82,23 @@ func (p *SmdClient) Version() string { return "v0.0.1-alpha" }
func (p *SmdClient) Description() string { return "Fetchs data from SMD and writes to store" }
func (p *SmdClient) Metadata() makeshift.Metadata {
return makeshift.Metadata{
"author.name": "David J. Allen",
"author.email": "davidallendj@gmail.com",
"author.links": []string{
"https://github.com/davidallendj",
"https://git.towk2.me/towk",
"author": map[string]any{
"name": "David J. Allen",
"email": "davidallendj@gmail.com",
"links": []string{
"https://github.com/davidallendj",
"https://git.towk2.me/towk",
},
},
}
}
func (p *SmdClient) Init() error {
log.Debug().Str("plugin", p.Name()).Msg("smd.Init()")
log.Debug().Str("plugin", p.Name()).Msg("(smd) Init()")
return nil
}
func (p *SmdClient) Run(data storage.KVStore, args []string) error {
func (p *SmdClient) Run(store storage.KVStore, args []string) error {
// set all the defaults for variables
var (
client SmdClient
@ -104,6 +106,13 @@ func (p *SmdClient) Run(data storage.KVStore, args []string) error {
err error
)
log.Debug().
Str("plugin", p.Name()).
Strs("args", args).
Int("arg_count", len(args)).
Any("store", store).
Msg("(smd) Run()")
// if we have a client, try making the request for the ethernet interfaces
err = client.FetchEthernetInterfaces()
if err != nil {
@ -124,14 +133,14 @@ func (p *SmdClient) Run(data storage.KVStore, args []string) error {
if err != nil {
return fmt.Errorf("(smd) failed to marshal SMD client: %v")
}
data.Set("shared", bytes)
store.Set("shared", bytes)
// apply template substitutions and return output as byte array
return nil
}
func (p *SmdClient) Cleanup() error {
log.Debug().Str("plugin", p.Name()).Msg("smd.Init()")
log.Debug().Str("plugin", p.Name()).Msg("(smd) Init()")
return nil
}