-
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/kubernetes): link to resources next to YAML in deploy p…
…ipeline (#4945)
- Loading branch information
Scott Bloch-Wehba-Seaward
committed
Mar 2, 2018
1 parent
60c3e20
commit 4c3cbb5
Showing
6 changed files
with
91 additions
and
5 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
80 changes: 80 additions & 0 deletions
80
app/scripts/modules/kubernetes/src/v2/manifest/showManifestDetails.component.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,80 @@ | ||
import { module, IComponentOptions, IController } from 'angular'; | ||
import { trim } from 'lodash'; | ||
import { ReactInjector } from 'core/reactShims'; | ||
|
||
const supportedKinds = ['deployment', 'replicaset']; | ||
|
||
class KubernetesShowManifestDetails implements IController { | ||
public manifest: any; | ||
public accountId: string; | ||
|
||
public canOpen(): boolean { | ||
return !!( | ||
this.manifest && | ||
this.manifest.kind && | ||
this.manifest.metadata && | ||
this.manifest.metadata.annotations && | ||
supportedKinds.includes(this.manifest.kind.toLowerCase()) | ||
); | ||
} | ||
|
||
public openDetails() { | ||
const kind = this.manifest.kind.toLowerCase(); | ||
if (kind === 'deployment') { | ||
this.openDeploymentDetails(); | ||
} else if (kind === 'replicaset') { | ||
this.openReplicaSetDetails(); | ||
} | ||
} | ||
|
||
private buildParams(annotations: any): any { | ||
return { | ||
accountId: this.accountId, | ||
provider: 'kubernetes', | ||
application: annotations.application, | ||
region: annotations.region, | ||
}; | ||
} | ||
|
||
private openDeploymentDetails() { | ||
const { $state } = ReactInjector; | ||
const annotations = this.extractAnnotations(this.manifest.metadata.annotations); | ||
const params = this.buildParams(annotations); | ||
params.serverGroupManager = `deployment ${annotations.name}`; | ||
$state.go('home.applications.application.insight.clusters.serverGroupManager', params); | ||
} | ||
|
||
private openReplicaSetDetails() { | ||
const { $state } = ReactInjector; | ||
const annotations = this.extractAnnotations(this.manifest.metadata.annotations); | ||
const params = this.buildParams(annotations); | ||
params.serverGroup = `replicaSet ${annotations.name}-${annotations.version}`; | ||
$state.go('home.applications.application.insight.clusters.serverGroup', params); | ||
} | ||
|
||
private stripQuotes(str: string): string { | ||
return trim(str, '"'); | ||
} | ||
|
||
private extractAnnotations(annotations?: any): any { | ||
return { | ||
application: this.stripQuotes(annotations['moniker.spinnaker.io/application']), | ||
region: this.stripQuotes(annotations['artifact.spinnaker.io/location']), | ||
name: this.stripQuotes(annotations['artifact.spinnaker.io/name']), | ||
version: this.stripQuotes(annotations['artifact.spinnaker.io/version']), | ||
}; | ||
} | ||
} | ||
|
||
class KubernetesShowManifestDetailsComponent implements IComponentOptions { | ||
public bindings: any = { manifest: '<', linkName: '<', accountId: '<' }; | ||
public controller: any = KubernetesShowManifestDetails; | ||
public controllerAs = 'ctrl'; | ||
public template = trim(` | ||
<a href ng-if='ctrl.canOpen()' ng-click='ctrl.openDetails()'>{{ctrl.linkName}}</a> | ||
`); | ||
} | ||
|
||
export const KUBERNETES_SHOW_MANIFEST_DETAILS = 'spinnaker.kubernetes.v2.manifest.showDetails'; | ||
module(KUBERNETES_SHOW_MANIFEST_DETAILS, []) | ||
.component('kubernetesShowManifestDetails', new KubernetesShowManifestDetailsComponent()); |
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
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