import { GuardSpec } from './conditions'; export const FLAGS_STATUS = { wip: 'Unstable', ready: 'Stable', } as const; /** * Feature flags for the application. * wip - work in progress * ready - feature is stable and ready for production */ export type FlagStatus = keyof typeof FLAGS_STATUS; export interface FeatureMeta { /** * Unique key for the feature flag. * This key is used to identify the feature flag in the codebase. */ key: string; /** * Description of the feature flag. * This description is used to provide context for the feature flag. */ description: string; /** * Default enabled state of the feature flag. * This state is used to determine if the feature flag is enabled by default. */ defaultEnabled: boolean; /** * Status of the feature flag. * This status is used to determine if the feature flag is a work in progress or ready for production. */ status: FlagStatus; /** * Optional validator function for conditional flags. * If specified, the flag can only be enabled when the validator returns true. * The validator is called before allowing the user to enable the flag. */ guard?: GuardSpec; } const InternalFLAGS = { 'kubearchive-logs': { key: 'kubearchive-logs', description: 'Use KubeArchive to fetch logs instead of Tekton', defaultEnabled: true, status: 'ready', guard: { allOf: ['isKubearchiveEnabled'], failureReason: 'KubeArchive is not available on this cluster', visibleInFeatureFlagPanel: true, }, }, 'taskruns-kubearchive': { key: 'taskruns-kubearchive', description: 'Use KubeArchive as data source for TaskRuns instead of Tekton Results', defaultEnabled: true, status: 'ready', guard: { allOf: ['isKubearchiveEnabled'], failureReason: 'KubeArchive is not available on this cluster', visibleInFeatureFlagPanel: true, }, }, 'pipelineruns-kubearchive': { key: 'pipelineruns-kubearchive', description: 'Use KubeArchive as data source for PipelineRuns instead of Tekton Results', defaultEnabled: true, status: 'ready', guard: { allOf: ['isKubearchiveEnabled'], failureReason: 'KubeArchive is not available on this cluster', visibleInFeatureFlagPanel: true, }, }, 'component-model': { key: 'component-model', description: 'Use new component model', defaultEnabled: false, status: 'wip', guard: { allOf: ['isStagingCluster'], failureReason: 'Not a staging cluster', visibleInFeatureFlagPanel: false, }, }, 'ai-chat': { key: 'ai-chat', description: 'Enable Konflux AI chat bot', defaultEnabled: false, status: 'wip', guard: { allOf: ['isStagingCluster', 'isLightspeedAvailable'], failureReason: 'Requires staging environment with Konflux AI available', visibleInFeatureFlagPanel: false, }, }, 'kueue-queue-position': { key: 'kueue-queue-position', description: 'Show queue position and priority for pending PipelineRuns', defaultEnabled: false, status: 'wip', guard: { allOf: ['isKueueAvailable'], failureReason: 'Kueue is not available on this cluster', visibleInFeatureFlagPanel: true, }, }, } satisfies Record; export type FlagKey = keyof typeof InternalFLAGS; export const FLAGS = InternalFLAGS as unknown as Record;