Skip to content

Warn about unused settings in broker.conf #1461

@adombeck

Description

@adombeck

For better UX, we should print a warning if the broker.conf contains an unknown setting.

The github.com/go-ini/ini package we use to parse the config file does not have built-in support for that, but we can implement it ourselves via:

	// Print warnings for unknown sections and keys.
	known := map[string][]string{
		oidcSection: {
			issuerKey,
			clientIDKey,
			clientSecret,
			forceProviderAuthenticationKey,
		},
		usersSection: {
			allowedUsersKey,
			ownerKey,
			homeDirKey,
			sshSuffixesKey,
			sshSuffixesKeyOld,
			extraGroupsKey,
			ownerExtraGroupsKey,
		},
	}
	for _, section := range iniCfg.Sections() {
		if _, ok := known[section.Name()]; !ok {
			log.Warningf(context.Background(), "unknown section %q in config file, ignoring", section.Name())
			continue
		}

		for _, key := range section.Keys() {
			if _, ok := known[section.Name()]; !ok {
				log.Warningf(context.Background(), "unknown key %q in section %q in config file, ignoring", key.Name(), section.Name())
				continue
			}
		}
	}

In our tests we should check that no warnings are printed

UDENG-8335

Metadata

Metadata

Labels

No labels
No labels
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions