Skip to content

Commit 13fd477

Browse files
authored
Add dependency for disabled modules (#130)
1 parent a7fc7ec commit 13fd477

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

internal/arguments/arguments.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ var (
2121
)
2222

2323
const interactiveHelpText = `Welcome to the support-collector argument wizard!
24-
We will guide you through all required details.
25-
26-
Available modules are: %s`
24+
We will guide you through all required details.`
2725

2826
type Argument struct {
2927
Name string
@@ -44,7 +42,7 @@ func New() Handler {
4442
}
4543

4644
func (args *Handler) CollectArgsFromStdin(availableModules string) []error {
47-
fmt.Printf(interactiveHelpText+"\n\n", availableModules)
45+
fmt.Printf("%s\n\nAvailable modules are: %s\n\n", interactiveHelpText, availableModules)
4846

4947
errors := make([]error, 0, len(args.arguments))
5048

main.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,19 @@ func init() {
133133
// Run specific arguments
134134
args.NewPromptStringVar(&outputFile, "output", buildFileName(), "Filename for resulting zip", true, nil)
135135
args.NewPromptStringSliceVar(&enabledModules, "enable", moduleOrder, "Enabled modules for collection (comma separated)", false, nil)
136-
args.NewPromptStringSliceVar(&disabledModules, "disable", []string{}, "Explicit disabled modules for collection (comma separated)", false, nil)
136+
args.NewPromptStringSliceVar(&disabledModules, "disable", []string{}, "Explicit disabled modules for collection (comma separated)", false, func() bool {
137+
if len(enabledModules) == 0 || len(enabledModules) == len(moduleOrder) {
138+
return true
139+
}
140+
141+
return false
142+
})
137143
args.NewPromptBoolVar(&noDetailedCollection, "no-details", false, "Disable detailed collection including logs and more", nil)
138144

139145
// Icinga 2 specific arguments
140-
args.NewPromptStringVar(&icinga2.APICred.Username, "icinga2-api-user", "", "Icinga 2: Username of global API user to collect data about Icinga 2 Infrastructure", false, icinga2Enabled)
141-
args.NewPromptStringVar(&icinga2.APICred.Password, "icinga2-api-pass", "", "Icinga 2: Password for global API user to collect data about Icinga 2 Infrastructure", false, icinga2Enabled)
142-
args.NewPromptStringSliceVar(&icinga2.APIEndpoints, "icinga2-api-endpoints", []string{}, "Icinga 2: Comma separated list of API Endpoints (including port) to collect data from. FQDN or IP address must be reachable. (Example: i2-master01.local:5665)", false, icinga2Enabled)
146+
args.NewPromptStringVar(&icinga2.APICred.Username, "icinga2-api-user", "", "Icinga 2: Username of global API user to collect data about Icinga 2 Infrastructure", false, isIcingaEnabled)
147+
args.NewPromptStringVar(&icinga2.APICred.Password, "icinga2-api-pass", "", "Icinga 2: Password for global API user to collect data about Icinga 2 Infrastructure", false, isIcingaEnabled)
148+
args.NewPromptStringSliceVar(&icinga2.APIEndpoints, "icinga2-api-endpoints", []string{}, "Icinga 2: Comma separated list of API Endpoints (including port) to collect data from. FQDN or IP address must be reachable. (Example: i2-master01.local:5665)", false, isIcingaEnabled)
143149

144150
flag.CommandLine.SortFlags = false
145151

@@ -178,7 +184,7 @@ func buildFileName() string {
178184
return FilePrefix + "_" + util.GetHostnameWithoutDomain() + "_" + time.Now().Format("20060102-1504") + ".zip"
179185
}
180186

181-
func icinga2Enabled() bool {
187+
func isIcingaEnabled() bool {
182188
for _, name := range enabledModules {
183189
if name == "icinga2" {
184190
return true
@@ -268,17 +274,17 @@ func NewCollection(outputFile string) (*collection.Collection, func()) {
268274
}
269275

270276
c := collection.New(file)
271-
c.Log.SetLevel(logrus.DebugLevel)
272277

273278
consoleLevel := logrus.InfoLevel
274279
if verbose {
275-
// logrus.StandardLogger().SetLevel(logrus.DebugLevel)
276280
consoleLevel = logrus.DebugLevel
277281
}
278282

283+
c.Log.SetLevel(consoleLevel)
284+
279285
// Add console log output via logrus.Hook
280286
c.Log.AddHook(&util.ExtraLogHook{
281-
Formatter: &logrus.TextFormatter{ForceColors: true},
287+
Formatter: &logrus.TextFormatter{ForceColors: true, FullTimestamp: true, TimestampFormat: "15:04:05"},
282288
Writer: colorable.NewColorableStdout(),
283289
Level: consoleLevel,
284290
})

0 commit comments

Comments
 (0)