From 5845408d5d8eb7fc0b7fafa0c9fdfdf2b3870c1b Mon Sep 17 00:00:00 2001 From: David Allen Date: Wed, 26 Jun 2024 13:41:57 -0600 Subject: [PATCH] Added example generator plugin --- internal/generator/plugins/example/example.go | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 internal/generator/plugins/example/example.go diff --git a/internal/generator/plugins/example/example.go b/internal/generator/plugins/example/example.go new file mode 100644 index 0000000..044bcf7 --- /dev/null +++ b/internal/generator/plugins/example/example.go @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + + configurator "github.com/OpenCHAMI/configurator/internal" + "github.com/OpenCHAMI/configurator/internal/generator" + "github.com/OpenCHAMI/configurator/internal/util" +) + +type Example struct { + Message string +} + +func (g *Example) GetName() string { + return "example" +} + +func (g *Example) GetVersion() string { + return util.GitCommit() +} + +func (g *Example) GetDescription() string { + return fmt.Sprintf("Configurator generator plugin for '%s'.", g.GetName()) +} + +func (g *Example) Generate(config *configurator.Config, opts ...util.Option) (generator.Files, error) { + g.Message = ` + This is an example generator plugin. See the file in 'internal/generator/plugins/example/example.go' on + information about constructing plugins and plugin requirements.` + return generator.Files{"example": []byte(g.Message)}, nil +}