Skip to content

Commit

Permalink
fix(kubernetes): safer lookups for deploy stage validators (#6847)
Browse files Browse the repository at this point in the history
  • Loading branch information
maggieneterval committed Apr 12, 2019
1 parent 478e326 commit 37e24d7
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isEmpty } from 'lodash';
import { get, isEmpty } from 'lodash';

import { IPipeline, IStage, IValidatorConfig, ICustomValidator } from '@spinnaker/core';

Expand All @@ -7,8 +7,9 @@ export const deployManifestValidators = (): IValidatorConfig[] => {
{
type: 'custom',
validate: (_pipeline: IPipeline, stage: IStage) => {
const { enabled = false, options = {} } = stage.trafficManagement;
if (enabled && isEmpty(options.services)) {
const enabled = get(stage, 'trafficManagement.enabled', false);
const services = get(stage, 'trafficManagement.options.services', []);
if (enabled && isEmpty(services)) {
return `Select at least one <strong>Service</strong> to enable Spinnaker-managed rollout strategy options.`;
}
return null;
Expand Down

0 comments on commit 37e24d7

Please sign in to comment.