Skip to content

Commit

Permalink
fix(kubernetes): fix patchBody input in Patch (Manifest) stage (#7600) (
Browse files Browse the repository at this point in the history
  • Loading branch information
spinnakerbot authored and Travis Tomsu committed Nov 11, 2019
1 parent 5d89a04 commit 579afd5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ export class PatchManifestStageConfig extends React.Component<IStageConfigProps>
});
delete props.stage.options.strategy;

// There was a bug introduced in Spinnaker 1.15 where we were incorrectly
// always storing the patchBody as an object. In order to auto-fix pipelines
// affected by that bug, massage any configured patchBody value into a list.
if (props.stage.patchBody && !Array.isArray(props.stage.patchBody)) {
props.stage.patchBody = [props.stage.patchBody];
}

// Intentionally initializing the stage config only once in the constructor
// The stage config is then completely owned within FormikStageConfig's Formik state
this.stage = props.stage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ export class PatchManifestStageForm extends React.Component<

public constructor(props: IPatchManifestStageConfigFormProps & IFormikStageConfigInjectedProps) {
super(props);
const patchBody: string = get(props.formik.values, 'patchBody');
const patchBody: any[] = get(props.formik.values, 'patchBody');
const isTextManifest: boolean = get(props.formik.values, 'source') === this.textSource;
this.state = {
rawManifest: !isEmpty(patchBody) && isTextManifest ? yamlDocumentsToString([patchBody]) : '',
rawManifest: !isEmpty(patchBody) && isTextManifest ? yamlDocumentsToString(patchBody) : '',
};
}

Expand Down Expand Up @@ -86,7 +86,7 @@ export class PatchManifestStageForm extends React.Component<
this.setState({
rawManifest,
});
this.props.formik.setFieldValue('patchBody', manifests[0]);
this.props.formik.setFieldValue('patchBody', manifests);
};

private onManifestSelectorChange = (): void => {
Expand Down

0 comments on commit 579afd5

Please sign in to comment.