vault/helper/experiments/experiments.go
Vault Automation b60d15a07c
Add experiment to enable the KMIP client API (#11981) (#12017)
* Make VAULT_EXPERIMENTS work as feature flags.

Make method IsFlagEnabled treat experiments as feature flags so that they
are accessible to plugins.

* Add experiment kmip.client_api.alpha1.

This experiment enables the KMIP client and template API endpoints.

* Use IsExperimentEnabled rather than ValidExperiments.

* Document TestCore_IsFlagEnabled.

Co-authored-by: Victor Rodriguez <vrizo@hashicorp.com>
2026-02-13 15:14:36 +00:00

42 lines
1.3 KiB
Go

// Copyright IBM Corp. 2016, 2025
// SPDX-License-Identifier: BUSL-1.1
package experiments
import "slices"
const (
VaultExperimentCoreAuditEventsAlpha1 = "core.audit.events.alpha1"
VaultExperimentSecretsImport = "secrets.import.alpha1"
// VaultExperimentKmipClientApi enables the experimental KMIP client
// and template API endpoints. See VAULT-41117.
VaultExperimentKmipClientApi = "kmip.client_api.alpha1"
VaultExperimentEventsAlpha1 = "events.alpha1"
)
var validExperiments = []string{
VaultExperimentEventsAlpha1,
VaultExperimentCoreAuditEventsAlpha1,
VaultExperimentSecretsImport,
VaultExperimentKmipClientApi,
}
// Unused experiments. We keep them so that we don't break users who include them in their
// flags or configs, but they no longer have any effect.
var unusedExperiments = []string{
VaultExperimentEventsAlpha1,
}
// ValidExperiments exposes the list of valid experiments without exposing a mutable
// global variable. Experiments can only be enabled when starting a server, and will
// typically enable pre-GA API functionality.
func ValidExperiments() []string {
return slices.Clone(validExperiments)
}
// IsUnused returns true if the given experiment is in the unused list.
func IsUnused(experiment string) bool {
return slices.Contains(unusedExperiments, experiment)
}