Skip to content
This repository was archived by the owner on Dec 20, 2025. It is now read-only.

Commit 4040461

Browse files
refactor(kubernetes): convert find artifacts from resource stage to react (#10157)
1 parent 269b738 commit 4040461

File tree

7 files changed

+86
-63
lines changed

7 files changed

+86
-63
lines changed

packages/kubernetes/src/kubernetes.module.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import { KUBERNETES_MANIFEST_CONDITION } from './manifest/status/condition.compo
3131
import { KUBERNETES_MANIFEST_STATUS } from './manifest/status/status.component';
3232
import { ManifestWizard } from './manifest/wizard/ManifestWizard';
3333
import './pipelines/stages';
34-
import { KUBERNETES_FIND_ARTIFACTS_FROM_RESOURCE_STAGE } from './pipelines/stages/findArtifactsFromResource/findArtifactsFromResourceStage';
3534
import { KUBERNETES_DISABLE_MANIFEST_STAGE } from './pipelines/stages/traffic/disableManifest.stage';
3635
import { KUBERNETES_ENABLE_MANIFEST_STAGE } from './pipelines/stages/traffic/enableManifest.stage';
3736
import { KUBERNETES_UNDO_ROLLOUT_MANIFEST_STAGE } from './pipelines/stages/undoRolloutManifest/undoRolloutManifestStage';
@@ -73,7 +72,6 @@ const requires = [
7372
KUBERNETES_LOAD_BALANCER_TRANSFORMER,
7473
KUBERNETES_SECURITY_GROUP_TRANSFORMER,
7574
KUBERNETES_UNDO_ROLLOUT_MANIFEST_STAGE,
76-
KUBERNETES_FIND_ARTIFACTS_FROM_RESOURCE_STAGE,
7775
KUBERNETES_MANIFEST_SELECTOR,
7876
KUBERNETES_MANIFEST_LABELS,
7977
KUBERNETES_MANIFEST_EVENTS,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { defaults } from 'lodash';
2+
import { useEffect } from 'react';
3+
import React from 'react';
4+
5+
import type { IFormikStageConfigInjectedProps, IStageConfigProps } from '@spinnaker/core';
6+
import { FormikStageConfig } from '@spinnaker/core';
7+
8+
import { FindArtifactsFromResourceStageForm } from './FindArtifactsFromResourceStageForm';
9+
10+
export function FindArtifactsFromResourceConfig({
11+
application,
12+
pipeline,
13+
stage,
14+
updateStage,
15+
stageFieldUpdated,
16+
}: IStageConfigProps) {
17+
useEffect(() => {
18+
defaults(stage, {
19+
app: application.name,
20+
cloudProvider: 'kubernetes',
21+
});
22+
}, []);
23+
24+
return (
25+
<FormikStageConfig
26+
application={application}
27+
pipeline={pipeline}
28+
stage={stage}
29+
onChange={updateStage}
30+
render={(props: IFormikStageConfigInjectedProps) => (
31+
<FindArtifactsFromResourceStageForm {...props} stageFieldUpdated={stageFieldUpdated} />
32+
)}
33+
/>
34+
);
35+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react';
2+
3+
import type { IFormikStageConfigInjectedProps } from '@spinnaker/core';
4+
5+
import type { IManifestSelector } from '../../../manifest/selector/IManifestSelector';
6+
import { SelectorMode } from '../../../manifest/selector/IManifestSelector';
7+
import { ManifestSelector } from '../../../manifest/selector/ManifestSelector';
8+
9+
interface IFindArtifactsFromResourceStageConfigFormProps {
10+
stageFieldUpdated: () => void;
11+
}
12+
13+
export function FindArtifactsFromResourceStageForm({
14+
application,
15+
formik,
16+
stageFieldUpdated,
17+
}: IFindArtifactsFromResourceStageConfigFormProps & IFormikStageConfigInjectedProps) {
18+
const stage = formik.values;
19+
20+
const onManifestSelectorChange = () => {
21+
stageFieldUpdated();
22+
};
23+
24+
return (
25+
<div className="form-horizontal">
26+
<h4>Manifest</h4>
27+
<div className="horizontal-rule" />
28+
<ManifestSelector
29+
application={application}
30+
selector={(stage as unknown) as IManifestSelector}
31+
modes={[SelectorMode.Static, SelectorMode.Dynamic]}
32+
onChange={onManifestSelectorChange}
33+
includeSpinnakerKinds={null}
34+
/>
35+
</div>
36+
);
37+
}

packages/kubernetes/src/pipelines/stages/findArtifactsFromResource/findArtifactsFromResourceConfig.controller.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

packages/kubernetes/src/pipelines/stages/findArtifactsFromResource/findArtifactsFromResourceConfig.html

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
1-
import { module } from 'angular';
2-
31
import { ExecutionArtifactTab, ExecutionDetailsTasks, Registry } from '@spinnaker/core';
42

5-
import { KubernetesV2FindArtifactsFromResourceConfigCtrl } from './findArtifactsFromResourceConfig.controller';
6-
import { KUBERNETES_MANIFEST_SELECTOR } from '../../../manifest/selector/selector.component';
3+
import { FindArtifactsFromResourceConfig } from './FindArtifactsFromResourceConfig';
74
import { manifestSelectorValidators } from '../validators/manifestSelectorValidators';
85

9-
export const KUBERNETES_FIND_ARTIFACTS_FROM_RESOURCE_STAGE =
10-
'spinnaker.kubernetes.v2.pipeline.stage.findArtifactsFromResource';
11-
126
const STAGE_NAME = 'Find Artifacts From Resource (Manifest)';
13-
module(KUBERNETES_FIND_ARTIFACTS_FROM_RESOURCE_STAGE, [KUBERNETES_MANIFEST_SELECTOR])
14-
.config(() => {
15-
Registry.pipeline.registerStage({
16-
label: STAGE_NAME,
17-
description: 'Finds artifacts from a Kubernetes resource.',
18-
key: 'findArtifactsFromResource',
19-
cloudProvider: 'kubernetes',
20-
templateUrl: require('./findArtifactsFromResourceConfig.html'),
21-
controller: 'KubernetesV2FindArtifactsFromResourceConfigCtrl',
22-
controllerAs: 'ctrl',
23-
executionDetailsSections: [ExecutionDetailsTasks, ExecutionArtifactTab],
24-
producesArtifacts: true,
25-
validators: manifestSelectorValidators(STAGE_NAME),
26-
});
27-
})
28-
.controller('KubernetesV2FindArtifactsFromResourceConfigCtrl', KubernetesV2FindArtifactsFromResourceConfigCtrl);
7+
const STAGE_KEY = 'findArtifactsFromResource';
8+
9+
Registry.pipeline.registerStage({
10+
label: STAGE_NAME,
11+
description: 'Finds artifacts from a Kubernetes resource.',
12+
key: STAGE_KEY,
13+
cloudProvider: 'kubernetes',
14+
component: FindArtifactsFromResourceConfig,
15+
executionDetailsSections: [ExecutionDetailsTasks, ExecutionArtifactTab],
16+
producesArtifacts: true,
17+
validators: manifestSelectorValidators(STAGE_NAME),
18+
});

packages/kubernetes/src/pipelines/stages/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * from './deleteManifest/deleteManifestStage';
22
export * from './deployManifest/deployManifestStage';
3+
export * from './findArtifactsFromResource/findArtifactsFromResourceStage';
34
export * from './patchManifest/patchManifestStage';
45
export * from './rolloutRestartManifest/rolloutRestartManifestStage';
56
export * from './runJob/runJobStage';

0 commit comments

Comments
 (0)