Skip to content

Commit

Permalink
fix(kubernetes): fix validation for Find Artifact from Resource stage (
Browse files Browse the repository at this point in the history
  • Loading branch information
spinnakerbot authored and maggieneterval committed Mar 29, 2019
1 parent 434fb84 commit fa36400
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { module } from 'angular';
import { Registry, SETTINGS, IStage, ExecutionDetailsTasks } from '@spinnaker/core';

import { manifestExecutionDetails } from 'kubernetes/v2/pipelines/stages/ManifestExecutionDetails';
import { trafficValidators } from 'kubernetes/v2/pipelines/stages/traffic/validators';
import { manifestSelectorValidators } from '../validators/manifestSelectorValidators';
import { DeleteManifestStageConfig } from 'kubernetes/v2/pipelines/stages/deleteManifest/DeleteManifestStageConfig';

export const KUBERNETES_DELETE_MANIFEST_STAGE = 'spinnaker.kubernetes.v2.pipeline.stage.deleteManifestStage';
Expand All @@ -22,7 +22,7 @@ module(KUBERNETES_DELETE_MANIFEST_STAGE, []).config(() => {
executionDetailsSections: [manifestExecutionDetails(STAGE_KEY), ExecutionDetailsTasks],
accountExtractor: (stage: IStage): string => (stage.account ? stage.account : []),
configAccountExtractor: (stage: any): string[] => (stage.account ? [stage.account] : []),
validators: trafficValidators(STAGE_NAME),
validators: manifestSelectorValidators(STAGE_NAME),
});
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import { Registry, SETTINGS, ExecutionDetailsTasks, ExecutionArtifactTab } from

import { KubernetesV2FindArtifactsFromResourceConfigCtrl } from './findArtifactsFromResourceConfig.controller';
import { KUBERNETES_MANIFEST_SELECTOR } from '../../../manifest/selector/selector.component';
import { manifestSelectorValidators } from '../validators/manifestSelectorValidators';

export const KUBERNETES_FIND_ARTIFACTS_FROM_RESOURCE_STAGE =
'spinnaker.kubernetes.v2.pipeline.stage.findArtifactsFromResource';

const STAGE_NAME = 'Find Artifacts From Resource (Manifest)';
module(KUBERNETES_FIND_ARTIFACTS_FROM_RESOURCE_STAGE, [KUBERNETES_MANIFEST_SELECTOR])
.config(() => {
// Todo: replace feature flag with proper versioned provider mechanism once available.
if (SETTINGS.feature.artifacts) {
Registry.pipeline.registerStage({
label: 'Find Artifacts From Resource (Manifest)',
label: STAGE_NAME,
description: 'Finds artifacts from a Kubernetes resource.',
key: 'findArtifactsFromResource',
cloudProvider: 'kubernetes',
Expand All @@ -22,11 +24,7 @@ module(KUBERNETES_FIND_ARTIFACTS_FROM_RESOURCE_STAGE, [KUBERNETES_MANIFEST_SELEC
controllerAs: 'ctrl',
executionDetailsSections: [ExecutionDetailsTasks, ExecutionArtifactTab],
producesArtifacts: true,
validators: [
{ type: 'requiredField', fieldName: 'location', fieldLabel: 'Namespace' },
{ type: 'requiredField', fieldName: 'account', fieldLabel: 'Account' },
{ type: 'manifestSelector' },
],
validators: manifestSelectorValidators(STAGE_NAME),
});
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@ import {
Registry,
SETTINGS,
} from '@spinnaker/core';

import { KubernetesV2PatchManifestConfigCtrl } from '../patchManifest/patchManifestConfig.controller';
import { KUBERNETES_PATCH_MANIFEST_OPTIONS_FORM } from './patchOptionsForm.component';
import { KUBERNETES_MANIFEST_SELECTOR } from 'kubernetes/v2/manifest/selector/selector.component';
import { DeployStatus } from '../deployManifest/react/DeployStatus';
import { trafficValidators } from '../traffic/validators';
import { manifestSelectorValidators } from '../validators/manifestSelectorValidators';

export const KUBERNETES_PATCH_MANIFEST_STAGE = 'spinnaker.kubernetes.v2.pipeline.stage.patchManifestStage';

export class PatchStatus extends DeployStatus {
public static title = 'PatchStatus';
}

const STAGE_NAME = 'Patch (Manifest)';
module(KUBERNETES_PATCH_MANIFEST_STAGE, [KUBERNETES_PATCH_MANIFEST_OPTIONS_FORM, KUBERNETES_MANIFEST_SELECTOR])
.config(() => {
if (SETTINGS.feature.versionedProviders) {
Registry.pipeline.registerStage({
label: 'Patch (Manifest)',
label: STAGE_NAME,
description: 'Patch a Kubernetes object in place.',
key: 'patchManifest',
cloudProvider: 'kubernetes',
Expand All @@ -34,7 +36,7 @@ module(KUBERNETES_PATCH_MANIFEST_STAGE, [KUBERNETES_PATCH_MANIFEST_OPTIONS_FORM,
executionDetailsSections: [PatchStatus, ExecutionDetailsTasks, ExecutionArtifactTab],
producesArtifacts: true,
defaultTimeoutMs: 30 * 60 * 1000, // 30 minutes
validators: trafficValidators(KUBERNETES_PATCH_MANIFEST_STAGE),
validators: manifestSelectorValidators(STAGE_NAME),
artifactExtractor: ExpectedArtifactService.accumulateArtifacts(['manifestArtifactId', 'requiredArtifactIds']),
artifactRemover: ArtifactReferenceService.removeArtifactFromFields([
'manifestArtifactId',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { module } from 'angular';

import { EXECUTION_ARTIFACT_TAB, ExecutionDetailsTasks, IStage, Registry } from '@spinnaker/core';
import { ManifestTrafficStageConfig } from './ManifestTrafficStageConfig';
import { trafficValidators } from 'kubernetes/v2/pipelines/stages/traffic/validators';
import { manifestSelectorValidators } from '../validators/manifestSelectorValidators';
import { manifestExecutionDetails } from 'kubernetes/v2/pipelines/stages/ManifestExecutionDetails';

const STAGE_NAME = 'Disable (Manifest)';
Expand All @@ -19,6 +19,6 @@ module(KUBERNETES_DISABLE_MANIFEST_STAGE, [EXECUTION_ARTIFACT_TAB]).config(() =>
defaultTimeoutMs: 30 * 60 * 1000, // 30 minutes
accountExtractor: (stage: IStage): string => (stage.account ? stage.account : ''),
configAccountExtractor: (stage: IStage): string[] => (stage.account ? [stage.account] : []),
validators: trafficValidators(STAGE_NAME),
validators: manifestSelectorValidators(STAGE_NAME),
});
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { module } from 'angular';

import { EXECUTION_ARTIFACT_TAB, ExecutionDetailsTasks, IStage, Registry } from '@spinnaker/core';

import { ManifestTrafficStageConfig } from './ManifestTrafficStageConfig';
import { trafficValidators } from 'kubernetes/v2/pipelines/stages/traffic/validators';
import { manifestSelectorValidators } from '../validators/manifestSelectorValidators';
import { manifestExecutionDetails } from 'kubernetes/v2/pipelines/stages/ManifestExecutionDetails';

const STAGE_NAME = 'Enable (Manifest)';
Expand All @@ -19,6 +20,6 @@ module(KUBERNETES_ENABLE_MANIFEST_STAGE, [EXECUTION_ARTIFACT_TAB]).config(() =>
defaultTimeoutMs: 30 * 60 * 1000, // 30 minutes
accountExtractor: (stage: IStage): string => (stage.account ? stage.account : ''),
configAccountExtractor: (stage: IStage): string[] => (stage.account ? [stage.account] : []),
validators: trafficValidators(STAGE_NAME),
validators: manifestSelectorValidators(STAGE_NAME),
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { IPipeline, IStage, IValidatorConfig, ICustomValidator } from '@spinnaker/core';

import { IManifestSelector, SelectorMode } from 'kubernetes/v2/manifest/selector/IManifestSelector';

export const trafficValidators = (stageName: string): IValidatorConfig[] => {
export const manifestSelectorValidators = (stageName: string): IValidatorConfig[] => {
const required = (field: string) => `<strong>${field}</strong> is a required field for ${stageName} stages.`;

return [
Expand Down

0 comments on commit fa36400

Please sign in to comment.