Skip to content
This repository has been archived by the owner on Feb 9, 2022. It is now read-only.

Commit

Permalink
add url for shared urls
Browse files Browse the repository at this point in the history
  • Loading branch information
Adnan Abdulhussein committed Jan 18, 2018
1 parent a1b1c2d commit a803244
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/actions/charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Dispatch } from 'redux';
import { createAction, getReturnOfExpression } from 'typesafe-actions';

import { StoreState, Chart } from '../store/types';
import * as url from '../shared/url';

export const requestCharts = createAction('REQUEST_CHARTS');
export const receiveCharts = createAction('RECEIVE_CHARTS', (charts: Chart[]) => ({
Expand All @@ -19,11 +20,7 @@ export type ChartsAction = typeof allActions[number];
export function fetchCharts(repo: string) {
return (dispatch: Dispatch<StoreState>): Promise<{}> => {
dispatch(requestCharts());
let url = '/api/chartsvc/v1/charts';
if (repo) {
url = `${url}/${repo}`;
}
return fetch(url)
return fetch(url.api.charts.list(repo))
.then(response => response.json())
.then(json => dispatch(receiveCharts(json.data)));
};
Expand All @@ -32,15 +29,15 @@ export function fetchCharts(repo: string) {
export function getChart(id: string) {
return (dispatch: Dispatch<StoreState>): Promise<{}> => {
dispatch(requestCharts());
return fetch(`/api/chartsvc/v1/charts/${id}`)
return fetch(url.api.charts.get(id))
.then(response => response.json())
.then(json => dispatch(selectChart(json.data)));
};
}

export function deployChart(chart: Chart, releaseName: string, namespace: string) {
return (dispatch: Dispatch<StoreState>): Promise<{}> => {
return fetch(`/api/kube/apis/helm.bitnami.com/v1/namespaces/${namespace}/helmreleases`, {
return fetch(url.api.helmreleases.create(namespace), {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
Expand Down
10 changes: 10 additions & 0 deletions src/shared/url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const api = {
charts: {
list: (repo?: string) => `/api/chartsvc/v1/charts${repo ? `/${repo}` : ''}`,
get: (id: string) => `/api/chartsvc/v1/charts/${id}`
},

helmreleases: {
create: (namespace = 'default') => `/api/kube/apis/helm.bitnami.com/v1/namespaces/${namespace}/helmreleases`,
},
};

0 comments on commit a803244

Please sign in to comment.