-
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(provider/aws):Function listing and searching functionality
This change adds a new tab for functions and facilitates listing existing functions and searching functions listed. Corresponding provider specific changes are included in this change for AWS. Authors: @sidmuls and @nabebe
- Loading branch information
Showing
25 changed files
with
1,005 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { IFunction } from '@spinnaker/core'; | ||
|
||
export interface IAmazonFunction extends IFunction { | ||
credentials?: string; | ||
role?: string; | ||
runtime: string; | ||
s3bucket: string; | ||
s3key: string; | ||
handler: string; | ||
functionName: string; | ||
publish: boolean; | ||
description: string; | ||
tags: [{}]; | ||
memorySize: number; | ||
timeout: number; | ||
envVariables: {}; | ||
tracingConfig: { | ||
mode: string; | ||
}; | ||
deadLetterConfig: { | ||
targetArn: string; | ||
}; | ||
KMSKeyArn: string; | ||
vpcConfig: { | ||
securityGroupIds: []; | ||
subnetIds: []; | ||
vpcId: string; | ||
}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { module } from 'angular'; | ||
|
||
export const AWS_FUNCTION_MODULE = 'spinnaker.amazon.function'; | ||
|
||
module(AWS_FUNCTION_MODULE, []); |
7 changes: 7 additions & 0 deletions
7
app/scripts/modules/amazon/src/function/function.transformer.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { IAmazonFunction } from 'amazon/domain'; | ||
|
||
export class AwsFunctionTransformer { | ||
public normalizeFunction(functionDef: IAmazonFunction): IAmazonFunction { | ||
return functionDef; | ||
} | ||
} |
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 @@ | ||
export * from './function.transformer'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { ITaggedEntity } from './ITaggedEntity'; | ||
|
||
export interface IFunctionSourceData { | ||
cloudProvider?: string; | ||
name?: string; | ||
provider?: string; | ||
type?: string; | ||
} | ||
|
||
export interface IFunction extends ITaggedEntity { | ||
account?: string; | ||
cloudProvider?: string; | ||
description?: string; | ||
name?: string; | ||
functionName?: string; | ||
provider?: string; | ||
region?: string; | ||
searchField?: string; | ||
type?: string; | ||
vpcId?: string; | ||
vpcName?: string; | ||
} | ||
|
||
export interface IFunctionGroup { | ||
heading: string; | ||
functionDef?: IFunction; | ||
subgroups?: IFunctionGroup[]; | ||
searchField?: string; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import * as React from 'react'; | ||
import { UISref, UISrefActive } from '@uirouter/react'; | ||
|
||
import { Application } from 'core/application/application.model'; | ||
import { IFunction } from 'core/domain'; | ||
|
||
import { EntityNotifications } from 'core/entityTag/notifications/EntityNotifications'; | ||
|
||
export interface IFunctionProps { | ||
application: Application; | ||
functionDef: IFunction; | ||
} | ||
|
||
export class Function extends React.Component<IFunctionProps> { | ||
public static defaultProps: Partial<IFunctionProps> = {}; | ||
|
||
public render(): React.ReactElement<Function> { | ||
const { application, functionDef } = this.props; | ||
const params = { | ||
application: application.name, | ||
region: functionDef.region, | ||
account: functionDef.account, | ||
name: functionDef.functionName, | ||
provider: functionDef.cloudProvider, | ||
}; | ||
return ( | ||
<div className="pod-subgroup function"> | ||
<div className="function-header sticky-header-2"> | ||
<UISrefActive class="active"> | ||
<UISref to=".functionDetails" params={params}> | ||
<h6 className="clickable clickable-row horizontal middle"> | ||
<i className="fa icon-sitemap" /> | ||
{(functionDef.region || '').toUpperCase()} | ||
<div className="flex-1"> | ||
<EntityNotifications | ||
entity={functionDef} | ||
application={application} | ||
placement="bottom" | ||
entityType="function" | ||
pageLocation="pod" | ||
onUpdate={() => application.functions.refresh()} | ||
/> | ||
</div> | ||
</h6> | ||
</UISref> | ||
</UISrefActive> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} |
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,11 @@ | ||
import * as React from 'react'; | ||
import { Overridable, IOverridableProps } from 'core/overrideRegistry'; | ||
|
||
export interface IFunctionDetailsProps extends IOverridableProps {} | ||
|
||
@Overridable('function.details') | ||
export class FunctionDetails extends React.Component<IFunctionDetailsProps> { | ||
public render() { | ||
return <h3>Function Details</h3>; | ||
} | ||
} |
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,39 @@ | ||
import * as React from 'react'; | ||
|
||
import { AccountTag } from 'core/account'; | ||
import { Application } from 'core/application/application.model'; | ||
import { IFunctionGroup } from 'core/domain'; | ||
import { Function } from './Function'; | ||
|
||
import './functionPod.less'; | ||
|
||
export interface IFunctionPodProps { | ||
grouping: IFunctionGroup; | ||
application: Application; | ||
parentHeading: string; | ||
} | ||
|
||
export class FunctionPod extends React.Component<IFunctionPodProps> { | ||
public render(): React.ReactElement<FunctionPod> { | ||
const { grouping, application, parentHeading } = this.props; | ||
const subgroups = grouping.subgroups.map(subgroup => ( | ||
<Function key={subgroup.functionDef.functionName} application={application} functionDef={subgroup.functionDef} /> | ||
)); | ||
|
||
return ( | ||
<div className="load-balancer-pod row rollup-entry sub-group"> | ||
<div className="rollup-summary sticky-header"> | ||
<div className="rollup-title-cell"> | ||
<div className="heading-tag"> | ||
<AccountTag account={parentHeading} /> | ||
</div> | ||
<div className="pod-center horizontal space-between center flex-1"> | ||
<div>{grouping.heading}</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="rollup-details">{subgroups}</div> | ||
</div> | ||
); | ||
} | ||
} |
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,119 @@ | ||
import * as React from 'react'; | ||
import { Debounce } from 'lodash-decorators'; | ||
import { Subscription } from 'rxjs'; | ||
import { Application } from 'core/application/application.model'; | ||
import { FilterTags, IFilterTag } from 'core/filterModel/FilterTags'; | ||
import { IFunctionGroup } from 'core/domain'; | ||
import { FunctionState } from 'core/state'; | ||
import { FunctionPod } from './FunctionPod'; | ||
import { Spinner } from 'core/widgets/spinners/Spinner'; | ||
|
||
export interface IFunctionsProps { | ||
app: Application; | ||
} | ||
|
||
export interface IFunctionsState { | ||
initialized: boolean; | ||
groups: IFunctionGroup[]; | ||
tags: IFilterTag[]; | ||
} | ||
|
||
export class Functions extends React.Component<IFunctionsProps, IFunctionsState> { | ||
private groupsUpdatedListener: Subscription; | ||
private functionsRefreshUnsubscribe: () => any; | ||
|
||
constructor(props: IFunctionsProps) { | ||
super(props); | ||
this.state = { | ||
initialized: false, | ||
groups: [], | ||
tags: [], | ||
}; | ||
} | ||
|
||
public componentDidMount(): void { | ||
const { app } = this.props; | ||
|
||
this.groupsUpdatedListener = FunctionState.filterService.groupsUpdatedStream.subscribe(() => this.groupsUpdated()); | ||
FunctionState.filterModel.asFilterModel.activate(); | ||
this.functionsRefreshUnsubscribe = app | ||
.getDataSource('functions') | ||
.onRefresh(null, () => this.updateFunctionGroups()); | ||
app.setActiveState(app.loadBalancers); | ||
this.updateFunctionGroups(); | ||
} | ||
|
||
public componentWillUnmount(): void { | ||
this.groupsUpdatedListener.unsubscribe(); | ||
this.functionsRefreshUnsubscribe(); | ||
} | ||
|
||
private groupsUpdated(): void { | ||
this.setState({ | ||
groups: FunctionState.filterModel.asFilterModel.groups, | ||
tags: FunctionState.filterModel.asFilterModel.tags, | ||
}); | ||
} | ||
|
||
@Debounce(200) | ||
private updateFunctionGroups(): void { | ||
FunctionState.filterModel.asFilterModel.applyParamsToUrl(); | ||
FunctionState.filterService.updateFunctionGroups(this.props.app); | ||
this.groupsUpdated(); | ||
|
||
if (this.props.app.getDataSource('functions').loaded) { | ||
this.setState({ initialized: true }); | ||
} | ||
} | ||
|
||
private clearFilters = (): void => { | ||
FunctionState.filterService.clearFilters(); | ||
this.updateFunctionGroups(); | ||
}; | ||
|
||
private tagCleared = (): void => { | ||
this.updateFunctionGroups(); | ||
}; | ||
|
||
public render(): React.ReactElement<Functions> { | ||
const groupings = this.state.initialized ? ( | ||
<div> | ||
{this.state.groups.map(group => ( | ||
<div key={group.heading} className="rollup"> | ||
{group.subgroups && | ||
group.subgroups.map(subgroup => ( | ||
<FunctionPod | ||
key={subgroup.heading} | ||
grouping={subgroup} | ||
application={this.props.app} | ||
parentHeading={group.heading} | ||
/> | ||
))} | ||
</div> | ||
))} | ||
{this.state.groups.length === 0 && ( | ||
<div> | ||
<h4 className="text-center">No functions match the filters you've selected.</h4> | ||
</div> | ||
)} | ||
</div> | ||
) : ( | ||
<div> | ||
<Spinner size="medium" /> | ||
</div> | ||
); | ||
|
||
return ( | ||
<div className="main-content functions"> | ||
<div className="header row header-clusters"> | ||
<div className="col-lg-4 col-md-2"> | ||
<div className="form-inline clearfix filters" /> | ||
</div> | ||
<FilterTags tags={this.state.tags} tagCleared={this.tagCleared} clearFilters={this.clearFilters} /> | ||
</div> | ||
|
||
<div className="content">{groupings}</div> | ||
</div> | ||
); | ||
} | ||
} |
Oops, something went wrong.