mirror of
https://github.com/harivansh-afk/agentikube.git
synced 2026-04-21 15:01:29 +00:00
init
This commit is contained in:
commit
0595d93c49
28 changed files with 1763 additions and 0 deletions
51
internal/manifest/generate.go
Normal file
51
internal/manifest/generate.go
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
package manifest
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"text/template"
|
||||
|
||||
"github.com/rathi/agentikube/internal/config"
|
||||
)
|
||||
|
||||
// Generate renders all applicable Kubernetes manifests from the embedded
|
||||
// templates using the provided configuration. Templates are selected based
|
||||
// on the compute type and warm pool settings.
|
||||
func Generate(cfg *config.Config) ([]byte, error) {
|
||||
tmpl, err := template.ParseFS(templateFS, "templates/*.yaml.tmpl")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parsing templates: %w", err)
|
||||
}
|
||||
|
||||
// Always-rendered templates
|
||||
names := []string{
|
||||
"namespace.yaml.tmpl",
|
||||
"storageclass-efs.yaml.tmpl",
|
||||
"sandbox-template.yaml.tmpl",
|
||||
}
|
||||
|
||||
// Conditionally add Karpenter templates
|
||||
if cfg.Compute.Type == "karpenter" {
|
||||
names = append(names,
|
||||
"karpenter-nodepool.yaml.tmpl",
|
||||
"karpenter-ec2nodeclass.yaml.tmpl",
|
||||
)
|
||||
}
|
||||
|
||||
// Conditionally add warm pool template
|
||||
if cfg.Sandbox.WarmPool.Enabled {
|
||||
names = append(names, "warm-pool.yaml.tmpl")
|
||||
}
|
||||
|
||||
var out bytes.Buffer
|
||||
for i, name := range names {
|
||||
if i > 0 {
|
||||
out.WriteString("---\n")
|
||||
}
|
||||
if err := tmpl.ExecuteTemplate(&out, name, cfg); err != nil {
|
||||
return nil, fmt.Errorf("rendering template %s: %w", name, err)
|
||||
}
|
||||
}
|
||||
|
||||
return out.Bytes(), nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue