- {loadBalancerService.metadata.name} |
- {loadBalancerService.spec.type} |
-
- {this.URLs().map(l => (
-
- {isLink ? (
-
- {l}
-
- ) : (
- l
- )}
-
- ))}
- |
-
- );
- }
-
- // isLink returns true if there are any link in the Item
- private isLink(): boolean {
- if (
- this.props.loadBalancerService.status.loadBalancer.ingress &&
- this.props.loadBalancerService.status.loadBalancer.ingress.length
- ) {
- return true;
- }
- return false;
- }
-
- // URLs returns the list of URLs obtained from the service status
- private URLs(): string[] {
- const URLs: string[] = [];
- const { loadBalancerService } = this.props;
- const status: IServiceStatus = loadBalancerService.status;
- if (status.loadBalancer.ingress && status.loadBalancer.ingress.length) {
- status.loadBalancer.ingress.forEach(i => {
- (loadBalancerService.spec as IServiceSpec).ports.forEach(port => {
- if (i.hostname) {
- URLs.push(this.getURL(i.hostname, port.port));
- }
- if (i.ip) {
- URLs.push(this.getURL(i.ip, port.port));
- }
- });
- });
- } else {
- URLs.push("Pending");
- }
- return URLs;
- }
-
- // getURL returns a full URL adding the protocol and the port if needed
- private getURL(base: string, port: number) {
- const protocol = port === 443 ? "https" : "http";
- // Only show the port in the URL if it's not a standard HTTP/HTTPS port
- const portSuffix = port === 443 || port === 80 ? "" : `:${port}`;
- return `${protocol}://${base}${portSuffix}`;
- }
-}
+const AccessURLItem: React.SFC