Skip to content

Commit

Permalink
Delete port number from ingress information (#3915)
Browse files Browse the repository at this point in the history
  • Loading branch information
gusevda authored Nov 30, 2022
1 parent d30aef4 commit ef106c8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/components/MAPI/apps/__tests__/ClusterDetailIngress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ describe('ClusterDetailIngress on Azure', () => {
}

expect(screen.getByLabelText('Base domain:')).toHaveTextContent(
'.j5y9m.k8s.test.gigantic.io:443'
'.j5y9m.k8s.test.gigantic.io'
);
expect(screen.getByLabelText('Load balancer DNS name:')).toHaveTextContent(
'ingress.j5y9m.k8s.test.gigantic.io:443'
'ingress.j5y9m.k8s.test.gigantic.io'
);
expect(screen.getByLabelText('Hostname pattern:')).toHaveTextContent(
'YOUR_PREFIX.j5y9m.k8s.test.gigantic.io:443'
'YOUR_PREFIX.j5y9m.k8s.test.gigantic.io'
);
});
});
Expand Down
26 changes: 20 additions & 6 deletions src/components/MAPI/apps/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import * as releasesUtils from 'MAPI/releases/utils';
import {
getClusterBaseUrl,
getClusterDescription,
getClusterK8sAPIUrl,
getClusterReleaseVersion,
getNamespaceFromOrgName,
isCAPACluster,
} from 'MAPI/utils';
import { GenericResponse } from 'model/clients/GenericResponse';
import { IHttpClient } from 'model/clients/HttpClient';
Expand All @@ -25,7 +23,10 @@ import {
} from 'model/services/mapi/applicationv1alpha1';
import * as authorizationv1 from 'model/services/mapi/authorizationv1';
import * as capiv1beta1 from 'model/services/mapi/capiv1beta1';
import * as capzv1beta1 from 'model/services/mapi/capzv1beta1';
import * as corev1 from 'model/services/mapi/corev1';
import * as infrav1alpha2 from 'model/services/mapi/infrastructurev1alpha2';
import * as infrav1alpha3 from 'model/services/mapi/infrastructurev1alpha3';
import * as metav1 from 'model/services/mapi/metav1';
import * as releasev1alpha1 from 'model/services/mapi/releasev1alpha1';
import { Cache, mutate } from 'swr';
Expand Down Expand Up @@ -723,13 +724,26 @@ export function getClusterK8sEndpoint(
cluster: capiv1beta1.ICluster,
provider: PropertiesOf<typeof Providers>
) {
if (isCAPACluster(cluster)) {
const hostname = getClusterBaseUrl(cluster, provider).host;
const infrastructureRef = cluster.spec?.infrastructureRef;
if (!infrastructureRef) {
return '';
}

return `https://${hostname}`;
const { kind, apiVersion } = infrastructureRef;
let hostname = null;
switch (true) {
case kind === capzv1beta1.AzureCluster:
case kind === infrav1alpha2.AWSCluster &&
apiVersion === infrav1alpha2.ApiVersion:
case kind === infrav1alpha3.AWSCluster &&
apiVersion === infrav1alpha3.ApiVersion:
hostname = cluster.spec?.controlPlaneEndpoint?.host;
break;
default:
hostname = getClusterBaseUrl(cluster, provider).host;
}

return getClusterK8sAPIUrl(cluster, provider);
return hostname ? `https://${hostname}` : '';
}

export function isTestRelease(releaseVersion: string): boolean {
Expand Down

0 comments on commit ef106c8

Please sign in to comment.