-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kubevirt: introduce init function to K8sWrappers
- add k8sWrapperCreate method to EnhancedK8sMethods
- Loading branch information
Showing
15 changed files
with
158 additions
and
52 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
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
30 changes: 23 additions & 7 deletions
30
frontend/packages/kubevirt-plugin/src/k8s/wrapper/common/k8s-resource-wrapper.ts
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
47 changes: 47 additions & 0 deletions
47
frontend/packages/kubevirt-plugin/src/k8s/wrapper/common/util/k8s-mixin.ts
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { apiVersionForModel, K8sKind, K8sResourceCommon } from '@console/internal/module/k8s'; | ||
import { ensurePath } from '../../utils/utils'; | ||
import { omitEmpty } from '../../../../utils/common'; | ||
|
||
export type K8sInitAddon = { | ||
name?: string; | ||
generateName?: string; | ||
namespace?: string; | ||
labels?: { [k: string]: string }; | ||
annotations?: { [k: string]: string }; | ||
}; | ||
export const initK8sObject = ( | ||
base: K8sResourceCommon, | ||
model: K8sKind, | ||
{ name, generateName, namespace, labels, annotations }: K8sInitAddon = {}, | ||
) => { | ||
if (base && model) { | ||
base.kind = model.kind; | ||
base.apiVersion = apiVersionForModel(model); | ||
|
||
ensurePath(base, 'metadata'); | ||
const { metadata } = base; | ||
if (name) { | ||
metadata.name = name; | ||
metadata.generateName = undefined; | ||
} else if (generateName) { | ||
metadata.name = undefined; | ||
metadata.generateName = generateName; | ||
} | ||
metadata.namespace = namespace || metadata.namespace; | ||
metadata.labels = labels || metadata.labels; | ||
metadata.annotations = annotations || metadata.annotations; | ||
omitEmpty(metadata, true); | ||
} | ||
}; | ||
|
||
export const clearRuntimeMetadata = (base: K8sResourceCommon) => { | ||
if (base && base.metadata) { | ||
const { metadata } = base; | ||
delete metadata.selfLink; | ||
delete metadata.resourceVersion; | ||
delete metadata.uid; | ||
delete metadata.creationTimestamp; | ||
delete metadata.deletionTimestamp; | ||
delete metadata.generation; | ||
} | ||
}; |
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
3 changes: 2 additions & 1 deletion
3
frontend/packages/kubevirt-plugin/src/k8s/wrapper/types/types.ts
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
Oops, something went wrong.