@spinnaker/kubernetes 0.0.0-main-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1663 -0
- package/LICENSE.txt +203 -0
- package/dist/help/kubernetes.help.d.ts +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6024 -0
- package/dist/index.js.map +1 -0
- package/dist/instance/details/details.controller.d.ts +1 -0
- package/dist/instance/index.d.ts +1 -0
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/infrastructure.types.d.ts +24 -0
- package/dist/kubernetes.module.d.ts +6 -0
- package/dist/loadBalancer/details/details.controller.d.ts +1 -0
- package/dist/loadBalancer/index.d.ts +1 -0
- package/dist/loadBalancer/transformer.d.ts +1 -0
- package/dist/manifest/IManifestCoordinates.d.ts +5 -0
- package/dist/manifest/ManifestImageDetails.d.ts +18 -0
- package/dist/manifest/ManifestKindSearch.d.ts +13 -0
- package/dist/manifest/ManifestLabels.d.ts +15 -0
- package/dist/manifest/ManifestQos.d.ts +15 -0
- package/dist/manifest/ManifestResources.d.ts +35 -0
- package/dist/manifest/ManifestSource.d.ts +4 -0
- package/dist/manifest/annotationCustomSections.component.d.ts +1 -0
- package/dist/manifest/artifact/artifact.component.d.ts +1 -0
- package/dist/manifest/delete/delete.controller.d.ts +12 -0
- package/dist/manifest/delete/deleteOptionsForm.component.d.ts +1 -0
- package/dist/manifest/editor/json/JsonEditor.d.ts +12 -0
- package/dist/manifest/editor/json/jsonEditor.component.d.ts +1 -0
- package/dist/manifest/index.d.ts +10 -0
- package/dist/manifest/manifest.service.d.ts +25 -0
- package/dist/manifest/manifestCommandBuilder.service.d.ts +30 -0
- package/dist/manifest/manifestEvents.component.d.ts +1 -0
- package/dist/manifest/manifestImageDetails.component.d.ts +1 -0
- package/dist/manifest/manifestLabels.component.d.ts +1 -0
- package/dist/manifest/manifestQos.component.d.ts +1 -0
- package/dist/manifest/manifestResources.component.d.ts +1 -0
- package/dist/manifest/rollout/RollingRestart.d.ts +1 -0
- package/dist/manifest/rollout/pause.controller.d.ts +1 -0
- package/dist/manifest/rollout/resume.controller.d.ts +1 -0
- package/dist/manifest/rollout/undo.controller.d.ts +1 -0
- package/dist/manifest/scale/ScaleSettingsForm.d.ts +10 -0
- package/dist/manifest/scale/scale.controller.d.ts +8 -0
- package/dist/manifest/scale/scaleSettingsForm.component.d.ts +1 -0
- package/dist/manifest/selector/IManifestLabelSelector.d.ts +9 -0
- package/dist/manifest/selector/IManifestSelector.d.ts +30 -0
- package/dist/manifest/selector/ManifestSelector.d.ts +46 -0
- package/dist/manifest/selector/labelEditor/LabelEditor.d.ts +15 -0
- package/dist/manifest/selector/selector.component.d.ts +1 -0
- package/dist/manifest/status/ManifestCondition.d.ts +13 -0
- package/dist/manifest/status/condition.component.d.ts +1 -0
- package/dist/manifest/status/status.component.d.ts +1 -0
- package/dist/manifest/traffic/ManifestTrafficService.d.ts +12 -0
- package/dist/manifest/wizard/BasicSettings.d.ts +17 -0
- package/dist/manifest/wizard/ManifestEntry.d.ts +16 -0
- package/dist/manifest/wizard/ManifestWizard.d.ts +22 -0
- package/dist/pipelines/stages/ManifestCoordinates.d.ts +31 -0
- package/dist/pipelines/stages/ManifestExecutionDetails.d.ts +69 -0
- package/dist/pipelines/stages/deleteManifest/DeleteManifestOptionsForm.d.ts +18 -0
- package/dist/pipelines/stages/deleteManifest/DeleteManifestStageConfig.d.ts +14 -0
- package/dist/pipelines/stages/deleteManifest/deleteManifestStage.d.ts +1 -0
- package/dist/pipelines/stages/deployManifest/CopyFromTemplateButton.d.ts +15 -0
- package/dist/pipelines/stages/deployManifest/DeployManifestStageConfig.d.ts +15 -0
- package/dist/pipelines/stages/deployManifest/DeployManifestStageForm.d.ts +31 -0
- package/dist/pipelines/stages/deployManifest/ManifestBindArtifactsSelector.d.ts +17 -0
- package/dist/pipelines/stages/deployManifest/ManifestCopier.d.ts +36 -0
- package/dist/pipelines/stages/deployManifest/ManifestDeploymentOptions.d.ts +34 -0
- package/dist/pipelines/stages/deployManifest/NamespaceSelector.d.ts +16 -0
- package/dist/pipelines/stages/deployManifest/deployManifest.validator.d.ts +2 -0
- package/dist/pipelines/stages/deployManifest/deployManifestStage.d.ts +1 -0
- package/dist/pipelines/stages/deployManifest/manifestStatus/DeployStatus.d.ts +23 -0
- package/dist/pipelines/stages/deployManifest/manifestStatus/DeployStatusPills.d.ts +8 -0
- package/dist/pipelines/stages/deployManifest/manifestStatus/ManifestDetailsLink.d.ts +20 -0
- package/dist/pipelines/stages/deployManifest/manifestStatus/ManifestEvents.d.ts +9 -0
- package/dist/pipelines/stages/deployManifest/manifestStatus/ManifestStatus.d.ts +8 -0
- package/dist/pipelines/stages/findArtifactsFromResource/FindArtifactsFromResourceConfig.d.ts +3 -0
- package/dist/pipelines/stages/findArtifactsFromResource/FindArtifactsFromResourceStageForm.d.ts +7 -0
- package/dist/pipelines/stages/findArtifactsFromResource/findArtifactsFromResourceStage.d.ts +1 -0
- package/dist/pipelines/stages/index.d.ts +8 -0
- package/dist/pipelines/stages/patchManifest/PatchManifestOptionsForm.d.ts +8 -0
- package/dist/pipelines/stages/patchManifest/PatchManifestStageConfig.d.ts +7 -0
- package/dist/pipelines/stages/patchManifest/PatchManifestStageForm.d.ts +21 -0
- package/dist/pipelines/stages/patchManifest/patchManifestStage.d.ts +4 -0
- package/dist/pipelines/stages/rolloutRestartManifest/RolloutRestartManifestStageConfig.d.ts +13 -0
- package/dist/pipelines/stages/rolloutRestartManifest/rolloutRestartManifestStage.d.ts +4 -0
- package/dist/pipelines/stages/runJob/KubernetesV2RunJobStageConfig.d.ts +31 -0
- package/dist/pipelines/stages/runJob/RunJobExecutionDetails.d.ts +7 -0
- package/dist/pipelines/stages/runJob/runJobStage.d.ts +1 -0
- package/dist/pipelines/stages/scaleManifest/ScaleManifestConfig.d.ts +3 -0
- package/dist/pipelines/stages/scaleManifest/ScaleManifestStageForm.d.ts +7 -0
- package/dist/pipelines/stages/scaleManifest/scaleManifestStage.d.ts +1 -0
- package/dist/pipelines/stages/traffic/ManifestTrafficStageConfig.d.ts +11 -0
- package/dist/pipelines/stages/traffic/disableManifest.stage.d.ts +1 -0
- package/dist/pipelines/stages/traffic/enableManifest.stage.d.ts +1 -0
- package/dist/pipelines/stages/undoRolloutManifest/UndoRolloutManifestConfig.d.ts +3 -0
- package/dist/pipelines/stages/undoRolloutManifest/UndoRolloutManifestStageForm.d.ts +7 -0
- package/dist/pipelines/stages/undoRolloutManifest/undoRolloutManifestStage.d.ts +1 -0
- package/dist/pipelines/stages/validators/manifestSelectorValidators.d.ts +2 -0
- package/dist/pipelines/validation/manifestSelector.validator.d.ts +8 -0
- package/dist/rawResource/component/K8sResources.d.ts +25 -0
- package/dist/rawResource/component/K8sResourcesFilters.d.ts +20 -0
- package/dist/rawResource/component/RawResourceUtils.d.ts +5 -0
- package/dist/rawResource/component/group/RawResouceGroup.d.ts +15 -0
- package/dist/rawResource/component/group/RawResource.d.ts +12 -0
- package/dist/rawResource/component/group/RawResourceDetails.d.ts +32 -0
- package/dist/rawResource/component/group/RawResourceGroups.d.ts +14 -0
- package/dist/rawResource/controller/FiltersPubSub.d.ts +12 -0
- package/dist/rawResource/index.d.ts +1 -0
- package/dist/rawResource/model/resource.d.ts +17 -0
- package/dist/rawResource/rawResource.dataSource.d.ts +2 -0
- package/dist/rawResource/rawResource.module.d.ts +1 -0
- package/dist/rawResource/rawResource.states.d.ts +6 -0
- package/dist/resources/ResourceDetails.d.ts +17 -0
- package/dist/resources/resources.state.d.ts +7 -0
- package/dist/rolloutStrategy/bluegreen.strategy.d.ts +2 -0
- package/dist/rolloutStrategy/highlander.strategy.d.ts +2 -0
- package/dist/rolloutStrategy/index.d.ts +1 -0
- package/dist/rolloutStrategy/none.strategy.d.ts +2 -0
- package/dist/rolloutStrategy/redblack.strategy.d.ts +2 -0
- package/dist/securityGroup/details/details.controller.d.ts +1 -0
- package/dist/securityGroup/index.d.ts +1 -0
- package/dist/securityGroup/securityGroup.reader.d.ts +4 -0
- package/dist/securityGroup/transformer.d.ts +1 -0
- package/dist/serverGroup/details/details.controller.d.ts +1 -0
- package/dist/serverGroup/details/resize/resize.controller.d.ts +1 -0
- package/dist/serverGroup/index.d.ts +4 -0
- package/dist/serverGroup/serverGroupCommandBuilder.service.d.ts +6 -0
- package/dist/serverGroup/serverGroupTransformer.service.d.ts +6 -0
- package/dist/serverGroupManager/details/details.controller.d.ts +1 -0
- package/dist/serverGroupManager/index.d.ts +1 -0
- package/dist/validation/applicationName.validator.d.ts +9 -0
- package/package.json +58 -0
- package/src/help/kubernetes.help.ts +236 -0
- package/src/index.ts +7 -0
- package/src/instance/details/details.controller.ts +186 -0
- package/src/instance/details/details.html +80 -0
- package/src/instance/index.ts +1 -0
- package/src/interfaces/index.ts +1 -0
- package/src/interfaces/infrastructure.types.ts +35 -0
- package/src/kubernetes.module.ts +144 -0
- package/src/loadBalancer/details/details.controller.ts +101 -0
- package/src/loadBalancer/details/details.html +187 -0
- package/src/loadBalancer/index.ts +1 -0
- package/src/loadBalancer/transformer.ts +60 -0
- package/src/logo/kubernetes.icon.svg +102 -0
- package/src/logo/kubernetes.logo.less +6 -0
- package/src/logo/kubernetes.logo.svg +1 -0
- package/src/manifest/IManifestCoordinates.ts +5 -0
- package/src/manifest/ManifestImageDetails.spec.tsx +76 -0
- package/src/manifest/ManifestImageDetails.tsx +64 -0
- package/src/manifest/ManifestKindSearch.tsx +31 -0
- package/src/manifest/ManifestLabels.tsx +31 -0
- package/src/manifest/ManifestQos.tsx +68 -0
- package/src/manifest/ManifestResources.tsx +69 -0
- package/src/manifest/ManifestSource.ts +4 -0
- package/src/manifest/annotationCustomSections.component.ts +114 -0
- package/src/manifest/artifact/artifact.component.ts +23 -0
- package/src/manifest/delete/delete.controller.ts +80 -0
- package/src/manifest/delete/delete.html +42 -0
- package/src/manifest/delete/deleteOptionsForm.component.ts +52 -0
- package/src/manifest/editor/json/JsonEditor.tsx +56 -0
- package/src/manifest/editor/json/jsonEditor.component.ts +12 -0
- package/src/manifest/index.ts +10 -0
- package/src/manifest/manifest.service.ts +90 -0
- package/src/manifest/manifestCommandBuilder.service.ts +126 -0
- package/src/manifest/manifestEvents.component.ts +12 -0
- package/src/manifest/manifestImageDetails.component.ts +12 -0
- package/src/manifest/manifestLabels.component.ts +12 -0
- package/src/manifest/manifestLabels.less +3 -0
- package/src/manifest/manifestQos.component.ts +12 -0
- package/src/manifest/manifestResources.component.ts +12 -0
- package/src/manifest/rollout/RollingRestart.tsx +54 -0
- package/src/manifest/rollout/pause.controller.ts +66 -0
- package/src/manifest/rollout/pause.html +28 -0
- package/src/manifest/rollout/resume.controller.ts +66 -0
- package/src/manifest/rollout/resume.html +28 -0
- package/src/manifest/rollout/undo.controller.ts +74 -0
- package/src/manifest/rollout/undo.html +44 -0
- package/src/manifest/scale/ScaleSettingsForm.tsx +43 -0
- package/src/manifest/scale/scale.controller.ts +75 -0
- package/src/manifest/scale/scale.html +32 -0
- package/src/manifest/scale/scaleSettingsForm.component.ts +11 -0
- package/src/manifest/selector/IManifestLabelSelector.ts +19 -0
- package/src/manifest/selector/IManifestSelector.ts +64 -0
- package/src/manifest/selector/ManifestSelector.spec.tsx +414 -0
- package/src/manifest/selector/ManifestSelector.tsx +424 -0
- package/src/manifest/selector/labelEditor/LabelEditor.spec.tsx +81 -0
- package/src/manifest/selector/labelEditor/LabelEditor.tsx +126 -0
- package/src/manifest/selector/labelEditor/labelEditor.less +3 -0
- package/src/manifest/selector/selector.component.ts +17 -0
- package/src/manifest/status/ManifestCondition.tsx +32 -0
- package/src/manifest/status/condition.component.ts +12 -0
- package/src/manifest/status/status.component.ts +36 -0
- package/src/manifest/traffic/ManifestTrafficService.spec.ts +30 -0
- package/src/manifest/traffic/ManifestTrafficService.ts +67 -0
- package/src/manifest/wizard/BasicSettings.tsx +57 -0
- package/src/manifest/wizard/ManifestEntry.tsx +46 -0
- package/src/manifest/wizard/ManifestWizard.tsx +94 -0
- package/src/pipelines/stages/ManifestCoordinates.spec.tsx +90 -0
- package/src/pipelines/stages/ManifestCoordinates.tsx +128 -0
- package/src/pipelines/stages/ManifestExecutionDetails.tsx +58 -0
- package/src/pipelines/stages/deleteManifest/DeleteManifestOptionsForm.spec.tsx +85 -0
- package/src/pipelines/stages/deleteManifest/DeleteManifestOptionsForm.tsx +87 -0
- package/src/pipelines/stages/deleteManifest/DeleteManifestStageConfig.tsx +62 -0
- package/src/pipelines/stages/deleteManifest/deleteManifestOptionsForm.less +9 -0
- package/src/pipelines/stages/deleteManifest/deleteManifestStage.ts +21 -0
- package/src/pipelines/stages/deployManifest/CopyFromTemplateButton.tsx +45 -0
- package/src/pipelines/stages/deployManifest/DeployManifestStageConfig.tsx +77 -0
- package/src/pipelines/stages/deployManifest/DeployManifestStageForm.tsx +265 -0
- package/src/pipelines/stages/deployManifest/ManifestBindArtifactsSelector.tsx +69 -0
- package/src/pipelines/stages/deployManifest/ManifestCopier.spec.ts +110 -0
- package/src/pipelines/stages/deployManifest/ManifestCopier.tsx +222 -0
- package/src/pipelines/stages/deployManifest/ManifestDeploymentOptions.spec.tsx +75 -0
- package/src/pipelines/stages/deployManifest/ManifestDeploymentOptions.tsx +203 -0
- package/src/pipelines/stages/deployManifest/NamespaceSelector.tsx +40 -0
- package/src/pipelines/stages/deployManifest/deployManifest.validator.ts +38 -0
- package/src/pipelines/stages/deployManifest/deployManifestStage.ts +28 -0
- package/src/pipelines/stages/deployManifest/manifestStatus/DeployStatus.less +11 -0
- package/src/pipelines/stages/deployManifest/manifestStatus/DeployStatus.tsx +120 -0
- package/src/pipelines/stages/deployManifest/manifestStatus/DeployStatusPills.tsx +47 -0
- package/src/pipelines/stages/deployManifest/manifestStatus/ManifestDetailsLink.tsx +92 -0
- package/src/pipelines/stages/deployManifest/manifestStatus/ManifestEvents.tsx +87 -0
- package/src/pipelines/stages/deployManifest/manifestStatus/ManifestStatus.less +24 -0
- package/src/pipelines/stages/deployManifest/manifestStatus/ManifestStatus.tsx +46 -0
- package/src/pipelines/stages/findArtifactsFromResource/FindArtifactsFromResourceConfig.tsx +35 -0
- package/src/pipelines/stages/findArtifactsFromResource/FindArtifactsFromResourceStageForm.tsx +37 -0
- package/src/pipelines/stages/findArtifactsFromResource/findArtifactsFromResourceStage.ts +21 -0
- package/src/pipelines/stages/index.ts +8 -0
- package/src/pipelines/stages/patchManifest/PatchManifestOptionsForm.tsx +35 -0
- package/src/pipelines/stages/patchManifest/PatchManifestStageConfig.tsx +57 -0
- package/src/pipelines/stages/patchManifest/PatchManifestStageForm.tsx +157 -0
- package/src/pipelines/stages/patchManifest/patchManifestStage.ts +30 -0
- package/src/pipelines/stages/rolloutRestartManifest/RolloutRestartManifestStageConfig.tsx +46 -0
- package/src/pipelines/stages/rolloutRestartManifest/rolloutRestartManifestStage.ts +20 -0
- package/src/pipelines/stages/runJob/KubernetesV2RunJobStageConfig.tsx +242 -0
- package/src/pipelines/stages/runJob/RunJobExecutionDetails.tsx +67 -0
- package/src/pipelines/stages/runJob/runJobStage.ts +39 -0
- package/src/pipelines/stages/scaleManifest/ScaleManifestConfig.tsx +38 -0
- package/src/pipelines/stages/scaleManifest/ScaleManifestStageForm.tsx +46 -0
- package/src/pipelines/stages/scaleManifest/scaleManifestStage.ts +24 -0
- package/src/pipelines/stages/traffic/ManifestTrafficStageConfig.tsx +44 -0
- package/src/pipelines/stages/traffic/disableManifest.stage.ts +26 -0
- package/src/pipelines/stages/traffic/enableManifest.stage.ts +26 -0
- package/src/pipelines/stages/undoRolloutManifest/UndoRolloutManifestConfig.tsx +37 -0
- package/src/pipelines/stages/undoRolloutManifest/UndoRolloutManifestStageForm.tsx +60 -0
- package/src/pipelines/stages/undoRolloutManifest/undoRolloutManifestStage.ts +21 -0
- package/src/pipelines/stages/validators/manifestSelectorValidators.ts +43 -0
- package/src/pipelines/validation/manifestSelector.validator.ts +36 -0
- package/src/rawResource/component/K8sResources.less +9 -0
- package/src/rawResource/component/K8sResources.tsx +112 -0
- package/src/rawResource/component/K8sResourcesFilters.tsx +112 -0
- package/src/rawResource/component/RawResourceUtils.ts +19 -0
- package/src/rawResource/component/group/RawResouceGroup.tsx +41 -0
- package/src/rawResource/component/group/RawResource.less +79 -0
- package/src/rawResource/component/group/RawResource.tsx +51 -0
- package/src/rawResource/component/group/RawResourceDetails.tsx +236 -0
- package/src/rawResource/component/group/RawResourceGroups.tsx +53 -0
- package/src/rawResource/controller/FiltersPubSub.ts +35 -0
- package/src/rawResource/index.ts +1 -0
- package/src/rawResource/model/resource.ts +18 -0
- package/src/rawResource/rawResource.dataSource.ts +39 -0
- package/src/rawResource/rawResource.module.ts +8 -0
- package/src/rawResource/rawResource.states.ts +64 -0
- package/src/resources/ResourceDetails.tsx +121 -0
- package/src/resources/resources.state.ts +45 -0
- package/src/rolloutStrategy/bluegreen.strategy.ts +7 -0
- package/src/rolloutStrategy/highlander.strategy.ts +7 -0
- package/src/rolloutStrategy/index.ts +6 -0
- package/src/rolloutStrategy/none.strategy.ts +8 -0
- package/src/rolloutStrategy/redblack.strategy.ts +7 -0
- package/src/securityGroup/details/details.controller.ts +118 -0
- package/src/securityGroup/details/details.html +91 -0
- package/src/securityGroup/index.ts +1 -0
- package/src/securityGroup/securityGroup.reader.ts +11 -0
- package/src/securityGroup/transformer.ts +19 -0
- package/src/serverGroup/details/details.controller.ts +207 -0
- package/src/serverGroup/details/details.html +153 -0
- package/src/serverGroup/details/resize/resize.controller.ts +73 -0
- package/src/serverGroup/details/resize/resize.html +57 -0
- package/src/serverGroup/index.ts +4 -0
- package/src/serverGroup/serverGroupCommandBuilder.service.ts +18 -0
- package/src/serverGroup/serverGroupTransformer.service.spec.ts +67 -0
- package/src/serverGroup/serverGroupTransformer.service.ts +34 -0
- package/src/serverGroupManager/details/details.controller.ts +191 -0
- package/src/serverGroupManager/details/details.html +136 -0
- package/src/serverGroupManager/index.ts +1 -0
- package/src/validation/applicationName.validator.spec.ts +19 -0
- package/src/validation/applicationName.validator.ts +44 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ICustomValidator, IPipeline, IStage, IStageOrTriggerTypeConfig, IValidatorConfig } from '@spinnaker/core';
|
|
2
|
+
import { ExecutionDetailsTasks, Registry } from '@spinnaker/core';
|
|
3
|
+
|
|
4
|
+
import { KubernetesV2RunJobStageConfig } from './KubernetesV2RunJobStageConfig';
|
|
5
|
+
import { RunJobExecutionDetails } from './RunJobExecutionDetails';
|
|
6
|
+
import { DeployStatus } from '../deployManifest/manifestStatus/DeployStatus';
|
|
7
|
+
|
|
8
|
+
Registry.pipeline.registerStage({
|
|
9
|
+
label: 'Run Job (Manifest)',
|
|
10
|
+
description: 'Run a Kubernetes Job manifest yaml/json file.',
|
|
11
|
+
key: 'runJobManifest',
|
|
12
|
+
alias: 'runJob',
|
|
13
|
+
addAliasToConfig: true,
|
|
14
|
+
cloudProvider: 'kubernetes',
|
|
15
|
+
component: KubernetesV2RunJobStageConfig,
|
|
16
|
+
executionDetailsSections: [RunJobExecutionDetails, DeployStatus, ExecutionDetailsTasks],
|
|
17
|
+
supportsCustomTimeout: true,
|
|
18
|
+
producesArtifacts: true,
|
|
19
|
+
restartable: true,
|
|
20
|
+
validators: [
|
|
21
|
+
{
|
|
22
|
+
type: 'custom',
|
|
23
|
+
validate: (
|
|
24
|
+
_pipeline: IPipeline,
|
|
25
|
+
stage: IStage,
|
|
26
|
+
_validator: IValidatorConfig,
|
|
27
|
+
_config: IStageOrTriggerTypeConfig,
|
|
28
|
+
): string => {
|
|
29
|
+
if (!stage.manifest || !stage.manifest.kind) {
|
|
30
|
+
return '';
|
|
31
|
+
}
|
|
32
|
+
if (stage.manifest.kind !== 'Job') {
|
|
33
|
+
return 'Run Job (Manifest) only accepts manifest of kind Job.';
|
|
34
|
+
}
|
|
35
|
+
return '';
|
|
36
|
+
},
|
|
37
|
+
} as ICustomValidator,
|
|
38
|
+
],
|
|
39
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { defaults } from 'lodash';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
import type { IFormikStageConfigInjectedProps, IStageConfigProps } from '@spinnaker/core';
|
|
5
|
+
import { FormikStageConfig } from '@spinnaker/core';
|
|
6
|
+
|
|
7
|
+
import { ScaleManifestStageForm } from './ScaleManifestStageForm';
|
|
8
|
+
|
|
9
|
+
export function ScaleManifestStageConfig({
|
|
10
|
+
application,
|
|
11
|
+
pipeline,
|
|
12
|
+
stage,
|
|
13
|
+
updateStage,
|
|
14
|
+
stageFieldUpdated,
|
|
15
|
+
}: IStageConfigProps) {
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
defaults(stage, {
|
|
18
|
+
app: application.name,
|
|
19
|
+
cloudProvider: 'kubernetes',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
if (stage.isNew) {
|
|
23
|
+
stage.replicas = 0;
|
|
24
|
+
}
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<FormikStageConfig
|
|
29
|
+
application={application}
|
|
30
|
+
pipeline={pipeline}
|
|
31
|
+
stage={stage}
|
|
32
|
+
onChange={updateStage}
|
|
33
|
+
render={(props: IFormikStageConfigInjectedProps) => (
|
|
34
|
+
<ScaleManifestStageForm {...props} stageFieldUpdated={stageFieldUpdated} />
|
|
35
|
+
)}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import type { IFormikStageConfigInjectedProps } from '@spinnaker/core';
|
|
4
|
+
|
|
5
|
+
import type { IScaleCommand } from '../../../manifest';
|
|
6
|
+
import { ScaleSettingsForm } from '../../../manifest/scale/ScaleSettingsForm';
|
|
7
|
+
import type { IManifestSelector } from '../../../manifest/selector/IManifestSelector';
|
|
8
|
+
import { SelectorMode } from '../../../manifest/selector/IManifestSelector';
|
|
9
|
+
import { ManifestSelector } from '../../../manifest/selector/ManifestSelector';
|
|
10
|
+
|
|
11
|
+
interface IScaleManifestStageConfigFormProps {
|
|
12
|
+
stageFieldUpdated: () => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function ScaleManifestStageForm({
|
|
16
|
+
application,
|
|
17
|
+
formik,
|
|
18
|
+
stageFieldUpdated,
|
|
19
|
+
}: IScaleManifestStageConfigFormProps & IFormikStageConfigInjectedProps) {
|
|
20
|
+
const stage = formik.values;
|
|
21
|
+
|
|
22
|
+
const onManifestSelectorChange = () => {
|
|
23
|
+
stageFieldUpdated();
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const onScaleSettingsFormChange = () => {
|
|
27
|
+
stageFieldUpdated();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div className="form-horizontal">
|
|
32
|
+
<h4>Manifest</h4>
|
|
33
|
+
<div className="horizontal-rule" />
|
|
34
|
+
<ManifestSelector
|
|
35
|
+
application={application}
|
|
36
|
+
selector={(stage as unknown) as IManifestSelector}
|
|
37
|
+
modes={[SelectorMode.Static, SelectorMode.Dynamic]}
|
|
38
|
+
onChange={onManifestSelectorChange}
|
|
39
|
+
includeSpinnakerKinds={null}
|
|
40
|
+
/>
|
|
41
|
+
<h4>Settings</h4>
|
|
42
|
+
<div className="horizontal-rule" />
|
|
43
|
+
<ScaleSettingsForm options={(stage as unknown) as IScaleCommand} onChange={onScaleSettingsFormChange} />
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { IStage } from '@spinnaker/core';
|
|
2
|
+
import { ExecutionDetailsTasks, Registry } from '@spinnaker/core';
|
|
3
|
+
|
|
4
|
+
import { manifestExecutionDetails } from '../ManifestExecutionDetails';
|
|
5
|
+
import { ScaleManifestStageConfig } from './ScaleManifestConfig';
|
|
6
|
+
import { manifestSelectorValidators } from '../validators/manifestSelectorValidators';
|
|
7
|
+
|
|
8
|
+
const STAGE_NAME = 'Scale (Manifest)';
|
|
9
|
+
const STAGE_KEY = 'scaleManifest';
|
|
10
|
+
|
|
11
|
+
Registry.pipeline.registerStage({
|
|
12
|
+
label: STAGE_NAME,
|
|
13
|
+
description: 'Scale a Kubernetes object created from a manifest.',
|
|
14
|
+
key: STAGE_KEY,
|
|
15
|
+
cloudProvider: 'kubernetes',
|
|
16
|
+
component: ScaleManifestStageConfig,
|
|
17
|
+
executionDetailsSections: [manifestExecutionDetails(STAGE_KEY), ExecutionDetailsTasks],
|
|
18
|
+
accountExtractor: (stage: IStage): string[] => (stage.context.account ? [stage.context.account] : []),
|
|
19
|
+
configAccountExtractor: (stage: any): string[] => (stage.account ? [stage.account] : []),
|
|
20
|
+
validators: [
|
|
21
|
+
...manifestSelectorValidators(STAGE_NAME),
|
|
22
|
+
{ type: 'requiredField', fieldName: 'replicas', fieldLabel: 'Replicas' },
|
|
23
|
+
],
|
|
24
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defaults } from 'lodash';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import type { IStage, IStageConfigProps } from '@spinnaker/core';
|
|
5
|
+
|
|
6
|
+
import type { IManifestSelector } from '../../../manifest/selector/IManifestSelector';
|
|
7
|
+
import { SelectorMode } from '../../../manifest/selector/IManifestSelector';
|
|
8
|
+
import { ManifestSelector } from '../../../manifest/selector/ManifestSelector';
|
|
9
|
+
|
|
10
|
+
export interface IKubernetesManifestStageConfigProps extends IStageConfigProps {
|
|
11
|
+
stage: IManifestSelector & IStage;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class ManifestTrafficStageConfig extends React.Component<IKubernetesManifestStageConfigProps> {
|
|
15
|
+
public componentDidMount = (): void => {
|
|
16
|
+
defaults(this.props.stage, {
|
|
17
|
+
app: this.props.application.name,
|
|
18
|
+
cloudProvider: 'kubernetes',
|
|
19
|
+
});
|
|
20
|
+
this.props.stageFieldUpdated();
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
private onChange = (stage: IManifestSelector): void => {
|
|
24
|
+
Object.assign(this.props.stage, stage);
|
|
25
|
+
this.props.stageFieldUpdated();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
public render() {
|
|
29
|
+
const selector = { ...this.props.stage };
|
|
30
|
+
return (
|
|
31
|
+
<div className="form-horizontal">
|
|
32
|
+
<h4>Manifest</h4>
|
|
33
|
+
<div className="horizontal-rule" />
|
|
34
|
+
<ManifestSelector
|
|
35
|
+
application={this.props.application}
|
|
36
|
+
selector={selector}
|
|
37
|
+
modes={[SelectorMode.Static, SelectorMode.Dynamic]}
|
|
38
|
+
onChange={this.onChange}
|
|
39
|
+
includeSpinnakerKinds={['serverGroups']}
|
|
40
|
+
/>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { module } from 'angular';
|
|
2
|
+
|
|
3
|
+
import type { IStage } from '@spinnaker/core';
|
|
4
|
+
import { EXECUTION_ARTIFACT_TAB, ExecutionDetailsTasks, Registry } from '@spinnaker/core';
|
|
5
|
+
|
|
6
|
+
import { manifestExecutionDetails } from '../ManifestExecutionDetails';
|
|
7
|
+
import { ManifestTrafficStageConfig } from './ManifestTrafficStageConfig';
|
|
8
|
+
import { manifestSelectorValidators } from '../validators/manifestSelectorValidators';
|
|
9
|
+
|
|
10
|
+
const STAGE_NAME = 'Disable (Manifest)';
|
|
11
|
+
const STAGE_KEY = 'disableManifest';
|
|
12
|
+
export const KUBERNETES_DISABLE_MANIFEST_STAGE = 'spinnaker.kubernetes.v2.pipeline.stage.disableManifestStage';
|
|
13
|
+
module(KUBERNETES_DISABLE_MANIFEST_STAGE, [EXECUTION_ARTIFACT_TAB]).config(() => {
|
|
14
|
+
Registry.pipeline.registerStage({
|
|
15
|
+
label: STAGE_NAME,
|
|
16
|
+
description: 'Disable a Kubernetes manifest.',
|
|
17
|
+
key: STAGE_KEY,
|
|
18
|
+
cloudProvider: 'kubernetes',
|
|
19
|
+
component: ManifestTrafficStageConfig,
|
|
20
|
+
executionDetailsSections: [manifestExecutionDetails(STAGE_KEY), ExecutionDetailsTasks],
|
|
21
|
+
supportsCustomTimeout: true,
|
|
22
|
+
accountExtractor: (stage: IStage): string[] => (stage.account ? [stage.account] : []),
|
|
23
|
+
configAccountExtractor: (stage: IStage): string[] => (stage.account ? [stage.account] : []),
|
|
24
|
+
validators: manifestSelectorValidators(STAGE_NAME),
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { module } from 'angular';
|
|
2
|
+
|
|
3
|
+
import type { IStage } from '@spinnaker/core';
|
|
4
|
+
import { EXECUTION_ARTIFACT_TAB, ExecutionDetailsTasks, Registry } from '@spinnaker/core';
|
|
5
|
+
|
|
6
|
+
import { manifestExecutionDetails } from '../ManifestExecutionDetails';
|
|
7
|
+
import { ManifestTrafficStageConfig } from './ManifestTrafficStageConfig';
|
|
8
|
+
import { manifestSelectorValidators } from '../validators/manifestSelectorValidators';
|
|
9
|
+
|
|
10
|
+
const STAGE_NAME = 'Enable (Manifest)';
|
|
11
|
+
const STAGE_KEY = 'enableManifest';
|
|
12
|
+
export const KUBERNETES_ENABLE_MANIFEST_STAGE = 'spinnaker.kubernetes.v2.pipeline.stage.enableManifestStage';
|
|
13
|
+
module(KUBERNETES_ENABLE_MANIFEST_STAGE, [EXECUTION_ARTIFACT_TAB]).config(() => {
|
|
14
|
+
Registry.pipeline.registerStage({
|
|
15
|
+
label: STAGE_NAME,
|
|
16
|
+
description: 'Enable a Kubernetes manifest.',
|
|
17
|
+
key: STAGE_KEY,
|
|
18
|
+
cloudProvider: 'kubernetes',
|
|
19
|
+
component: ManifestTrafficStageConfig,
|
|
20
|
+
executionDetailsSections: [manifestExecutionDetails(STAGE_KEY), ExecutionDetailsTasks],
|
|
21
|
+
supportsCustomTimeout: true,
|
|
22
|
+
accountExtractor: (stage: IStage): string[] => (stage.account ? [stage.account] : []),
|
|
23
|
+
configAccountExtractor: (stage: IStage): string[] => (stage.account ? [stage.account] : []),
|
|
24
|
+
validators: manifestSelectorValidators(STAGE_NAME),
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { defaults } from 'lodash';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
import type { IFormikStageConfigInjectedProps, IStageConfigProps } from '@spinnaker/core';
|
|
5
|
+
import { FormikStageConfig } from '@spinnaker/core';
|
|
6
|
+
|
|
7
|
+
import { UndoRolloutManifestStageForm } from './UndoRolloutManifestStageForm';
|
|
8
|
+
|
|
9
|
+
export function UndoRolloutManifestConfig({
|
|
10
|
+
application,
|
|
11
|
+
pipeline,
|
|
12
|
+
stage,
|
|
13
|
+
updateStage,
|
|
14
|
+
stageFieldUpdated,
|
|
15
|
+
}: IStageConfigProps) {
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
defaults(stage, {
|
|
18
|
+
cloudProvider: 'kubernetes',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
if (stage.isNew) {
|
|
22
|
+
stage.numRevisionsBack = 1;
|
|
23
|
+
}
|
|
24
|
+
}, []);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<FormikStageConfig
|
|
28
|
+
application={application}
|
|
29
|
+
pipeline={pipeline}
|
|
30
|
+
stage={stage}
|
|
31
|
+
onChange={updateStage}
|
|
32
|
+
render={(props: IFormikStageConfigInjectedProps) => (
|
|
33
|
+
<UndoRolloutManifestStageForm {...props} stageFieldUpdated={stageFieldUpdated} />
|
|
34
|
+
)}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import type { IFormikStageConfigInjectedProps } from '@spinnaker/core';
|
|
4
|
+
import { NumberInput, StageConfigField } from '@spinnaker/core';
|
|
5
|
+
|
|
6
|
+
import type { IManifestSelector } from '../../../manifest/selector/IManifestSelector';
|
|
7
|
+
import { SelectorMode } from '../../../manifest/selector/IManifestSelector';
|
|
8
|
+
import { ManifestSelector } from '../../../manifest/selector/ManifestSelector';
|
|
9
|
+
|
|
10
|
+
interface IUndoRolloutManifestStageConfigFormProps {
|
|
11
|
+
stageFieldUpdated: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function UndoRolloutManifestStageForm({
|
|
15
|
+
application,
|
|
16
|
+
formik,
|
|
17
|
+
stageFieldUpdated,
|
|
18
|
+
}: IUndoRolloutManifestStageConfigFormProps & IFormikStageConfigInjectedProps) {
|
|
19
|
+
const stage = formik.values;
|
|
20
|
+
|
|
21
|
+
const onManifestSelectorChange = () => {
|
|
22
|
+
stageFieldUpdated();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const onRevisionsChange = (e: React.ChangeEvent<any>) => {
|
|
26
|
+
formik.setFieldValue('numRevisionsBack', e.target.value);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className="form-horizontal">
|
|
31
|
+
<h4>Manifest</h4>
|
|
32
|
+
<div className="horizontal-rule" />
|
|
33
|
+
<ManifestSelector
|
|
34
|
+
application={application}
|
|
35
|
+
selector={(stage as unknown) as IManifestSelector}
|
|
36
|
+
modes={[SelectorMode.Static, SelectorMode.Dynamic]}
|
|
37
|
+
onChange={onManifestSelectorChange}
|
|
38
|
+
includeSpinnakerKinds={null}
|
|
39
|
+
/>
|
|
40
|
+
<h4>Settings</h4>
|
|
41
|
+
<div className="horizontal-rule" />
|
|
42
|
+
<StageConfigField
|
|
43
|
+
label="Revisions Back"
|
|
44
|
+
helpKey="kubernetes.manifest.undoRollout.revisionsBack"
|
|
45
|
+
fieldColumns={4}
|
|
46
|
+
groupClassName="form-group form-inline"
|
|
47
|
+
>
|
|
48
|
+
<div className="input-group">
|
|
49
|
+
<NumberInput
|
|
50
|
+
inputClassName="input-sm highlight-pristine"
|
|
51
|
+
onChange={onRevisionsChange}
|
|
52
|
+
value={stage.numRevisionsBack}
|
|
53
|
+
min={1}
|
|
54
|
+
/>
|
|
55
|
+
<span className="input-group-addon">{stage.numRevisionsBack === '1' ? 'revision' : 'revisions'}</span>
|
|
56
|
+
</div>
|
|
57
|
+
</StageConfigField>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ExecutionDetailsTasks, Registry } from '@spinnaker/core';
|
|
2
|
+
|
|
3
|
+
import { manifestExecutionDetails } from '../ManifestExecutionDetails';
|
|
4
|
+
import { UndoRolloutManifestConfig } from './UndoRolloutManifestConfig';
|
|
5
|
+
import { manifestSelectorValidators } from '../validators/manifestSelectorValidators';
|
|
6
|
+
|
|
7
|
+
const STAGE_NAME = 'Undo Rollout (Manifest)';
|
|
8
|
+
const STAGE_KEY = 'undoRolloutManifest';
|
|
9
|
+
|
|
10
|
+
Registry.pipeline.registerStage({
|
|
11
|
+
label: STAGE_NAME,
|
|
12
|
+
description: 'Rollback a manifest a target number of revisions.',
|
|
13
|
+
key: STAGE_KEY,
|
|
14
|
+
cloudProvider: 'kubernetes',
|
|
15
|
+
component: UndoRolloutManifestConfig,
|
|
16
|
+
executionDetailsSections: [manifestExecutionDetails(STAGE_KEY), ExecutionDetailsTasks],
|
|
17
|
+
validators: [
|
|
18
|
+
...manifestSelectorValidators(STAGE_NAME),
|
|
19
|
+
{ type: 'requiredField', fieldName: 'numRevisionsBack', fieldLabel: 'Number of Revisions' },
|
|
20
|
+
],
|
|
21
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ICustomValidator, IPipeline, IStage, IValidatorConfig } from '@spinnaker/core';
|
|
2
|
+
|
|
3
|
+
import type { IManifestSelector } from '../../../manifest/selector/IManifestSelector';
|
|
4
|
+
import { SelectorMode } from '../../../manifest/selector/IManifestSelector';
|
|
5
|
+
|
|
6
|
+
export const manifestSelectorValidators = (stageName: string): IValidatorConfig[] => {
|
|
7
|
+
const required = (field: string) => `<strong>${field}</strong> is a required field for ${stageName} stages.`;
|
|
8
|
+
|
|
9
|
+
return [
|
|
10
|
+
{ type: 'requiredField', fieldName: 'location', fieldLabel: 'Namespace' },
|
|
11
|
+
{ type: 'requiredField', fieldName: 'account', fieldLabel: 'Account' },
|
|
12
|
+
{
|
|
13
|
+
type: 'custom',
|
|
14
|
+
validate: (_pipeline: IPipeline, stage: IManifestSelector & IStage) => {
|
|
15
|
+
if (stage.mode === SelectorMode.Dynamic) {
|
|
16
|
+
if (!stage.kind) {
|
|
17
|
+
return required('Kind');
|
|
18
|
+
}
|
|
19
|
+
if (!stage.cluster) {
|
|
20
|
+
return required('Cluster');
|
|
21
|
+
}
|
|
22
|
+
if (!stage.criteria) {
|
|
23
|
+
return required('Target');
|
|
24
|
+
}
|
|
25
|
+
} else if (stage.mode === SelectorMode.Static) {
|
|
26
|
+
const [kind] = (stage.manifestName || '').split(' ');
|
|
27
|
+
if (!kind) {
|
|
28
|
+
return required('Kind');
|
|
29
|
+
}
|
|
30
|
+
const [, name] = (stage.manifestName || '').split(' ');
|
|
31
|
+
if (!name) {
|
|
32
|
+
return required('Name');
|
|
33
|
+
}
|
|
34
|
+
} else if (stage.mode === SelectorMode.Label) {
|
|
35
|
+
if (!stage.kinds) {
|
|
36
|
+
return required('Kinds');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
},
|
|
41
|
+
} as ICustomValidator,
|
|
42
|
+
];
|
|
43
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
IPipeline,
|
|
3
|
+
IStage,
|
|
4
|
+
IStageOrTriggerTypeConfig,
|
|
5
|
+
IStageOrTriggerValidator,
|
|
6
|
+
IValidatorConfig,
|
|
7
|
+
} from '@spinnaker/core';
|
|
8
|
+
import { PipelineConfigValidator } from '@spinnaker/core';
|
|
9
|
+
|
|
10
|
+
export interface IStageWithManifestSelector extends IStage {
|
|
11
|
+
manifestName: string;
|
|
12
|
+
location: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class ManifestSelectorValidator implements IStageOrTriggerValidator {
|
|
16
|
+
public validate(
|
|
17
|
+
_pipeline: IPipeline,
|
|
18
|
+
stage: IStageWithManifestSelector,
|
|
19
|
+
_validator: IValidatorConfig,
|
|
20
|
+
_config: IStageOrTriggerTypeConfig,
|
|
21
|
+
): string {
|
|
22
|
+
const [kind, name] = (stage.manifestName || '').split(' ');
|
|
23
|
+
if (!name && !kind) {
|
|
24
|
+
return `<strong>Name</strong> and <strong>Kind</strong> are required fields.`;
|
|
25
|
+
}
|
|
26
|
+
if (!name) {
|
|
27
|
+
return `<strong>Name</strong> is a required field.`;
|
|
28
|
+
}
|
|
29
|
+
if (!kind) {
|
|
30
|
+
return `<strong>Kind</strong> is a required field.`;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
PipelineConfigValidator.registerValidator('manifestSelector', new ManifestSelectorValidator());
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import type { Application, ApplicationDataSource } from '@spinnaker/core';
|
|
4
|
+
import { FormField, ReactSelectInput } from '@spinnaker/core';
|
|
5
|
+
|
|
6
|
+
import type { IK8sResourcesFiltersState } from './K8sResourcesFilters';
|
|
7
|
+
import { RawResourceUtils } from './RawResourceUtils';
|
|
8
|
+
import { FiltersPubSub } from '../controller/FiltersPubSub';
|
|
9
|
+
import { RawResource } from './group/RawResource';
|
|
10
|
+
import { RawResourceGroups } from './group/RawResourceGroups';
|
|
11
|
+
import { KUBERNETS_RAW_RESOURCE_DATA_SOURCE_KEY } from '../rawResource.dataSource';
|
|
12
|
+
|
|
13
|
+
import './K8sResources.less';
|
|
14
|
+
|
|
15
|
+
export interface IK8sResourcesProps {
|
|
16
|
+
app: Application;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface IK8sResourcesState {
|
|
20
|
+
groupBy: string;
|
|
21
|
+
filters: IK8sResourcesFiltersState;
|
|
22
|
+
rawResources: IApiKubernetesResource[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class K8sResources extends React.Component<IK8sResourcesProps, IK8sResourcesState> {
|
|
26
|
+
private dataSource: ApplicationDataSource<IApiKubernetesResource[]>;
|
|
27
|
+
private filterPubSub: FiltersPubSub = FiltersPubSub.getInstance(this.props.app.name);
|
|
28
|
+
private sub = this.onFilterChange.bind(this);
|
|
29
|
+
|
|
30
|
+
constructor(props: IK8sResourcesProps) {
|
|
31
|
+
super(props);
|
|
32
|
+
this.dataSource = this.props.app.getDataSource(KUBERNETS_RAW_RESOURCE_DATA_SOURCE_KEY);
|
|
33
|
+
this.state = {
|
|
34
|
+
groupBy: 'none',
|
|
35
|
+
filters: null,
|
|
36
|
+
rawResources: [],
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
this.filterPubSub.subscribe(this.sub);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public componentWillUnmount() {
|
|
43
|
+
this.filterPubSub.unsubscribe(this.sub);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public onFilterChange(message: IK8sResourcesFiltersState) {
|
|
47
|
+
this.setState({ ...this.state, filters: message });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public async componentDidMount() {
|
|
51
|
+
await this.dataSource.ready();
|
|
52
|
+
|
|
53
|
+
this.setState({
|
|
54
|
+
...this.state,
|
|
55
|
+
groupBy: this.state.groupBy,
|
|
56
|
+
rawResources: await this.dataSource.data.sort((a, b) => a.name.localeCompare(b.name)),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private groupByChanged = (e: React.ChangeEvent<any>): void => {
|
|
61
|
+
this.setState({ groupBy: e.target.value.toLowerCase() });
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
public render() {
|
|
65
|
+
const opts = ['None', 'Account', 'Kind', 'Namespace'];
|
|
66
|
+
return (
|
|
67
|
+
<div className="K8sResources">
|
|
68
|
+
<div className="header row">
|
|
69
|
+
<FormField
|
|
70
|
+
onChange={this.groupByChanged}
|
|
71
|
+
value={this.state.groupBy.charAt(0).toUpperCase() + this.state.groupBy.substr(1)}
|
|
72
|
+
name="groupBy"
|
|
73
|
+
label="Group By"
|
|
74
|
+
input={(props) => (
|
|
75
|
+
<ReactSelectInput {...props} inputClassName="groupby" stringOptions={opts} clearable={false} />
|
|
76
|
+
)}
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
<div className="content">
|
|
80
|
+
{this.state.groupBy === 'none' ? (
|
|
81
|
+
<>
|
|
82
|
+
{...this.state.rawResources
|
|
83
|
+
.filter((resource) => this.matchFilters(resource))
|
|
84
|
+
.map((resource) => (
|
|
85
|
+
<RawResource key={RawResourceUtils.resourceKey(resource)} resource={resource}></RawResource>
|
|
86
|
+
))}
|
|
87
|
+
</>
|
|
88
|
+
) : (
|
|
89
|
+
<RawResourceGroups
|
|
90
|
+
resources={this.state.rawResources.filter((resource) => this.matchFilters(resource))}
|
|
91
|
+
groupBy={this.state.groupBy}
|
|
92
|
+
></RawResourceGroups>
|
|
93
|
+
)}
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private matchFilters(resource: IApiKubernetesResource) {
|
|
100
|
+
if (this.state.filters == null) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
const accountMatch =
|
|
104
|
+
Object.values(this.state.filters.accounts).every((x) => !x) || this.state.filters.accounts[resource.account];
|
|
105
|
+
const kindMatch =
|
|
106
|
+
Object.values(this.state.filters.kinds).every((x) => !x) || this.state.filters.kinds[resource.kind];
|
|
107
|
+
const namespaceMatch =
|
|
108
|
+
Object.values(this.state.filters.namespaces).every((x) => !x) ||
|
|
109
|
+
this.state.filters.namespaces[resource.namespace];
|
|
110
|
+
return accountMatch && kindMatch && namespaceMatch;
|
|
111
|
+
}
|
|
112
|
+
}
|