Skip to content

Commit a00b8d0

Browse files
authored
fix: Rename plugin type -> kind for consistency with existing configs (#1240)
I realized existing plugin configs use the word `kind` (e.g. `kind: source`) and not `type`. Let's just stick to one word everywhere for consistency.
1 parent dac3376 commit a00b8d0

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

plugin/plugin_package.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ const (
1111
GoArchArm64 = "arm64"
1212
)
1313

14-
type Type string
14+
type Kind string
1515

1616
const (
17-
TypeSource Type = "source"
18-
TypeDestination Type = "destination"
17+
KindSource Kind = "source"
18+
KindDestination Kind = "destination"
1919
)
2020

21-
func (t Type) Validate() error {
22-
switch t {
23-
case TypeSource, TypeDestination:
21+
func (k Kind) Validate() error {
22+
switch k {
23+
case KindSource, KindDestination:
2424
return nil
2525
default:
26-
return errors.New("invalid type: must be one of source, destination")
26+
return errors.New("invalid plugin kind: must be one of source, destination")
2727
}
2828
}
2929

serve/package.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This creates a directory with the plugin binaries, package.json and documentatio
3232
type PackageJSON struct {
3333
SchemaVersion int `json:"schema_version"`
3434
Name string `json:"name"`
35-
Type plugin.Type `json:"type"`
35+
Kind plugin.Kind `json:"kind"`
3636
Message string `json:"message"`
3737
Version string `json:"version"`
3838
Protocols []int `json:"protocols"`
@@ -200,12 +200,12 @@ func (*PluginServe) getModuleName(pluginDirectory string) (string, error) {
200200
return strings.TrimSpace(importPath), nil
201201
}
202202

203-
func (s *PluginServe) writePackageJSON(dir string, pluginType plugin.Type, pluginVersion, message string, targets []TargetBuild) error {
203+
func (s *PluginServe) writePackageJSON(dir string, pluginKind plugin.Kind, pluginVersion, message string, targets []TargetBuild) error {
204204
packageJSON := PackageJSON{
205205
SchemaVersion: 1,
206206
Name: s.plugin.Name(),
207207
Message: message,
208-
Type: pluginType,
208+
Kind: pluginKind,
209209
Version: pluginVersion,
210210
Protocols: s.versions,
211211
SupportedTargets: targets,
@@ -273,8 +273,8 @@ func (s *PluginServe) newCmdPluginPackage() *cobra.Command {
273273
Long: pluginPackageLong,
274274
Args: cobra.ExactArgs(3),
275275
RunE: func(cmd *cobra.Command, args []string) error {
276-
pluginType := plugin.Type(args[0])
277-
if err := pluginType.Validate(); err != nil {
276+
pluginKind := plugin.Kind(args[0])
277+
if err := pluginKind.Validate(); err != nil {
278278
return err
279279
}
280280
pluginVersion := args[1]
@@ -310,7 +310,7 @@ func (s *PluginServe) newCmdPluginPackage() *cobra.Command {
310310
}); err != nil {
311311
return err
312312
}
313-
if pluginType == plugin.TypeSource {
313+
if pluginKind == plugin.KindSource {
314314
if err := s.writeTablesJSON(cmd.Context(), distPath); err != nil {
315315
return err
316316
}
@@ -324,7 +324,7 @@ func (s *PluginServe) newCmdPluginPackage() *cobra.Command {
324324
}
325325
targets = append(targets, *targetBuild)
326326
}
327-
if err := s.writePackageJSON(distPath, pluginType, pluginVersion, message, targets); err != nil {
327+
if err := s.writePackageJSON(distPath, pluginKind, pluginVersion, message, targets); err != nil {
328328
return fmt.Errorf("failed to write manifest: %w", err)
329329
}
330330
if err := s.copyDocs(distPath, docsPath); err != nil {

serve/package_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ with multiple lines and **markdown**`
7878
expectPackage := PackageJSON{
7979
SchemaVersion: 1,
8080
Name: "testPlugin",
81-
Type: "source",
81+
Kind: "source",
8282
Message: msg,
8383
Version: "v1.2.3",
8484
Protocols: []int{3},
@@ -162,7 +162,7 @@ with multiple lines and **markdown**`
162162
expectPackage := PackageJSON{
163163
SchemaVersion: 1,
164164
Name: "testPlugin",
165-
Type: "destination",
165+
Kind: "destination",
166166
Message: msg,
167167
Version: "v1.2.3",
168168
Protocols: []int{3},

0 commit comments

Comments
 (0)