-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d75ad86
commit 3e41660
Showing
4 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package plugins | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/90poe/connectctl/internal/ctl" | ||
"github.com/90poe/connectctl/internal/version" | ||
"github.com/90poe/connectctl/pkg/client/connect" | ||
"github.com/90poe/connectctl/pkg/manager" | ||
"github.com/pkg/errors" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
type validatePluginsCmdParams struct { | ||
ClusterURL string | ||
Input string | ||
} | ||
|
||
func validatePluginsCmd() *cobra.Command { | ||
params := &validatePluginsCmdParams{} | ||
|
||
validateCmd := &cobra.Command{ | ||
Use: "validate", | ||
Short: "Validates plugin config", | ||
Long: "", | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
return doValidatePlugins(cmd, params) | ||
}, | ||
} | ||
|
||
ctl.AddClusterFlag(validateCmd, true, ¶ms.ClusterURL) | ||
ctl.AddInputFlag(validateCmd, true, ¶ms.Input) | ||
|
||
return validateCmd | ||
} | ||
|
||
func doValidatePlugins(_ *cobra.Command, params *validatePluginsCmdParams) error { | ||
config := &manager.Config{ | ||
ClusterURL: params.ClusterURL, | ||
Version: version.Version, | ||
} | ||
|
||
userAgent := fmt.Sprintf("90poe.io/connectctl/%s", version.Version) | ||
|
||
client, err := connect.NewClient(params.ClusterURL, connect.WithUserAgent(userAgent)) | ||
if err != nil { | ||
return errors.Wrap(err, "error creating connect client") | ||
} | ||
|
||
mngr, err := manager.NewConnectorsManager(client, config) | ||
if err != nil { | ||
return errors.Wrap(err, "error creating connectors manager") | ||
} | ||
|
||
//TODO remove | ||
if mngr != nil { | ||
return nil | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters