mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-04-09 03:02:26 -04:00
chore: update yaml tag for tools
This commit is contained in:
@@ -26,7 +26,7 @@ import (
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
)
|
||||
|
||||
const kind string = "postgres-list-installed-extensions"
|
||||
const resourceType string = "postgres-list-installed-extensions"
|
||||
|
||||
const listAvailableExtensionsQuery = `
|
||||
SELECT
|
||||
@@ -50,8 +50,8 @@ const listAvailableExtensionsQuery = `
|
||||
`
|
||||
|
||||
func init() {
|
||||
if !tools.Register(kind, newConfig) {
|
||||
panic(fmt.Sprintf("tool type %q already registered", kind))
|
||||
if !tools.Register(resourceType, newConfig) {
|
||||
panic(fmt.Sprintf("tool type %q already registered", resourceType))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ type compatibleSource interface {
|
||||
|
||||
type Config struct {
|
||||
Name string `yaml:"name" validate:"required"`
|
||||
Type string `yaml:"kind" validate:"required"`
|
||||
Type string `yaml:"type" validate:"required"`
|
||||
Source string `yaml:"source" validate:"required"`
|
||||
Description string `yaml:"description" validate:"required"`
|
||||
AuthRequired []string `yaml:"authRequired"`
|
||||
@@ -80,7 +80,7 @@ type Config struct {
|
||||
var _ tools.ToolConfig = Config{}
|
||||
|
||||
func (cfg Config) ToolConfigType() string {
|
||||
return kind
|
||||
return resourceType
|
||||
}
|
||||
|
||||
func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error) {
|
||||
|
||||
@@ -17,7 +17,6 @@ package postgreslistinstalledextensions_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
yaml "github.com/goccy/go-yaml"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/googleapis/genai-toolbox/internal/server"
|
||||
"github.com/googleapis/genai-toolbox/internal/testutils"
|
||||
@@ -37,14 +36,14 @@ func TestParseFromYamlPostgres(t *testing.T) {
|
||||
{
|
||||
desc: "basic example",
|
||||
in: `
|
||||
tools:
|
||||
example_tool:
|
||||
kind: postgres-list-installed-extensions
|
||||
source: my-pg-instance
|
||||
description: "some description"
|
||||
authRequired:
|
||||
- my-google-auth-service
|
||||
- other-auth-service
|
||||
kind: tools
|
||||
name: example_tool
|
||||
type: postgres-list-installed-extensions
|
||||
source: my-pg-instance
|
||||
description: "some description"
|
||||
authRequired:
|
||||
- my-google-auth-service
|
||||
- other-auth-service
|
||||
`,
|
||||
want: server.ToolConfigs{
|
||||
"example_tool": postgreslistinstalledextensions.Config{
|
||||
@@ -59,11 +58,11 @@ func TestParseFromYamlPostgres(t *testing.T) {
|
||||
{
|
||||
desc: "basic example without authRequired",
|
||||
in: `
|
||||
tools:
|
||||
example_tool:
|
||||
kind: postgres-list-installed-extensions
|
||||
source: my-pg-instance
|
||||
description: "some description"
|
||||
kind: tools
|
||||
name: example_tool
|
||||
type: postgres-list-installed-extensions
|
||||
source: my-pg-instance
|
||||
description: "some description"
|
||||
`,
|
||||
want: server.ToolConfigs{
|
||||
"example_tool": postgreslistinstalledextensions.Config{
|
||||
@@ -78,15 +77,12 @@ func TestParseFromYamlPostgres(t *testing.T) {
|
||||
}
|
||||
for _, tc := range tcs {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
got := struct {
|
||||
Tools server.ToolConfigs `yaml:"tools"`
|
||||
}{}
|
||||
// Parse contents
|
||||
err := yaml.UnmarshalContext(ctx, testutils.FormatYaml(tc.in), &got)
|
||||
_, _, _, got, _, _, err := server.UnmarshalResourceConfig(ctx, testutils.FormatYaml(tc.in))
|
||||
if err != nil {
|
||||
t.Fatalf("unable to unmarshal: %s", err)
|
||||
}
|
||||
if diff := cmp.Diff(tc.want, got.Tools); diff != "" {
|
||||
if diff := cmp.Diff(tc.want, got); diff != "" {
|
||||
t.Fatalf("incorrect parse: diff %v", diff)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user