package resiproute

import (
	"embed"

	"github.com/opensvc/om3/v3/core/driver"
	"github.com/opensvc/om3/v3/core/keywords"
	"github.com/opensvc/om3/v3/core/manifest"
	"github.com/opensvc/om3/v3/core/naming"
)

var (
	//go:embed text
	fs embed.FS

	drvID = driver.NewID(driver.GroupIP, "route")

	kws = []*keywords.Keyword{
		{
			Attr:     "NetNS",
			Example:  "container#0",
			Option:   "netns",
			Required: true,
			Scopable: true,
			Text:     keywords.NewText(fs, "text/kw/netns"),
		},
		{
			Attr:     "Gateway",
			Option:   "gateway",
			Example:  "1.2.3.4",
			Required: true,
			Scopable: true,
			Text:     keywords.NewText(fs, "text/kw/gateway"),
		},
		{
			Attr:     "To",
			Example:  "192.168.100.0/24",
			Option:   "to",
			Required: true,
			Scopable: true,
			Text:     keywords.NewText(fs, "text/kw/to"),
		},
		{
			Attr:        "Dev",
			DefaultText: keywords.NewText(fs, "text/kw/dev.default"),
			Example:     "eth1",
			Option:      "dev",
			Required:    false,
			Scopable:    true,
			Text:        keywords.NewText(fs, "text/kw/dev"),
		},
	}
)

func init() {
	driver.Register(drvID, New)
}

func (t *T) DriverID() driver.ID {
	return drvID
}

// Manifest ...
func (t *T) Manifest() *manifest.T {
	m := manifest.New(drvID, t)
	m.Kinds.Or(naming.KindSvc)
	m.AddKeywords(kws...)
	return m
}
