/*
 * This file is part of the KubeVirt project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Copyright The KubeVirt Authors.
 *
 */

package featuregate

import "fmt"

const (
	LiveMigrationGate      = "LiveMigration"
	SRIOVLiveMigrationGate = "SRIOVLiveMigration"
	NonRoot                = "NonRoot"
	PSA                    = "PSA"
	CPUNodeDiscoveryGate   = "CPUNodeDiscovery"
	NUMAFeatureGate        = "NUMA"
	GPUGate                = "GPU"
	// VMLiveUpdateFeaturesGate allows updating certain VM fields, such as CPU sockets to enable hot-plug functionality.
	// GA:    v1.5.0
	VMLiveUpdateFeaturesGate = "VMLiveUpdateFeatures"

	// CommonInstancetypesDeploymentGate enables the deployment of common-instancetypes by virt-operator
	// Owner: @lyarwood
	// Alpha: v1.1.0
	// Beta:  v1.2.0
	// GA:	  v1.4.0
	CommonInstancetypesDeploymentGate = "CommonInstancetypesDeploymentGate"

	// HotplugNetworkIfacesGate controls the network interface hotplug feature lifecycle.
	// Alpha: v1.1.0
	// Beta:  v1.3.0
	// GA:    v1.4.0
	HotplugNetworkIfacesGate = "HotplugNICs"

	// BochsDisplayForEFIGuests instructs EFI guests to start with Bochs display (instead of VGA)
	// GA:    v1.4.0
	BochsDisplayForEFIGuests = "BochsDisplayForEFIGuests"

	// AutoResourceLimitsGate enables automatic setting of vmi limits if there is a ResourceQuota with limits associated with the vmi namespace.
	// GA:    v1.5.0
	AutoResourceLimitsGate = "AutoResourceLimitsGate"

	// DockerSELinuxMCSWorkaround sets the SELinux level of all the non-compute virt-launcher containers to "s0".
	// Deprecated: v1.4.0
	DockerSELinuxMCSWorkaround = "DockerSELinuxMCSWorkaround"

	// NetworkBindingPluginsGate enables using a plugin to bind the pod and the VM network
	// Alpha: v1.1.0
	// Beta:  v1.4.0
	// GA:    v1.5.0
	NetworkBindingPluginsGate = "NetworkBindingPlugins"

	// DynamicPodInterfaceNamingGate enables a mechanism to dynamically determine the primary pod interface for KubeVirt virtual machines.
	// Beta:  v1.4.0
	// GA:    v1.5.0
	DynamicPodInterfaceNamingGate = "DynamicPodInterfaceNaming"

	PasstGate             = "Passt"
	MacvtapGate           = "Macvtap"
	PasstIPStackMigration = "PasstIPStackMigration"

	// VirtIOFSGate enables the use of virtiofs for config and storage volumes.
	// Discontinued in v1.7.0
	VirtIOFSGate = "ExperimentalVirtiofsSupport"
	// VolumesUpdateStrategy enables to specify the strategy on the volume updates.
	// Introduced in v1.3.0
	VolumesUpdateStrategy = "VolumesUpdateStrategy"
	// VolumeMigration enables to migrate the storage. It depends on the VolumesUpdateStrategy feature.
	// Introduced in v1.3.0
	VolumeMigration = "VolumeMigration"

	// Owner: sig-storage
	// Alpha: v0.55.0
	// Beta: v1.3.0
	// GA: v1.9.0
	// VMExportGate enables the creation of VMExport resources, that allows setting up the export server to export VM volumes.
	VMExportGate = "VMExport"

	// DisableCustomSELinuxPolicy disables the installation of the custom SELinux policy for virt-launcher
	DisableCustomSELinuxPolicy = "DisableCustomSELinuxPolicy"

	ClusterProfiler = "ClusterProfiler"

	// VMPersistentState enables persisting backend state files of VMs, such as the contents of the vTPM
	VMPersistentState = "VMPersistentState"

	// Owner: @lyarwood
	// Alpha: v1.4.0
	// Beta: v1.5.0
	// GA: v1.6.0
	//
	// InstancetypeReferencePolicy allows a cluster admin to control how a VirtualMachine references instance types and preferences
	// through the kv.spec.configuration.instancetype.referencePolicy configurable.
	InstancetypeReferencePolicy = "InstancetypeReferencePolicy"

	// Owner: sig-compute / @lyarwood
	// Alpha: v1.0.0
	// Deprecated: v1.8.0
	//
	// MultiArchitecture allows VM/VMIs to request and schedule to an architecture other than that of control plane
	MultiArchitecture = "MultiArchitecture"

	// VirtIOFSConfigVolumesGate enables the use of virtiofs for config volumes, i.e., config-maps, secrets, downwardAPI, etc.
	// Owners: @germag @jcanocan
	// Alpha: v1.5.0
	// Beta: v1.6.0
	// GA: v1.8.0
	VirtIOFSConfigVolumesGate = "EnableVirtioFsConfigVolumes"

	// VideoConfig enables VM owners to specify a video device type (e.g., virtio, vga, bochs, ramfb) via the `Video` field, overriding default settings.
	// Requires `autoattachGraphicsDevice` to be true or unset.
	// Owner: @dasionov
	// Alpha: v1.6.0
	// Beta: v1.7.0
	// GA: v1.9.0
	VideoConfig = "VideoConfig"

	// Owner: sig-compute
	// Alpha: v1.0.0
	// Deprecated: v1.8.0
	//
	// DisableMediatedDevicesHandling disables the handling of mediated
	// devices, its creation and deletion
	DisableMediatedDevicesHandling = "DisableMDEVConfiguration"

	// Owner: sig-storage
	// Alpha: v0.48.0
	// GA: v1.8.0
	//
	// ExpandDisksGate allows for expanding the storage available for in-use virtual machines.
	ExpandDisksGate = "ExpandDisks"

	// Owner: @varunrsekar
	// Alpha: v1.6.0
	// Beta: v1.7.0
	// GA: v1.9.0
	//
	// PanicDevices allows defining panic devices for signaling crashes in the guest for a VirtualMachineInstance.
	PanicDevicesGate = "PanicDevices"

	// Owner: sig-network
	// Beta: v1.8.0
	// GA: v1.9.0
	//
	// LiveUpdateNADRef enables dynamic modification of NAD references for secondary networks on running VMs.
	LiveUpdateNADRef = "LiveUpdateNADRef"

	// Owner: sig-storage
	// Alpha: v0.36.0
	// Deprecated: v1.9.0
	HotplugVolumesGate = "HotplugVolumes"

	// Owner: sig-storage
	// Alpha: v1.0.0
	// GA: v1.9.0
	//
	// PersistentReservation enables the use of the SCSI persistent reservation in VMs using the pr-helper daemon
	PersistentReservation = "PersistentReservation"

	// Owner: sig-compute / @jschintag
	// Alpha: v1.6.0
	// Beta: v1.7.0
	// GA: v1.9.0
	//
	// SecureExecution introduces secure execution of VMs on IBM Z architecture
	SecureExecution = "SecureExecution"

	// MigrationPriorityQueue enables controllers to assign priorities to migrations,
	// ensuring system-initiated migrations (e.g., node drains, upgrades) take precedence
	// over user-initiated ones (e.g., hot plug operations).
	// Owner: sig-compute / @fossedihelm
	// Alpha: v1.7.0
	// Beta: v1.8.0
	// GA: v1.9.0
	MigrationPriorityQueue = "MigrationPriorityQueue"
)

func init() {
	RegisterFeatureGate(FeatureGate{Name: LiveMigrationGate, State: GA})
	RegisterFeatureGate(FeatureGate{Name: SRIOVLiveMigrationGate, State: GA})
	RegisterFeatureGate(FeatureGate{Name: NonRoot, State: GA})
	RegisterFeatureGate(FeatureGate{Name: PSA, State: GA})
	RegisterFeatureGate(FeatureGate{Name: CPUNodeDiscoveryGate, State: GA})
	RegisterFeatureGate(FeatureGate{Name: NUMAFeatureGate, State: GA})
	RegisterFeatureGate(FeatureGate{Name: CommonInstancetypesDeploymentGate, State: GA})
	RegisterFeatureGate(FeatureGate{Name: GPUGate, State: GA})
	RegisterFeatureGate(FeatureGate{Name: HotplugNetworkIfacesGate, State: GA})
	RegisterFeatureGate(FeatureGate{Name: BochsDisplayForEFIGuests, State: GA})
	RegisterFeatureGate(FeatureGate{Name: VMLiveUpdateFeaturesGate, State: GA})
	RegisterFeatureGate(FeatureGate{Name: NetworkBindingPluginsGate, State: GA})
	RegisterFeatureGate(FeatureGate{Name: DynamicPodInterfaceNamingGate, State: GA})
	RegisterFeatureGate(FeatureGate{Name: VolumesUpdateStrategy, State: GA})
	RegisterFeatureGate(FeatureGate{Name: VolumeMigration, State: GA})
	RegisterFeatureGate(FeatureGate{Name: DisableCustomSELinuxPolicy, State: GA})
	RegisterFeatureGate(FeatureGate{Name: AutoResourceLimitsGate, State: GA})
	RegisterFeatureGate(FeatureGate{Name: ClusterProfiler, State: GA})
	RegisterFeatureGate(FeatureGate{Name: VMPersistentState, State: GA})
	RegisterFeatureGate(FeatureGate{Name: VMExportGate, State: GA})
	RegisterFeatureGate(FeatureGate{Name: PersistentReservation, State: GA})

	RegisterFeatureGate(FeatureGate{Name: DockerSELinuxMCSWorkaround, State: Deprecated, Message: fmt.Sprintf(
		"DockerSELinuxMCSWorkaround has been deprecated since v1.4.")})
	RegisterFeatureGate(FeatureGate{Name: VirtIOFSGate, State: Discontinued, Message: VirtioFsFeatureGateDiscontinueMessage})

	RegisterFeatureGate(FeatureGate{Name: PasstGate, State: Discontinued, Message: PasstDiscontinueMessage, VmiSpecUsed: passtApiUsed})
	RegisterFeatureGate(FeatureGate{Name: MacvtapGate, State: Discontinued, Message: MacvtapDiscontinueMessage, VmiSpecUsed: macvtapApiUsed})
	RegisterFeatureGate(FeatureGate{Name: PasstIPStackMigration, State: Discontinued, Message: PasstIPStackMigrationMessage})

	RegisterFeatureGate(FeatureGate{Name: InstancetypeReferencePolicy, State: GA})
	RegisterFeatureGate(FeatureGate{Name: MultiArchitecture, State: Deprecated, Message: "MultiArchitecture has been deprecated since v1.8.0"})
	RegisterFeatureGate(FeatureGate{Name: VirtIOFSConfigVolumesGate, State: GA})
	RegisterFeatureGate(FeatureGate{Name: DisableMediatedDevicesHandling, State: Deprecated, Message: "DisableMDEVConfiguration has been deprecated since v1.8.0"})
	RegisterFeatureGate(FeatureGate{Name: ExpandDisksGate, State: GA})
	RegisterFeatureGate(FeatureGate{Name: PanicDevicesGate, State: GA})
	RegisterFeatureGate(FeatureGate{Name: LiveUpdateNADRef, State: GA})
	RegisterFeatureGate(FeatureGate{Name: HotplugVolumesGate, State: Deprecated, Message: "HotplugVolumes has been deprecated since v1.9.0 and has been replaced by DeclarativeHotplugVolumes"})
	RegisterFeatureGate(FeatureGate{Name: VideoConfig, State: GA})
	RegisterFeatureGate(FeatureGate{Name: SecureExecution, State: GA})
	RegisterFeatureGate(FeatureGate{Name: MigrationPriorityQueue, State: GA})
}
