Skip to content

Commit d148ae1

Browse files
committed
Create command skaffold and add config and context command
0 parents  commit d148ae1

13 files changed

Lines changed: 1566 additions & 0 deletions

File tree

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/kafkactl.iml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 222 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/cmd_config.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package cmd
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
"github.com/spf13/viper"
6+
)
7+
8+
func (cmd *Kafkactl) ConfigCmd() *cobra.Command {
9+
configCmd := &cobra.Command{
10+
Use: "config",
11+
Short: "Manage the kafkactl configuration",
12+
}
13+
14+
addContextCmd := &cobra.Command{
15+
Use: "add-context <NAME>",
16+
Args: cobra.ExactArgs(1),
17+
Short: "Add a new Kafka cluster to your configuration",
18+
RunE: cmd.runConfigAddContextCommand,
19+
}
20+
21+
addContextCmd.Flags().StringSliceP("broker", "b", nil, "Kafka Broker address")
22+
addContextCmd.MarkFlagRequired("broker")
23+
24+
configCmd.AddCommand(addContextCmd)
25+
26+
return configCmd
27+
}
28+
29+
func (cmd *Kafkactl) runConfigAddContextCommand(_ *cobra.Command, args []string) error {
30+
name := args[0]
31+
brokers := viper.GetStringSlice("broker")
32+
err := cmd.conf.AddContext(name, brokers...)
33+
if err != nil {
34+
return err
35+
}
36+
37+
return cmd.saveConfiguration()
38+
}

0 commit comments

Comments
 (0)