mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-02-05 20:54:56 -05:00
refactor!: update Kind field to Type in source code (#2312)
Update source code `Kind` to `Type`. It's only changes within our code. Changes to yaml tag (that will affect users) will be done in later PRs. This is a breaking change since it updates telemetry's span attribute from `source_kind` to `source_type`. Related #817 Future updates will include: * Updating a preprocessing function to convert config file from v1 to v2 * Update unmarshal function for ToolsFile to convert config file (test will fail since the yaml tag is not yet updated). * Update yaml tag (test will pass).
This commit is contained in:
@@ -29,7 +29,7 @@ const kind string = "cloud-sql-create-users"
|
||||
|
||||
func init() {
|
||||
if !tools.Register(kind, newConfig) {
|
||||
panic(fmt.Sprintf("tool kind %q already registered", kind))
|
||||
panic(fmt.Sprintf("tool type %q already registered", kind))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ type compatibleSource interface {
|
||||
// Config defines the configuration for the create-user tool.
|
||||
type Config struct {
|
||||
Name string `yaml:"name" validate:"required"`
|
||||
Kind string `yaml:"kind" validate:"required"`
|
||||
Type string `yaml:"kind" validate:"required"`
|
||||
Source string `yaml:"source" validate:"required"`
|
||||
Description string `yaml:"description"`
|
||||
AuthRequired []string `yaml:"authRequired"`
|
||||
@@ -59,8 +59,8 @@ type Config struct {
|
||||
// validate interface
|
||||
var _ tools.ToolConfig = Config{}
|
||||
|
||||
// ToolConfigKind returns the kind of the tool.
|
||||
func (cfg Config) ToolConfigKind() string {
|
||||
// ToolConfigType returns the kind of the tool.
|
||||
func (cfg Config) ToolConfigType() string {
|
||||
return kind
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ func (t Tool) ToConfig() tools.ToolConfig {
|
||||
|
||||
// Invoke executes the tool's logic.
|
||||
func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) {
|
||||
source, err := tools.GetCompatibleSource[compatibleSource](resourceMgr, t.Source, t.Name, t.Kind)
|
||||
source, err := tools.GetCompatibleSource[compatibleSource](resourceMgr, t.Source, t.Name, t.Type)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -170,7 +170,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool {
|
||||
}
|
||||
|
||||
func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) (bool, error) {
|
||||
source, err := tools.GetCompatibleSource[compatibleSource](resourceMgr, t.Source, t.Name, t.Kind)
|
||||
source, err := tools.GetCompatibleSource[compatibleSource](resourceMgr, t.Source, t.Name, t.Type)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ func TestParseFromYaml(t *testing.T) {
|
||||
want: server.ToolConfigs{
|
||||
"create-user": cloudsqlcreateusers.Config{
|
||||
Name: "create-user",
|
||||
Kind: "cloud-sql-create-users",
|
||||
Type: "cloud-sql-create-users",
|
||||
Source: "my-source",
|
||||
Description: "some description",
|
||||
AuthRequired: []string{},
|
||||
|
||||
Reference in New Issue
Block a user