-
Notifications
You must be signed in to change notification settings - Fork 10
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
9c64c58
commit b25b107
Showing
23 changed files
with
999 additions
and
728 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package connect | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/c-bata/go-prompt" | ||
schedv1 "github.com/confluentinc/cc-structs/kafka/scheduler/v1" | ||
opv1 "github.com/confluentinc/cc-structs/operator/v1" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/confluentinc/cli/internal/pkg/shell/completer" | ||
) | ||
|
||
func (c *command) Cmd() *cobra.Command { | ||
return c.Command | ||
} | ||
|
||
func (c *command) ServerCompletableChildren() []*cobra.Command { | ||
return c.completableChildren | ||
} | ||
|
||
func (c *command) ServerComplete() []prompt.Suggest { | ||
var suggestions []prompt.Suggest | ||
connectors, err := c.fetchConnectors() | ||
if err != nil { | ||
return suggestions | ||
} | ||
for _, conn := range connectors { | ||
suggestions = append(suggestions, prompt.Suggest{ | ||
Text: conn.Id.Id, | ||
Description: conn.Info.Name, | ||
}) | ||
} | ||
return suggestions | ||
} | ||
|
||
func (c *command) fetchConnectors() (map[string]*opv1.ConnectorExpansion, error) { | ||
kafkaCluster, err := c.Context.GetKafkaClusterForCommand(c.Command) | ||
if err != nil { | ||
return nil, err | ||
} | ||
connectors, err := c.Client.Connect.ListWithExpansions(context.Background(), &schedv1.Connector{AccountId: c.EnvironmentId(), KafkaClusterId: kafkaCluster.ID}, "status,info,id") | ||
if err != nil { | ||
return nil, err | ||
} | ||
return connectors, nil | ||
|
||
} | ||
|
||
func (c *command) ServerCompletableFlagChildren() map[string][]*cobra.Command { | ||
return c.completableFlagChildren | ||
} | ||
|
||
func (c *command) ServerFlagComplete() map[string]func() []prompt.Suggest { | ||
return map[string]func() []prompt.Suggest{ | ||
"cluster": completer.ClusterFlagServerCompleterFunc(c.Client, c.EnvironmentId()), | ||
} | ||
} | ||
|
||
func (c *pluginCommand) Cmd() *cobra.Command { | ||
return c.Command | ||
} | ||
|
||
func (c *pluginCommand) ServerComplete() []prompt.Suggest { | ||
var suggestions []prompt.Suggest | ||
plugins, err := c.getPlugins(c.Command) | ||
if err != nil { | ||
return suggestions | ||
} | ||
for _, conn := range plugins { | ||
suggestions = append(suggestions, prompt.Suggest{ | ||
Text: conn.Class, | ||
Description: conn.Type, | ||
}) | ||
} | ||
return suggestions | ||
} | ||
|
||
func (c *pluginCommand) ServerCompletableChildren() []*cobra.Command { | ||
return c.completableChildren | ||
} |
Oops, something went wrong.