Skip to content

Commit f270e98

Browse files
committed
Remove init()
1 parent 396374a commit f270e98

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

main.go

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -96,32 +96,6 @@ const (
9696
Default = "\033[0m"
9797
)
9898

99-
func init() {
100-
flag.StringVar(&broker, "broker", "", "Bootstrap-brokers, default is localhost:9092 (can be also set by Env variable KAFKA_BROKER)")
101-
flag.StringVar(&specfile, "spec", "", "Spec-file (can be set by Env variable KAFKA_SPEC_FILE)")
102-
flag.StringVar(&protocol, "protocol", "plaintext", "Security protocol. Available options: plaintext, sasl_ssl, sasl_plaintext (default: plaintext)")
103-
flag.StringVar(&mechanism, "mechanism", "scram-sha-256", "SASL mechanism. Available options: scram-sha-256, scram-sha-512 (default: scram-sha-256)")
104-
flag.StringVar(&username, "username", "", "Username for authentication (can be also set by Env variable KAFKA_USERNAME")
105-
flag.StringVar(&password, "password", "", "Password for authentication (can be also set by Env variable KAFKA_PASSWORD")
106-
flag.BoolVar(&actionApply, "apply", false, "Apply spec-file to the broker, create all entities that do not exist there; this is the default action")
107-
flag.BoolVar(&actionDump, "dump", false, "Dump broker entities in YAML (default) or JSON format to stdout or to a file if --spec option is defined")
108-
flag.BoolVar(&actionHelp, "help", false, "Print usage")
109-
flag.BoolVar(&isYAML, "yaml", false, "Spec-file is in YAML format (will try to detect format if none of --yaml or --json is set)")
110-
flag.BoolVar(&isJSON, "json", false, "Spec-file is in JSON format (will try to detect format if none of --yaml or --json is set)")
111-
flag.BoolVar(&errorStop, "stop-on-error", false, "Exit on first occurred error")
112-
flag.BoolVar(&isTemplate, "template", false, "Spec-file is a template")
113-
flag.BoolVar(&missingOk, "missingok", false, "Ignore missing template keys")
114-
flag.BoolVar(&verbose, "verbose", false, "Verbose output")
115-
flag.Var(&varFlags, "var", "Variable for templating")
116-
flag.Usage = func() {
117-
usage()
118-
}
119-
flag.Parse()
120-
121-
protocol = strings.ToLower(protocol)
122-
mechanism = strings.ToLower(mechanism)
123-
}
124-
12599
func main() {
126100
defer handleExit()
127101
//defer fmt.Println("closed")
@@ -767,6 +741,30 @@ func (f *arrFlags) String() string {
767741
}
768742

769743
func validateFlags() {
744+
flag.StringVar(&broker, "broker", "", "Bootstrap-brokers, default is localhost:9092 (can be also set by Env variable KAFKA_BROKER)")
745+
flag.StringVar(&specfile, "spec", "", "Spec-file (can be set by Env variable KAFKA_SPEC_FILE)")
746+
flag.StringVar(&protocol, "protocol", "plaintext", "Security protocol. Available options: plaintext, sasl_ssl, sasl_plaintext (default: plaintext)")
747+
flag.StringVar(&mechanism, "mechanism", "scram-sha-256", "SASL mechanism. Available options: scram-sha-256, scram-sha-512 (default: scram-sha-256)")
748+
flag.StringVar(&username, "username", "", "Username for authentication (can be also set by Env variable KAFKA_USERNAME")
749+
flag.StringVar(&password, "password", "", "Password for authentication (can be also set by Env variable KAFKA_PASSWORD")
750+
flag.BoolVar(&actionApply, "apply", false, "Apply spec-file to the broker, create all entities that do not exist there; this is the default action")
751+
flag.BoolVar(&actionDump, "dump", false, "Dump broker entities in YAML (default) or JSON format to stdout or to a file if --spec option is defined")
752+
flag.BoolVar(&actionHelp, "help", false, "Print usage")
753+
flag.BoolVar(&isYAML, "yaml", false, "Spec-file is in YAML format (will try to detect format if none of --yaml or --json is set)")
754+
flag.BoolVar(&isJSON, "json", false, "Spec-file is in JSON format (will try to detect format if none of --yaml or --json is set)")
755+
flag.BoolVar(&errorStop, "stop-on-error", false, "Exit on first occurred error")
756+
flag.BoolVar(&isTemplate, "template", false, "Spec-file is a template")
757+
flag.BoolVar(&missingOk, "missingok", false, "Ignore missing template keys")
758+
flag.BoolVar(&verbose, "verbose", false, "Verbose output")
759+
flag.Var(&varFlags, "var", "Variable for templating")
760+
flag.Usage = func() {
761+
usage()
762+
}
763+
flag.Parse()
764+
765+
protocol = strings.ToLower(protocol)
766+
mechanism = strings.ToLower(mechanism)
767+
770768
if !actionApply && !actionDump && !actionHelp {
771769
fmt.Println("Please define one of the actions: --dump, --apply, --help")
772770
os.Exit(1)

0 commit comments

Comments
 (0)