@spinnaker/kubernetes 0.6.1 → 2025.0.0

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/index.js +6023 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/manifest/scale/ScaleSettingsForm.d.ts +10 -0
  5. package/dist/manifest/scale/scale.controller.d.ts +7 -0
  6. package/dist/pipelines/stages/deployManifest/DeployManifestStageForm.d.ts +8 -0
  7. package/dist/pipelines/stages/findArtifactsFromResource/FindArtifactsFromResourceConfig.d.ts +3 -0
  8. package/dist/pipelines/stages/findArtifactsFromResource/FindArtifactsFromResourceStageForm.d.ts +7 -0
  9. package/dist/pipelines/stages/findArtifactsFromResource/findArtifactsFromResourceStage.d.ts +1 -1
  10. package/dist/pipelines/stages/index.d.ts +3 -0
  11. package/dist/pipelines/stages/scaleManifest/ScaleManifestConfig.d.ts +3 -0
  12. package/dist/pipelines/stages/scaleManifest/ScaleManifestStageForm.d.ts +7 -0
  13. package/dist/pipelines/stages/scaleManifest/scaleManifestStage.d.ts +1 -1
  14. package/dist/pipelines/stages/undoRolloutManifest/UndoRolloutManifestConfig.d.ts +3 -0
  15. package/dist/pipelines/stages/undoRolloutManifest/UndoRolloutManifestStageForm.d.ts +7 -0
  16. package/dist/pipelines/stages/undoRolloutManifest/undoRolloutManifestStage.d.ts +1 -1
  17. package/package.json +5 -4
  18. package/src/help/kubernetes.help.ts +6 -0
  19. package/src/kubernetes.module.ts +0 -6
  20. package/src/manifest/scale/ScaleSettingsForm.tsx +43 -0
  21. package/src/manifest/scale/scale.controller.ts +11 -6
  22. package/src/manifest/scale/scale.html +9 -4
  23. package/src/manifest/scale/scaleSettingsForm.component.ts +4 -22
  24. package/src/pipelines/stages/deleteManifest/deleteManifestStage.ts +1 -1
  25. package/src/pipelines/stages/deployManifest/DeployManifestStageForm.tsx +66 -0
  26. package/src/pipelines/stages/deployManifest/deployManifestStage.ts +1 -1
  27. package/src/pipelines/stages/findArtifactsFromResource/FindArtifactsFromResourceConfig.tsx +35 -0
  28. package/src/pipelines/stages/findArtifactsFromResource/FindArtifactsFromResourceStageForm.tsx +37 -0
  29. package/src/pipelines/stages/findArtifactsFromResource/findArtifactsFromResourceStage.ts +16 -23
  30. package/src/pipelines/stages/index.ts +3 -0
  31. package/src/pipelines/stages/scaleManifest/ScaleManifestConfig.tsx +38 -0
  32. package/src/pipelines/stages/scaleManifest/ScaleManifestStageForm.tsx +46 -0
  33. package/src/pipelines/stages/scaleManifest/scaleManifestStage.ts +17 -26
  34. package/src/pipelines/stages/undoRolloutManifest/UndoRolloutManifestConfig.tsx +37 -0
  35. package/src/pipelines/stages/undoRolloutManifest/UndoRolloutManifestStageForm.tsx +60 -0
  36. package/src/pipelines/stages/undoRolloutManifest/undoRolloutManifestStage.ts +18 -27
  37. package/dist/pipelines/stages/findArtifactsFromResource/findArtifactsFromResourceConfig.controller.d.ts +0 -9
  38. package/dist/pipelines/stages/scaleManifest/scaleManifestConfig.controller.d.ts +0 -9
  39. package/dist/pipelines/stages/undoRolloutManifest/undoRolloutManifestConfig.controller.d.ts +0 -7
  40. package/src/pipelines/stages/findArtifactsFromResource/findArtifactsFromResourceConfig.controller.ts +0 -28
  41. package/src/pipelines/stages/findArtifactsFromResource/findArtifactsFromResourceConfig.html +0 -10
  42. package/src/pipelines/stages/scaleManifest/scaleManifestConfig.controller.ts +0 -32
  43. package/src/pipelines/stages/scaleManifest/scaleManifestConfig.html +0 -13
  44. package/src/pipelines/stages/undoRolloutManifest/undoRolloutManifestConfig.controller.ts +0 -19
  45. package/src/pipelines/stages/undoRolloutManifest/undoRolloutManifestConfig.html +0 -28
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import type { IScaleCommand } from './scale.controller';
3
+ export interface IScaleSettingsFormProps {
4
+ options: IScaleCommand;
5
+ onChange(options: IScaleCommand): void;
6
+ }
7
+ export interface IScaleSettingsFormState {
8
+ options: IScaleCommand;
9
+ }
10
+ export declare function ScaleSettingsForm({ options, onChange }: IScaleSettingsFormProps): JSX.Element;
@@ -1 +1,8 @@
1
+ export interface IScaleCommand {
2
+ manifestName: string;
3
+ location: string;
4
+ account: string;
5
+ reason: string;
6
+ replicas: number;
7
+ }
1
8
  export declare const KUBERNETES_MANIFEST_SCALE_CTRL = "spinnaker.kubernetes.v2.manifest.scale.controller";
@@ -1,11 +1,18 @@
1
1
  import React from 'react';
2
2
  import type { IAccountDetails, IFormikStageConfigInjectedProps } from '@spinnaker/core';
3
+ import type { IManifestLabelSelector } from '../../../manifest/selector/IManifestLabelSelector';
4
+ import type { IManifestSelector } from '../../../manifest/selector/IManifestSelector';
5
+ import { SelectorMode } from '../../../manifest/selector/IManifestSelector';
3
6
  interface IDeployManifestStageConfigFormProps {
4
7
  accounts: IAccountDetails[];
8
+ selector?: IManifestSelector;
9
+ modes?: SelectorMode.Label;
5
10
  }
6
11
  interface IDeployManifestStageConfigFormState {
7
12
  rawManifest: string;
8
13
  overrideNamespace: boolean;
14
+ selector: IManifestSelector;
15
+ labelSelectors: IManifestLabelSelector[];
9
16
  }
10
17
  export declare class DeployManifestStageForm extends React.Component<IDeployManifestStageConfigFormProps & IFormikStageConfigInjectedProps, IDeployManifestStageConfigFormState> {
11
18
  private readonly excludedManifestArtifactTypes;
@@ -19,5 +26,6 @@ export declare class DeployManifestStageForm extends React.Component<IDeployMani
19
26
  private onRequiredArtifactsChanged;
20
27
  private overrideNamespaceChange;
21
28
  render(): JSX.Element;
29
+ private handleLabelSelectorsChange;
22
30
  }
23
31
  export {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { IStageConfigProps } from '@spinnaker/core';
3
+ export declare function FindArtifactsFromResourceConfig({ application, pipeline, stage, updateStage, stageFieldUpdated, }: IStageConfigProps): JSX.Element;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { IFormikStageConfigInjectedProps } from '@spinnaker/core';
3
+ interface IFindArtifactsFromResourceStageConfigFormProps {
4
+ stageFieldUpdated: () => void;
5
+ }
6
+ export declare function FindArtifactsFromResourceStageForm({ application, formik, stageFieldUpdated, }: IFindArtifactsFromResourceStageConfigFormProps & IFormikStageConfigInjectedProps): JSX.Element;
7
+ export {};
@@ -1 +1 @@
1
- export declare const KUBERNETES_FIND_ARTIFACTS_FROM_RESOURCE_STAGE = "spinnaker.kubernetes.v2.pipeline.stage.findArtifactsFromResource";
1
+ export {};
@@ -1,5 +1,8 @@
1
1
  export * from './deleteManifest/deleteManifestStage';
2
2
  export * from './deployManifest/deployManifestStage';
3
+ export * from './findArtifactsFromResource/findArtifactsFromResourceStage';
3
4
  export * from './patchManifest/patchManifestStage';
4
5
  export * from './rolloutRestartManifest/rolloutRestartManifestStage';
5
6
  export * from './runJob/runJobStage';
7
+ export * from './undoRolloutManifest/undoRolloutManifestStage';
8
+ export * from './scaleManifest/scaleManifestStage';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { IStageConfigProps } from '@spinnaker/core';
3
+ export declare function ScaleManifestStageConfig({ application, pipeline, stage, updateStage, stageFieldUpdated, }: IStageConfigProps): JSX.Element;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { IFormikStageConfigInjectedProps } from '@spinnaker/core';
3
+ interface IScaleManifestStageConfigFormProps {
4
+ stageFieldUpdated: () => void;
5
+ }
6
+ export declare function ScaleManifestStageForm({ application, formik, stageFieldUpdated, }: IScaleManifestStageConfigFormProps & IFormikStageConfigInjectedProps): JSX.Element;
7
+ export {};
@@ -1 +1 @@
1
- export declare const KUBERNETES_SCALE_MANIFEST_STAGE = "spinnaker.kubernetes.v2.pipeline.stage.scaleManifestStage";
1
+ export {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { IStageConfigProps } from '@spinnaker/core';
3
+ export declare function UndoRolloutManifestConfig({ application, pipeline, stage, updateStage, stageFieldUpdated, }: IStageConfigProps): JSX.Element;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { IFormikStageConfigInjectedProps } from '@spinnaker/core';
3
+ interface IUndoRolloutManifestStageConfigFormProps {
4
+ stageFieldUpdated: () => void;
5
+ }
6
+ export declare function UndoRolloutManifestStageForm({ application, formik, stageFieldUpdated, }: IUndoRolloutManifestStageConfigFormProps & IFormikStageConfigInjectedProps): JSX.Element;
7
+ export {};
@@ -1 +1 @@
1
- export declare const KUBERNETES_UNDO_ROLLOUT_MANIFEST_STAGE = "spinnaker.kubernetes.v2.pipeline.stage.undoRolloutManifestStage";
1
+ export {};
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@spinnaker/kubernetes",
3
3
  "license": "Apache-2.0",
4
- "version": "0.6.1",
4
+ "version": "2025.0.0",
5
5
  "module": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "publishConfig": {
8
- "access": "public"
8
+ "access": "public",
9
+ "registry": "https://registry.npmjs.org"
9
10
  },
10
11
  "scripts": {
11
12
  "clean": "shx rm -rf dist",
@@ -16,7 +17,7 @@
16
17
  "lib": "npm run build"
17
18
  },
18
19
  "dependencies": {
19
- "@spinnaker/core": "^0.29.0",
20
+ "@spinnaker/core": "^0.29.1",
20
21
  "@uirouter/angularjs": "1.0.26",
21
22
  "@uirouter/react": "1.0.7",
22
23
  "angular": "1.6.10",
@@ -53,5 +54,5 @@
53
54
  "shx": "0.3.3",
54
55
  "typescript": "4.3.5"
55
56
  },
56
- "gitHead": "082a084908e13888d640e88a5bd6e1571479de14"
57
+ "gitHead": "5b197da8614979a51dc24b0a6f92e19c3162e874"
57
58
  }
@@ -211,6 +211,12 @@ const helpContents: { [key: string]: string } = {
211
211
  'These artifacts must be present in the context for this stage to successfully complete. Artifacts specified will be <a href="https://www.spinnaker.io/reference/artifacts/in-kubernetes-v2/#binding-artifacts-in-manifests" target="_blank">bound to the deployed manifest.</a>',
212
212
  'kubernetes.manifest.skipExpressionEvaluation':
213
213
  '<p>Skip SpEL expression evaluation of the manifest artifact in this stage. Can be paired with the "Evaluate SpEL expressions in overrides at bake time" option in the Bake Manifest stage when baking a third-party manifest artifact with expressions not meant for Spinnaker to evaluate as SpEL.</p>',
214
+ 'kubernetes.manifest.skipSpecTemplateLabels': `
215
+ <p>Skip applying the <a href="https://spinnaker.io/docs/reference/providers/kubernetes-v2/#reserved-labels" target="_blank">Reserved labels</a> to the manifest's <b><i>.spec.template.metadata.labels.</i></b></p>`,
216
+ 'kubernetes.manifest.deployLabelSelectors': `
217
+ <p>Via Label Selectors, Spinnaker can deploy a subset of manifests satisfying the Label Selectors. See <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors" target="_blank">Kubernetes Label Selectors</a> for more details. Multiple selectors combine with AND (All must be satisfied).</p>`,
218
+ 'kubernetes.manifest.deployLabelSelectors.allowNothingSelected': `
219
+ <p>When unchecked an error is thrown if none of the provided manifests satisfy the Label Selectors</p>`,
214
220
  'kubernetes.manifest.undoRollout.revisionsBack': `
215
221
  <p>How many revisions to rollback from the current active revision. This is not a hard-coded revision to rollout.</p>
216
222
  <p>For example: If you specify "1", and this stage executes, the prior revision will be active upon success.</p>
@@ -31,11 +31,8 @@ import { KUBERNETES_MANIFEST_CONDITION } from './manifest/status/condition.compo
31
31
  import { KUBERNETES_MANIFEST_STATUS } from './manifest/status/status.component';
32
32
  import { ManifestWizard } from './manifest/wizard/ManifestWizard';
33
33
  import './pipelines/stages';
34
- import { KUBERNETES_FIND_ARTIFACTS_FROM_RESOURCE_STAGE } from './pipelines/stages/findArtifactsFromResource/findArtifactsFromResourceStage';
35
- import { KUBERNETES_SCALE_MANIFEST_STAGE } from './pipelines/stages/scaleManifest/scaleManifestStage';
36
34
  import { KUBERNETES_DISABLE_MANIFEST_STAGE } from './pipelines/stages/traffic/disableManifest.stage';
37
35
  import { KUBERNETES_ENABLE_MANIFEST_STAGE } from './pipelines/stages/traffic/enableManifest.stage';
38
- import { KUBERNETES_UNDO_ROLLOUT_MANIFEST_STAGE } from './pipelines/stages/undoRolloutManifest/undoRolloutManifestStage';
39
36
  import './pipelines/validation/manifestSelector.validator';
40
37
  import { KUBERNETS_RAW_RESOURCE_MODULE } from './rawResource';
41
38
  import { KUBERNETES_RESOURCE_STATES } from './resources/resources.state';
@@ -73,9 +70,6 @@ const requires = [
73
70
  KUBERNETES_MANIFEST_ARTIFACT,
74
71
  KUBERNETES_LOAD_BALANCER_TRANSFORMER,
75
72
  KUBERNETES_SECURITY_GROUP_TRANSFORMER,
76
- KUBERNETES_SCALE_MANIFEST_STAGE,
77
- KUBERNETES_UNDO_ROLLOUT_MANIFEST_STAGE,
78
- KUBERNETES_FIND_ARTIFACTS_FROM_RESOURCE_STAGE,
79
73
  KUBERNETES_MANIFEST_SELECTOR,
80
74
  KUBERNETES_MANIFEST_LABELS,
81
75
  KUBERNETES_MANIFEST_EVENTS,
@@ -0,0 +1,43 @@
1
+ import React, { useState } from 'react';
2
+ import { NumberInput, StageConfigField } from '@spinnaker/core';
3
+ import type { IScaleCommand } from './scale.controller';
4
+
5
+ export interface IScaleSettingsFormProps {
6
+ options: IScaleCommand;
7
+ onChange(options: IScaleCommand): void;
8
+ }
9
+
10
+ export interface IScaleSettingsFormState {
11
+ options: IScaleCommand;
12
+ }
13
+
14
+ export function ScaleSettingsForm({ options, onChange }: IScaleSettingsFormProps) {
15
+ const [state, setState] = useState<IScaleSettingsFormState>({
16
+ options: options,
17
+ });
18
+
19
+ const updateReplicas = (newReplicas: number) => {
20
+ state.options.replicas = newReplicas;
21
+ if (onChange) {
22
+ onChange(state.options);
23
+ }
24
+ setState({ options: state.options });
25
+ };
26
+
27
+ return (
28
+ <div className="form-horizontal">
29
+ <StageConfigField label="Replicas" fieldColumns={4} groupClassName="form-group form-inline">
30
+ <div className="input-group">
31
+ <NumberInput
32
+ inputClassName="input-sm highlight-pristine"
33
+ onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
34
+ updateReplicas(e.target.valueAsNumber);
35
+ }}
36
+ value={options.replicas}
37
+ min={0}
38
+ />
39
+ </div>
40
+ </StageConfigField>
41
+ </div>
42
+ );
43
+ }
@@ -1,4 +1,4 @@
1
- import type { IController } from 'angular';
1
+ import type { IController, IScope } from 'angular';
2
2
  import { copy, module } from 'angular';
3
3
  import type { IModalServiceInstance } from 'angular-ui-bootstrap';
4
4
 
@@ -7,7 +7,7 @@ import { ManifestWriter, TaskMonitor } from '@spinnaker/core';
7
7
  import type { IManifestCoordinates } from '../IManifestCoordinates';
8
8
  import { KUBERNETES_SCALE_MANIFEST_SETTINGS_FORM } from './scaleSettingsForm.component';
9
9
 
10
- interface IScaleCommand {
10
+ export interface IScaleCommand {
11
11
  manifestName: string;
12
12
  location: string;
13
13
  account: string;
@@ -17,13 +17,13 @@ interface IScaleCommand {
17
17
 
18
18
  class KubernetesManifestScaleController implements IController {
19
19
  public taskMonitor: TaskMonitor;
20
- public command: IScaleCommand;
21
20
  public verification = {
22
21
  verified: false,
23
22
  };
24
23
 
25
- public static $inject = ['coordinates', 'currentReplicas', '$uibModalInstance', 'application'];
24
+ public static $inject = ['$scope', 'coordinates', 'currentReplicas', '$uibModalInstance', 'application'];
26
25
  constructor(
26
+ private $scope: IScope,
27
27
  coordinates: IManifestCoordinates,
28
28
  currentReplicas: number,
29
29
  private $uibModalInstance: IModalServiceInstance,
@@ -35,13 +35,18 @@ class KubernetesManifestScaleController implements IController {
35
35
  modalInstance: $uibModalInstance,
36
36
  });
37
37
 
38
- this.command = {
38
+ this.$scope.command = {
39
39
  manifestName: coordinates.name,
40
40
  location: coordinates.namespace,
41
41
  account: coordinates.account,
42
42
  reason: null,
43
43
  replicas: currentReplicas,
44
44
  };
45
+
46
+ // used by react components to update command fields in parent (angular) scope
47
+ this.$scope.onChange = () => {
48
+ this.$scope.$applyAsync();
49
+ };
45
50
  }
46
51
 
47
52
  public isValid(): boolean {
@@ -54,7 +59,7 @@ class KubernetesManifestScaleController implements IController {
54
59
 
55
60
  public scale(): void {
56
61
  this.taskMonitor.submit(() => {
57
- const payload = copy(this.command) as any;
62
+ const payload = copy(this.$scope.command) as any;
58
63
  payload.cloudProvider = 'kubernetes';
59
64
 
60
65
  return ManifestWriter.scaleManifest(payload, this.application);
@@ -3,14 +3,19 @@
3
3
  <form role="form" name="scaleForm">
4
4
  <modal-close dismiss="$dismiss()"></modal-close>
5
5
  <div class="modal-header">
6
- <h4 class="modal-title">Scale {{ctrl.command.manifestName | robotToHuman}} in {{ctrl.command.location}}</h4>
6
+ <h4 class="modal-title">
7
+ Scale {{ctrl.$scope.command.manifestName | robotToHuman}} in {{ctrl.$scope.command.location}}
8
+ </h4>
7
9
  </div>
8
10
  <div class="modal-body confirmation-modal">
9
- <kubernetes-scale-manifest-settings-form settings="ctrl.command"></kubernetes-scale-manifest-settings-form>
10
- <task-reason command="ctrl.command"></task-reason>
11
+ <kubernetes-scale-manifest-settings-form
12
+ options="ctrl.$scope.command"
13
+ on-change="ctrl.$scope.onChange"
14
+ ></kubernetes-scale-manifest-settings-form>
15
+ <task-reason command="ctrl.$scope.command"></task-reason>
11
16
  </div>
12
17
  <div class="modal-footer">
13
- <user-verification account="ctrl.command.account" verification="ctrl.verification"></user-verification>
18
+ <user-verification account="ctrl.$scope.command.account" verification="ctrl.verification"></user-verification>
14
19
  <button type="submit" ng-click="ctrl.scale()" style="display: none"></button>
15
20
  <!-- Allows form submission via enter keypress-->
16
21
  <button class="btn btn-default" ng-click="ctrl.cancel()">Cancel</button>
@@ -1,29 +1,11 @@
1
- import type { IComponentOptions } from 'angular';
2
1
  import { module } from 'angular';
3
-
4
- const kubernetesScaleManifestSettingsFormComponent: IComponentOptions = {
5
- bindings: { settings: '=' },
6
- controllerAs: 'ctrl',
7
- template: `
8
- <div class="form-horizontal">
9
- <div class="form-group form-inline">
10
- <div class="col-md-3 sm-label-right">
11
- Replicas
12
- </div>
13
- <div class="col-md-4">
14
- <input type="text"
15
- class="form-control input-sm highlight-pristine"
16
- ng-model="ctrl.settings.replicas"
17
- min="0"/>
18
- </div>
19
- </div>
20
- </div>
21
- `,
22
- };
2
+ import { react2angular } from 'react2angular';
3
+ import { withErrorBoundary } from '@spinnaker/core';
4
+ import { ScaleSettingsForm } from './ScaleSettingsForm';
23
5
 
24
6
  export const KUBERNETES_SCALE_MANIFEST_SETTINGS_FORM =
25
7
  'spinnaker.kubernetes.v2.kubernetes.manifest.scale.settingsForm.component';
26
8
  module(KUBERNETES_SCALE_MANIFEST_SETTINGS_FORM, []).component(
27
9
  'kubernetesScaleManifestSettingsForm',
28
- kubernetesScaleManifestSettingsFormComponent,
10
+ react2angular(withErrorBoundary(ScaleSettingsForm, 'kubernetesScaleManifestSettingsForm'), ['options', 'onChange']),
29
11
  );
@@ -15,7 +15,7 @@ Registry.pipeline.registerStage({
15
15
  cloudProvider: 'kubernetes',
16
16
  component: DeleteManifestStageConfig,
17
17
  executionDetailsSections: [manifestExecutionDetails(STAGE_KEY), ExecutionDetailsTasks],
18
- accountExtractor: (stage: IStage): string[] => (stage.account ? [stage.account] : []),
18
+ accountExtractor: (stage: IStage): string[] => (stage.context.account ? [stage.context.account] : []),
19
19
  configAccountExtractor: (stage: any): string[] => (stage.account ? [stage.account] : []),
20
20
  validators: manifestSelectorValidators(STAGE_NAME),
21
21
  });
@@ -13,6 +13,7 @@ import {
13
13
  ArtifactTypePatterns,
14
14
  CheckboxInput,
15
15
  RadioButtonInput,
16
+ SETTINGS,
16
17
  StageArtifactSelectorDelegate,
17
18
  StageConfigField,
18
19
  yamlDocumentsToString,
@@ -25,15 +26,23 @@ import { ManifestBindArtifactsSelector } from './ManifestBindArtifactsSelector';
25
26
  import { ManifestDeploymentOptions } from './ManifestDeploymentOptions';
26
27
  import { NamespaceSelector } from './NamespaceSelector';
27
28
  import { ManifestSource } from '../../../manifest/ManifestSource';
29
+ import type { IManifestLabelSelector } from '../../../manifest/selector/IManifestLabelSelector';
30
+ import type { IManifestSelector } from '../../../manifest/selector/IManifestSelector';
31
+ import { SelectorMode } from '../../../manifest/selector/IManifestSelector';
32
+ import LabelEditor from '../../../manifest/selector/labelEditor/LabelEditor';
28
33
  import { ManifestBasicSettings } from '../../../manifest/wizard/BasicSettings';
29
34
 
30
35
  interface IDeployManifestStageConfigFormProps {
31
36
  accounts: IAccountDetails[];
37
+ selector?: IManifestSelector;
38
+ modes?: SelectorMode.Label;
32
39
  }
33
40
 
34
41
  interface IDeployManifestStageConfigFormState {
35
42
  rawManifest: string;
36
43
  overrideNamespace: boolean;
44
+ selector: IManifestSelector;
45
+ labelSelectors: IManifestLabelSelector[];
37
46
  }
38
47
 
39
48
  export class DeployManifestStageForm extends React.Component<
@@ -55,6 +64,13 @@ export class DeployManifestStageForm extends React.Component<
55
64
  this.state = {
56
65
  rawManifest: !isEmpty(manifests) && isTextManifest ? yamlDocumentsToString(manifests) : '',
57
66
  overrideNamespace: get(stage, 'namespaceOverride', '') !== '',
67
+ selector: {
68
+ account: '',
69
+ location: '',
70
+ mode: SelectorMode.Label,
71
+ labelSelectors: { selectors: [] },
72
+ },
73
+ labelSelectors: [],
58
74
  };
59
75
  }
60
76
 
@@ -186,6 +202,51 @@ export class DeployManifestStageForm extends React.Component<
186
202
  stage={stage}
187
203
  />
188
204
  </StageConfigField>
205
+ {SETTINGS.feature.deployManifestStageAdvancedConfiguration && (
206
+ <>
207
+ <hr />
208
+ <h4>Deploy Configuration</h4>
209
+ <StageConfigField label="Skip Spec Template Labels" helpKey="kubernetes.manifest.skipSpecTemplateLabels">
210
+ <CheckboxInput
211
+ checked={stage.skipSpecTemplateLabels === true}
212
+ onChange={(e: any) => this.props.formik.setFieldValue('skipSpecTemplateLabels', e.target.checked)}
213
+ />
214
+ </StageConfigField>
215
+ <StageConfigField label="Label Selectors" helpKey="kubernetes.manifest.deployLabelSelectors">
216
+ <CheckboxInput
217
+ checked={stage.labelSelectors != null}
218
+ onChange={(e: any) => {
219
+ if (e.target.checked) {
220
+ this.props.formik.setFieldValue('labelSelectors', { selectors: [] });
221
+ this.props.formik.setFieldValue('allowNothingSelected', false);
222
+ } else {
223
+ this.props.formik.setFieldValue('labelSelectors', null);
224
+ this.props.formik.setFieldValue('allowNothingSelected', null);
225
+ }
226
+ }}
227
+ />
228
+ </StageConfigField>
229
+ {stage.labelSelectors && stage.labelSelectors.selectors && (
230
+ <>
231
+ <StageConfigField label="Labels">
232
+ <LabelEditor
233
+ labelSelectors={this.props.formik.values.labelSelectors.selectors}
234
+ onLabelSelectorsChange={this.handleLabelSelectorsChange}
235
+ />
236
+ </StageConfigField>
237
+ <StageConfigField
238
+ label="Allow nothing selected"
239
+ helpKey="kubernetes.manifest.deployLabelSelectors.allowNothingSelected"
240
+ >
241
+ <CheckboxInput
242
+ checked={stage.allowNothingSelected === true}
243
+ onChange={(e: any) => this.props.formik.setFieldValue('allowNothingSelected', e.target.checked)}
244
+ />
245
+ </StageConfigField>
246
+ </>
247
+ )}
248
+ </>
249
+ )}
189
250
  <hr />
190
251
  <ManifestDeploymentOptions
191
252
  accounts={this.props.accounts}
@@ -196,4 +257,9 @@ export class DeployManifestStageForm extends React.Component<
196
257
  </div>
197
258
  );
198
259
  }
260
+
261
+ private handleLabelSelectorsChange = (labelSelectors: IManifestLabelSelector[]): void => {
262
+ this.setState({ labelSelectors });
263
+ this.props.formik.setFieldValue('labelSelectors.selectors', labelSelectors);
264
+ };
199
265
  }
@@ -21,7 +21,7 @@ Registry.pipeline.registerStage({
21
21
  producesArtifacts: true,
22
22
  supportsCustomTimeout: true,
23
23
  validators: deployManifestValidators(),
24
- accountExtractor: (stage: IStage): string[] => (stage.account ? [stage.account] : []),
24
+ accountExtractor: (stage: IStage): string[] => (stage.context.account ? [stage.context.account] : []),
25
25
  configAccountExtractor: (stage: any): string[] => (stage.account ? [stage.account] : []),
26
26
  artifactExtractor: ExpectedArtifactService.accumulateArtifacts(['manifestArtifactId', 'requiredArtifactIds']),
27
27
  artifactRemover: ArtifactReferenceService.removeArtifactFromFields(['manifestArtifactId', 'requiredArtifactIds']),
@@ -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
+ }
@@ -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
+ }
@@ -1,28 +1,21 @@
1
- import { module } from 'angular';
2
-
1
+ import type { IStage } from '@spinnaker/core';
3
2
  import { ExecutionArtifactTab, ExecutionDetailsTasks, Registry } from '@spinnaker/core';
4
3
 
5
- import { KubernetesV2FindArtifactsFromResourceConfigCtrl } from './findArtifactsFromResourceConfig.controller';
6
- import { KUBERNETES_MANIFEST_SELECTOR } from '../../../manifest/selector/selector.component';
4
+ import { FindArtifactsFromResourceConfig } from './FindArtifactsFromResourceConfig';
7
5
  import { manifestSelectorValidators } from '../validators/manifestSelectorValidators';
8
6
 
9
- export const KUBERNETES_FIND_ARTIFACTS_FROM_RESOURCE_STAGE =
10
- 'spinnaker.kubernetes.v2.pipeline.stage.findArtifactsFromResource';
11
-
12
7
  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);
8
+ const STAGE_KEY = 'findArtifactsFromResource';
9
+
10
+ Registry.pipeline.registerStage({
11
+ label: STAGE_NAME,
12
+ description: 'Finds artifacts from a Kubernetes resource.',
13
+ key: STAGE_KEY,
14
+ cloudProvider: 'kubernetes',
15
+ component: FindArtifactsFromResourceConfig,
16
+ executionDetailsSections: [ExecutionDetailsTasks, ExecutionArtifactTab],
17
+ producesArtifacts: true,
18
+ validators: manifestSelectorValidators(STAGE_NAME),
19
+ accountExtractor: (stage: IStage): string[] => (stage.context.account ? [stage.context.account] : []),
20
+ configAccountExtractor: (stage: any): string[] => (stage.account ? [stage.account] : []),
21
+ });
@@ -1,5 +1,8 @@
1
1
  export * from './deleteManifest/deleteManifestStage';
2
2
  export * from './deployManifest/deployManifestStage';
3
+ export * from './findArtifactsFromResource/findArtifactsFromResourceStage';
3
4
  export * from './patchManifest/patchManifestStage';
4
5
  export * from './rolloutRestartManifest/rolloutRestartManifestStage';
5
6
  export * from './runJob/runJobStage';
7
+ export * from './undoRolloutManifest/undoRolloutManifestStage';
8
+ export * from './scaleManifest/scaleManifestStage';
@@ -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
+ }