fix(sources/cockroachdb): update kind to type (#2465)

Fix failing integration test, clean up source code from `kind` to
`type`.
This commit is contained in:
Yuan Teoh
2026-02-12 15:59:55 -08:00
committed by GitHub
parent f032389a07
commit 2d341acaa6
6 changed files with 32 additions and 57 deletions

View File

@@ -30,11 +30,11 @@ import (
"github.com/jackc/pgx/v5"
)
const kind string = "cockroachdb-execute-sql"
const resourceType string = "cockroachdb-execute-sql"
func init() {
if !tools.Register(kind, newConfig) {
panic(fmt.Sprintf("tool kind %q already registered", kind))
if !tools.Register(resourceType, newConfig) {
panic(fmt.Sprintf("tool type %q already registered", resourceType))
}
}
@@ -50,7 +50,7 @@ type compatibleSource interface {
Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
}
var compatibleSources = [...]string{cockroachdb.SourceKind}
var compatibleSources = [...]string{cockroachdb.SourceType}
type Config struct {
Name string `yaml:"name" validate:"required"`
@@ -62,12 +62,8 @@ type Config struct {
var _ tools.ToolConfig = Config{}
func (cfg Config) ToolConfigKind() string {
return kind
}
func (cfg Config) ToolConfigType() string {
return kind
return resourceType
}
func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error) {
@@ -78,7 +74,7 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
_, ok = rawS.(compatibleSource)
if !ok {
return nil, fmt.Errorf("invalid source for %q tool: source kind must be one of %q", kind, compatibleSources)
return nil, fmt.Errorf("invalid source for %q tool: source type must be one of %q", resourceType, compatibleSources)
}
sqlParameter := parameters.NewStringParameter("sql", "The sql to execute.")

View File

@@ -29,7 +29,7 @@ import (
"github.com/jackc/pgx/v5"
)
const kind string = "cockroachdb-list-schemas"
const resourceType string = "cockroachdb-list-schemas"
const listSchemasStatement = `
SELECT
@@ -44,8 +44,8 @@ const listSchemasStatement = `
`
func init() {
if !tools.Register(kind, newConfig) {
panic(fmt.Sprintf("tool kind %q already registered", kind))
if !tools.Register(resourceType, newConfig) {
panic(fmt.Sprintf("tool type %q already registered", resourceType))
}
}
@@ -63,7 +63,7 @@ type compatibleSource interface {
var _ compatibleSource = &cockroachdb.Source{}
var compatibleSources = [...]string{cockroachdb.SourceKind}
var compatibleSources = [...]string{cockroachdb.SourceType}
type Config struct {
Name string `yaml:"name" validate:"required"`
@@ -75,12 +75,8 @@ type Config struct {
var _ tools.ToolConfig = Config{}
func (cfg Config) ToolConfigKind() string {
return kind
}
func (cfg Config) ToolConfigType() string {
return kind
return resourceType
}
func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error) {
@@ -91,7 +87,7 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
_, ok = rawS.(compatibleSource)
if !ok {
return nil, fmt.Errorf("invalid source for %q tool: source kind must be one of %q", kind, compatibleSources)
return nil, fmt.Errorf("invalid source for %q tool: source type must be one of %q", resourceType, compatibleSources)
}
allParameters := parameters.Parameters{}

View File

@@ -29,7 +29,7 @@ import (
"github.com/jackc/pgx/v5"
)
const kind string = "cockroachdb-list-tables"
const resourceType string = "cockroachdb-list-tables"
const listTablesStatement = `
WITH desired_relkinds AS (
@@ -104,8 +104,8 @@ const listTablesStatement = `
`
func init() {
if !tools.Register(kind, newConfig) {
panic(fmt.Sprintf("tool kind %q already registered", kind))
if !tools.Register(resourceType, newConfig) {
panic(fmt.Sprintf("tool type %q already registered", resourceType))
}
}
@@ -123,7 +123,7 @@ type compatibleSource interface {
var _ compatibleSource = &cockroachdb.Source{}
var compatibleSources = [...]string{cockroachdb.SourceKind}
var compatibleSources = [...]string{cockroachdb.SourceType}
type Config struct {
Name string `yaml:"name" validate:"required"`
@@ -135,12 +135,8 @@ type Config struct {
var _ tools.ToolConfig = Config{}
func (cfg Config) ToolConfigKind() string {
return kind
}
func (cfg Config) ToolConfigType() string {
return kind
return resourceType
}
func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error) {
@@ -151,7 +147,7 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
_, ok = rawS.(compatibleSource)
if !ok {
return nil, fmt.Errorf("invalid source for %q tool: source kind must be one of %q", kind, compatibleSources)
return nil, fmt.Errorf("invalid source for %q tool: source type must be one of %q", resourceType, compatibleSources)
}
allParameters := parameters.Parameters{

View File

@@ -30,11 +30,11 @@ import (
"github.com/jackc/pgx/v5"
)
const kind string = "cockroachdb-sql"
const resourceType string = "cockroachdb-sql"
func init() {
if !tools.Register(kind, newConfig) {
panic(fmt.Sprintf("tool kind %q already registered", kind))
if !tools.Register(resourceType, newConfig) {
panic(fmt.Sprintf("tool type %q already registered", resourceType))
}
}
@@ -52,7 +52,7 @@ type compatibleSource interface {
var _ compatibleSource = &cockroachdb.Source{}
var compatibleSources = [...]string{cockroachdb.SourceKind}
var compatibleSources = [...]string{cockroachdb.SourceType}
type Config struct {
Name string `yaml:"name" validate:"required"`
@@ -67,12 +67,8 @@ type Config struct {
var _ tools.ToolConfig = Config{}
func (cfg Config) ToolConfigKind() string {
return kind
}
func (cfg Config) ToolConfigType() string {
return kind
return resourceType
}
func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error) {
@@ -83,7 +79,7 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
_, ok = rawS.(compatibleSource)
if !ok {
return nil, fmt.Errorf("invalid source for %q tool: source kind must be one of %q", kind, compatibleSources)
return nil, fmt.Errorf("invalid source for %q tool: source type must be one of %q", resourceType, compatibleSources)
}
allParameters, paramManifest, err := parameters.ProcessParameters(cfg.TemplateParameters, cfg.Parameters)