-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2388 from rszwajko/webhookWarning
CNV-54166: Admission webhook warning about non existing properties l2bridge and deviceIndex
- Loading branch information
Showing
5 changed files
with
48 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,47 @@ | ||
/* eslint-disable require-jsdoc */ | ||
import { V1Interface, V1Network } from '@kubevirt-ui/kubevirt-api/kubevirt'; | ||
|
||
import { UDN_BINDING_NAME } from '../constants'; | ||
import { BRIDGE, MASQUERADE, SRIOV, UDN_BINDING_NAME } from '../constants'; | ||
|
||
export type NetworkPresentation = { | ||
iface: V1Interface; | ||
network: V1Network; | ||
}; | ||
|
||
const typeHandler = { | ||
get(target, prop) { | ||
get(target: TypeMap, prop: string) { | ||
return target[prop] ?? target.bridge; | ||
}, | ||
}; | ||
|
||
const types = { | ||
const labelHandler = { | ||
get(target: LabelMap, prop: string) { | ||
return target[prop] ?? BRIDGE; | ||
}, | ||
}; | ||
|
||
export type InterfaceTypes = | ||
| typeof BRIDGE | ||
| typeof MASQUERADE | ||
| typeof SRIOV | ||
| typeof UDN_BINDING_NAME; | ||
type LabelMap = { [key: string]: InterfaceTypes }; | ||
type TypeMap = { [key in InterfaceTypes]: string }; | ||
|
||
const types2labels: TypeMap = { | ||
bridge: 'Bridge', | ||
l2bridge: 'L2 bridge', | ||
masquerade: 'Masquerade', | ||
sriov: 'SR-IOV', | ||
[UDN_BINDING_NAME]: 'L2 bridge', | ||
}; | ||
|
||
export const interfacesTypes = new Proxy(types, typeHandler); | ||
const labels2types: LabelMap = Object.fromEntries( | ||
Object.entries(types2labels).map( | ||
([type, label]: [InterfaceTypes, string]): [string, InterfaceTypes] => [label, type], | ||
), | ||
); | ||
|
||
export const interfacesTypes = new Proxy<TypeMap>(types2labels, typeHandler); | ||
export const interfaceLabels = new Proxy<LabelMap>(labels2types, labelHandler); | ||
|
||
export const PRIMARY_UDN_BINDING = 'primary-udn-kubevirt-binding'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters