-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(git/repo): add git/repo artifact support in kustomize bake manif…
…est (#7572) * feat(git/repo): add git/repo artifact support in kustomize bake manifest * Update app/scripts/modules/core/src/pipeline/config/stages/bakeManifest/kustomize/BakeKustomizeConfigForm.tsx Co-Authored-By: Maggie Neterval <mneterval@google.com> * Update app/scripts/modules/core/src/pipeline/config/stages/bakeManifest/kustomize/BakeKustomizeConfigForm.tsx Co-Authored-By: Maggie Neterval <mneterval@google.com> * Update app/scripts/modules/core/src/pipeline/config/triggers/artifacts/gitrepo/GitRepoArtifactEditor.tsx Co-Authored-By: Maggie Neterval <mneterval@google.com>
- Loading branch information
1 parent
98d4c9a
commit f882544
Showing
7 changed files
with
155 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app/scripts/modules/core/src/artifact/icons/git-repo-artifact.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
...pts/modules/core/src/pipeline/config/triggers/artifacts/gitrepo/GitRepoArtifactEditor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import { cloneDeep, get } from 'lodash'; | ||
import * as React from 'react'; | ||
|
||
import { ArtifactTypePatterns } from 'core/artifact'; | ||
import { IArtifactEditorProps, IArtifactKindConfig } from 'core/domain'; | ||
import { StageConfigField } from 'core/pipeline'; | ||
import { SpelText } from 'core/widgets'; | ||
import { CheckboxInput } from 'core/presentation'; | ||
|
||
const TYPE = 'git/repo'; | ||
|
||
interface IGitRepoArtifactEditorState { | ||
includesSubPath: boolean; | ||
} | ||
|
||
class GitRepoArtifactEditor extends React.Component<IArtifactEditorProps, IGitRepoArtifactEditorState> { | ||
public constructor(props: IArtifactEditorProps) { | ||
super(props); | ||
const { artifact } = this.props; | ||
this.state = { | ||
includesSubPath: get(artifact, 'metadata.subPath', '') !== '', | ||
}; | ||
} | ||
|
||
private onIncludesSubPathChange = (event: any) => { | ||
this.setState({ includesSubPath: event.target.checked }); | ||
}; | ||
|
||
private onReferenceChanged = (reference: string) => { | ||
const clonedArtifact = cloneDeep(this.props.artifact); | ||
clonedArtifact.reference = reference; | ||
this.props.onChange(clonedArtifact); | ||
}; | ||
|
||
private onVersionChanged = (version: string) => { | ||
const clonedArtifact = cloneDeep(this.props.artifact); | ||
clonedArtifact.version = version; | ||
this.props.onChange(clonedArtifact); | ||
}; | ||
|
||
private onSubPathChanged = (subPath: string) => { | ||
const clonedArtifact = cloneDeep(this.props.artifact); | ||
const metadata = get(clonedArtifact, 'metadata', {}) as any; | ||
metadata.subPath = subPath; | ||
clonedArtifact.metadata = metadata; | ||
this.props.onChange(clonedArtifact); | ||
}; | ||
|
||
public render() { | ||
const { artifact } = this.props; | ||
|
||
return ( | ||
<> | ||
<StageConfigField label="URL" helpKey="pipeline.config.expectedArtifact.gitrepo.url"> | ||
<SpelText | ||
placeholder="https or ssh to your git repo" | ||
value={artifact.reference} | ||
onChange={this.onReferenceChanged} | ||
pipeline={this.props.pipeline} | ||
docLink={true} | ||
/> | ||
</StageConfigField> | ||
<StageConfigField label="Branch" helpKey="pipeline.config.expectedArtifact.gitrepo.branch"> | ||
<SpelText | ||
placeholder="master" | ||
value={artifact.version} | ||
onChange={this.onVersionChanged} | ||
pipeline={this.props.pipeline} | ||
docLink={true} | ||
/> | ||
</StageConfigField> | ||
<StageConfigField label="Checkout subpath" helpKey="pipeline.config.expectedArtifact.gitrepo.checkoutSubpath"> | ||
<CheckboxInput checked={this.state.includesSubPath} onChange={this.onIncludesSubPathChange} /> | ||
</StageConfigField> | ||
{this.state.includesSubPath && ( | ||
<StageConfigField label="Subpath" helpKey="pipeline.config.expectedArtifact.gitrepo.subpath"> | ||
<SpelText | ||
placeholder="path/to/subdirectory" | ||
value={get(artifact, 'metadata.subPath', '')} | ||
onChange={this.onSubPathChanged} | ||
pipeline={this.props.pipeline} | ||
docLink={true} | ||
/> | ||
</StageConfigField> | ||
)} | ||
</> | ||
); | ||
} | ||
} | ||
|
||
export const GitRepoMatch: IArtifactKindConfig = { | ||
label: 'GitRepo', | ||
description: 'A Git repository.', | ||
key: 'gitrepo', | ||
typePattern: ArtifactTypePatterns.GIT_REPO, | ||
type: TYPE, | ||
isDefault: false, | ||
isMatch: true, | ||
editCmp: GitRepoArtifactEditor, | ||
}; | ||
|
||
export const GitRepoDefault: IArtifactKindConfig = { | ||
label: 'GitRepo', | ||
typePattern: ArtifactTypePatterns.GIT_REPO, | ||
type: TYPE, | ||
description: 'A Git repository.', | ||
key: 'default.gitrepo', | ||
isDefault: true, | ||
isMatch: false, | ||
editCmp: GitRepoArtifactEditor, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters