Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
scriptnull committed Nov 4, 2024
1 parent 88bb48a commit 48ba69e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
16 changes: 4 additions & 12 deletions internal/asset/cli_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,6 @@ type BinaryCLIPluginPlatform struct {
Bin string
}

func ParseConnectorMetadata(data []byte) (*ConnectorMetadataYAML, error) {
var connMetadata ConnectorMetadataYAML
err := yaml.Unmarshal(data, &connMetadata)
if err != nil {
return nil, err
}
return &connMetadata, nil
}

func ApplyCLIPluginTransform(connPkgs []ndchub.ConnectorPackaging) error {
var transform errgroup.Group
for _, cp := range connPkgs {
Expand All @@ -108,12 +99,13 @@ func ApplyCLIPluginTransform(connPkgs []ndchub.ConnectorPackaging) error {
return err
}

cmy, err := ParseConnectorMetadata(data)
var connMetadata ConnectorMetadataYAML
err = yaml.Unmarshal(data, &connMetadata)
if err != nil {
return nil
return err
}

if cliPlugin, ok := cmy.CLIPlugin.(*BinaryInlineCLIPluginDefinition); ok {
if cliPlugin, ok := connMetadata.CLIPlugin.(*BinaryInlineCLIPluginDefinition); ok {
for range cliPlugin.Platforms {

}
Expand Down
9 changes: 7 additions & 2 deletions internal/asset/cli_plugin_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package asset

import "testing"
import (
"testing"

"gopkg.in/yaml.v3"
)

func TestParseConnectorMetadata(t *testing.T) {
tt := []struct {
Expand Down Expand Up @@ -30,7 +34,8 @@ cliPlugin:

for _, tc := range tt {
t.Run(tc.Name, func(t *testing.T) {
connMetadata, err := ParseConnectorMetadata(tc.RawYAML)
connMetadata := new(ConnectorMetadataYAML)
err := yaml.Unmarshal(tc.RawYAML, &connMetadata)
if err != nil {
t.Error(err)
return
Expand Down

0 comments on commit 48ba69e

Please sign in to comment.