forked from spinnaker/deck
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(artifacts): Combine expected artifacts and trigger artifact …
…constraints (spinnaker#6634) To enable new artifact functional set `feature.artifactsRewrite = true` in Deck. Co-Authored-By: Scott Bloch-Wehba-Seaward <sbws@google.com>
- Loading branch information
1 parent
2224c5e
commit 5da2965
Showing
77 changed files
with
2,458 additions
and
812 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
12 changes: 5 additions & 7 deletions
12
app/scripts/modules/core/src/artifact/expectedArtifact.service.ts
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
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
57 changes: 57 additions & 0 deletions
57
app/scripts/modules/core/src/artifact/react/ArtifactEditor.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,57 @@ | ||
import * as React from 'react'; | ||
import { cloneDeep } from 'lodash'; | ||
import { IArtifactAccount } from 'core/account'; | ||
import { ArtifactAccountSelector } from 'core/artifact'; | ||
import { IArtifact, IPipeline } from 'core/domain'; | ||
import { StageConfigField } from 'core/pipeline/config/stages/common'; | ||
import { Registry } from 'core/registry'; | ||
import { UUIDGenerator } from 'core/utils'; | ||
|
||
export interface IArtifactEditorProps { | ||
pipeline: IPipeline; | ||
artifact: IArtifact; | ||
artifactAccounts: IArtifactAccount[]; | ||
onArtifactEdit: (artifact: IArtifact) => void; | ||
isDefault: boolean; | ||
} | ||
|
||
/** | ||
* Editor for either the match or default side of an expected artifact. Also | ||
* used in stages where an inline default artifact may be defined. | ||
*/ | ||
export class ArtifactEditor extends React.Component<IArtifactEditorProps> { | ||
private onArtifactAccountChanged = (artifactAccount: IArtifactAccount) => { | ||
// reset artifact fields if the account type has changed, so we don't leave dangling properties | ||
// that are not modifiable using the new artifact account type's form. | ||
const artifact: IArtifact = | ||
this.props.artifact && artifactAccount.types.includes(this.props.artifact.type) | ||
? cloneDeep(this.props.artifact) | ||
: { id: UUIDGenerator.generateUuid() }; | ||
artifact.artifactAccount = artifactAccount.name; | ||
this.props.onArtifactEdit(artifact); | ||
}; | ||
|
||
public render(): React.ReactNode { | ||
const { pipeline, artifact, artifactAccounts, onArtifactEdit, isDefault } = this.props; | ||
const artifactAccount = artifactAccounts.find(acc => acc.name === artifact.artifactAccount) || artifactAccounts[0]; | ||
const accountTypes = artifactAccount ? artifactAccount.types : undefined; | ||
const kinds = isDefault ? Registry.pipeline.getDefaultArtifactKinds() : Registry.pipeline.getMatchArtifactKinds(); | ||
const kind = accountTypes ? kinds.find(a => accountTypes.some(typ => a.typePattern.test(typ))) : undefined; | ||
const EditCmp = kind && kind.editCmp; | ||
|
||
return ( | ||
<> | ||
<StageConfigField label="Account" fieldColumns={8}> | ||
<ArtifactAccountSelector | ||
accounts={artifactAccounts} | ||
selected={artifactAccount} | ||
onChange={this.onArtifactAccountChanged} | ||
/> | ||
</StageConfigField> | ||
{EditCmp && ( | ||
<EditCmp account={artifactAccount} artifact={artifact} onChange={onArtifactEdit} pipeline={pipeline} /> | ||
)} | ||
</> | ||
); | ||
} | ||
} |
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
Oops, something went wrong.