Skip to content

Commit

Permalink
try to get static git pages urls (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacov authored Mar 6, 2022
1 parent e8b960d commit 7aad250
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bridge/dynamic-plugin-sdk-mocks/useK8sWatchResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ const getResourceURL = (props: WatchK8sResource): string => {
return;
}

const baseURL ='/api/kubernetes/apis/' + group + '/' + version;
const namespaceURL =
namespaced ? '/namespaces/' + (namespace.toString() || 'default') : '';
const resourceKind = kind.toLowerCase() + 's';
const resourceName = name ? name.toString() : '';
const url = baseURL + namespaceURL + '/' + resourceKind + (resourceName ? '/' + resourceName : '');
const url = 'apis/' + group + '/' + version + namespaceURL + '/' + resourceKind + (resourceName ? '/' + resourceName : '');

return url;
};
Expand All @@ -26,7 +25,10 @@ export const useK8sWatchResource = <R extends K8sResourceCommon | K8sResourceCom
const [data, setData] = React.useState<R>();

React.useEffect(() => {
const url = getResourceURL(props);
const baseURL = window.location.hostname.includes('kubevirt-ui.github.io') ?
'/kubevirt-components/api/kubernetes/' :
'/api/kubernetes/';
const url = baseURL + getResourceURL(props);

fetch(url)
.then(response => response.json())
Expand Down

0 comments on commit 7aad250

Please sign in to comment.