import React from 'react'; import { CollapsibleSection, ShowUserData } from '@spinnaker/core'; import type { IAmazonServerGroupDetailsSectionProps } from './IAmazonServerGroupDetailsSectionProps'; import type { IAmazonServerGroupView } from '../../../domain'; import { getBaseImageName } from '../utils'; export interface ILaunchConfigDetailsSectionState { image: any; } export class LaunchConfigDetailsSection extends React.Component< IAmazonServerGroupDetailsSectionProps, ILaunchConfigDetailsSectionState > { constructor(props: IAmazonServerGroupDetailsSectionProps) { super(props); this.state = { image: this.getImage(props.serverGroup) }; } private getImage(serverGroup: IAmazonServerGroupView): any { const image = serverGroup.image ? serverGroup.image : undefined; if (serverGroup.image && serverGroup.image.description) { image.baseImage = getBaseImageName(serverGroup.image.description); } return image; } public componentWillReceiveProps(nextProps: IAmazonServerGroupDetailsSectionProps): void { this.setState({ image: this.getImage(nextProps.serverGroup) }); } public render(): JSX.Element { const { name, launchConfig } = this.props.serverGroup; const { image } = this.state; if (launchConfig) { return (
Name
{launchConfig.launchConfigurationName}
Image ID
{launchConfig.imageId}
{image && image.imageLocation &&
Image Name
} {image && image.imageLocation &&
{image.imageLocation}
} {image && image.baseImage &&
Base Image Name
} {image && image.baseImage &&
{image.baseImage}
}
Instance Type
{launchConfig.instanceType}
IAM Profile
{launchConfig.iamInstanceProfile}
{launchConfig.instanceMonitoring && ( <>
Instance Monitoring
{launchConfig.instanceMonitoring.enabled ? 'enabled' : 'disabled'}
)} {launchConfig.spotPrice &&
Spot Price
} {launchConfig.spotPrice &&
{launchConfig.spotPrice}
} {launchConfig.keyName &&
Key Name
} {launchConfig.keyName &&
{launchConfig.keyName}
} {launchConfig.kernelId &&
Kernel ID
} {launchConfig.kernelId &&
{launchConfig.kernelId}
} {launchConfig.ramdiskId &&
Ramdisk ID
} {launchConfig.ramdiskId &&
{launchConfig.ramdiskId}
}
User Data
{launchConfig.userData && (
)} {!launchConfig.userData &&
[none]
}
); } return null; } }