mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #40122 # Details * Adds deprecation warnings to `fleetctl apply` * Adds alias conflict errors (i.e. using both new and deprecated keys in the same spec) to `fleetctl apply` * Adds logic around all deprecated field warnings to check the topic first * Disables deprecation warnings by default for `fleet serve`, `fleetctl gitops` and `fleetctl apply` * Enables deprecation warnings for dogfood via env var To turn on warnings: * In `fleet serve`, use either `--logging_enable_topics=deprecated-field-names` or the `FLEET_LOGGING_ENABLE_TOPICS=deprecated-field-names` env var * In `fleetctl gitops` / `fleetctl apply` use either `--enable-log-topics=deprecated-field-names` or `FLEET_ENABLE_LOG_TOPICS=deprecated-field-names` # Checklist for submitter If some of the following don't apply, delete the relevant line. - [X] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. ## Testing - [X] Added/updated automated tests - [X] QA'd all new/changed functionality manually tested in `fleetctl apply`, `fleet serve` and `fleet gitops` that warnings are suppressed by default and added when the appropriate env var or CLI option is used
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package logging
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
const DeprecatedFieldTopic = "deprecated-field-names"
|
|
|
|
// disabledTopics tracks which topics have been explicitly disabled.
|
|
// Topics are enabled by default — only topics in this map are disabled.
|
|
var (
|
|
disabledTopics = make(map[string]bool)
|
|
disabledTopicsMu sync.RWMutex
|
|
)
|
|
|
|
// EnableTopic marks a topic as enabled (removes it from the disabled set).
|
|
func EnableTopic(name string) {
|
|
disabledTopicsMu.Lock()
|
|
delete(disabledTopics, name)
|
|
disabledTopicsMu.Unlock()
|
|
}
|
|
|
|
// DisableTopic marks a topic as disabled.
|
|
func DisableTopic(name string) {
|
|
disabledTopicsMu.Lock()
|
|
disabledTopics[name] = true
|
|
disabledTopicsMu.Unlock()
|
|
}
|
|
|
|
// TopicEnabled returns true unless the topic has been explicitly disabled.
|
|
func TopicEnabled(name string) bool {
|
|
disabledTopicsMu.RLock()
|
|
disabled := disabledTopics[name]
|
|
disabledTopicsMu.RUnlock()
|
|
return !disabled
|
|
}
|
|
|
|
// ResetTopics clears all disabled topics, re-enabling everything.
|
|
// This is intended for use in tests to ensure isolation.
|
|
func ResetTopics() {
|
|
disabledTopicsMu.Lock()
|
|
disabledTopics = make(map[string]bool)
|
|
disabledTopicsMu.Unlock()
|
|
}
|