Skip to content

Commit

Permalink
feat(bake): add UI element for helmChartFilePath to bake manifest sta…
Browse files Browse the repository at this point in the history
…ge, when using a git/repo artifact for the helm chart (#8774)

Co-authored-by: David Byron <david.byron@avast.com>
Co-authored-by: Daniel Peach <daniel.peach@armory.io>
  • Loading branch information
3 people committed Dec 9, 2020
1 parent 5b41d4a commit a53e32c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/scripts/modules/core/src/help/help.contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ const helpContents: { [key: string]: string } = {
'pipeline.config.bake.manifest.overrideExpressionEvaluation':
'<p>Explicitly evaluate SpEL expressions in overrides just prior to manifest baking. Can be paired with the "Skip SpEL evaluation" option in the Deploy Manifest stage when baking a third-party manifest artifact with expressions not meant for Spinnaker to evaluate as SpEL.</p>',
'pipeline.config.bake.manifest.templateRenderer': '<p>This is the engine used for rendering your manifest.</p>',
'pipeline.config.bake.manifest.helm.chartFilePath': `
<p>This is the relative path to the Chart.yaml file within your Git repo.</p>
<p>e.g.: <b>helm/my-chart/Chart.yaml</b></p>`,
'pipeline.config.bake.manifest.helm.rawOverrides':
'Use <i>--set</i> instead of <i>--set-string</i> when injecting override values. Values injected using <i>--set</i> will be converted to primitive types by Helm.',
'pipeline.config.bake.manifest.kustomize.filePath': `
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import React from 'react';

import { AccountService, IArtifactAccount } from 'core/account';
import { StageConfigField } from '../../common/stageConfigField/StageConfigField';
import { CheckboxInput, TextInput } from 'core/presentation';
import { MapEditor } from 'core/forms';
import { IArtifact, IExpectedArtifact } from 'core/domain';
import { excludeAllTypesExcept, ArtifactTypePatterns, StageArtifactSelectorDelegate } from 'core/artifact';
import { IFormikStageConfigInjectedProps } from '../../FormikStageConfig';

export class BakeHelmConfigForm extends React.Component<IFormikStageConfigInjectedProps> {
export interface IBakeHelmConfigFormState {
gitRepoArtifactAccounts: IArtifactAccount[];
}

export class BakeHelmConfigForm extends React.Component<IFormikStageConfigInjectedProps, IBakeHelmConfigFormState> {
constructor(props: IFormikStageConfigInjectedProps) {
super(props);
this.state = { gitRepoArtifactAccounts: [] };
}

private static readonly excludedArtifactTypes = excludeAllTypesExcept(
ArtifactTypePatterns.BITBUCKET_FILE,
ArtifactTypePatterns.CUSTOM_OBJECT,
Expand All @@ -31,6 +41,13 @@ export class BakeHelmConfigForm extends React.Component<IFormikStageConfigInject
},
]);
}
AccountService.getArtifactAccounts().then((artifactAccounts) => {
this.setState({
gitRepoArtifactAccounts: artifactAccounts.filter((account) =>
account.types.some((type) => ArtifactTypePatterns.GIT_REPO.test(type)),
),
});
});
}

private onTemplateArtifactEdited = (artifact: IArtifact, index: number) => {
Expand Down Expand Up @@ -137,6 +154,16 @@ export class BakeHelmConfigForm extends React.Component<IFormikStageConfigInject
pipeline={this.props.pipeline}
stage={stage}
/>
{this.state.gitRepoArtifactAccounts.includes(this.getInputArtifact(stage, 0).account) && (
<StageConfigField label="File" helpKey="pipeline.config.bake.manifest.helm.chartFilePath">
<TextInput
onChange={(e: React.ChangeEvent<any>) => {
this.props.formik.setFieldValue('helmChartFilePath', e.target.value);
}}
value={stage.helmChartFilePath}
/>
</StageConfigField>
)}
<h4>Overrides</h4>
{stage.inputArtifacts && stage.inputArtifacts.length > 1 && (
<div className="row form-group">
Expand Down

0 comments on commit a53e32c

Please sign in to comment.