Skip to content

Commit

Permalink
App.upgrade sends app repo name (#1151)
Browse files Browse the repository at this point in the history
* Upgrade passes app repo name. Upgrade and Create don't send repo URL

* Remove required RBAC for deployment form (get app repo no longer required)

* Fix test typo
  • Loading branch information
absoludity authored Sep 5, 2019
1 parent 272c971 commit 4b8fdea
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 20 deletions.
14 changes: 1 addition & 13 deletions dashboard/src/components/DeploymentForm/DeploymentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as Moniker from "moniker-native";
import * as React from "react";
import AceEditor from "react-ace";

import { IChartState, IChartVersion, IRBACRole } from "../../shared/types";
import { IChartState, IChartVersion } from "../../shared/types";
import { ErrorSelector } from "../ErrorAlert";
import LoadingWrapper from "../LoadingWrapper";

Expand Down Expand Up @@ -110,7 +110,6 @@ class DeploymentForm extends React.Component<IDeploymentFormProps, IDeploymentFo
<ErrorSelector
error={this.props.error}
namespace={namespace}
defaultRequiredRBACRoles={{ create: this.requiredRBACRoles() }}
action="create"
resource={latestSubmittedReleaseName}
/>
Expand Down Expand Up @@ -202,17 +201,6 @@ class DeploymentForm extends React.Component<IDeploymentFormProps, IDeploymentFo
public handleValuesChange = (value: string) => {
this.setState({ appValues: value, valuesModified: true });
};

private requiredRBACRoles(): IRBACRole[] {
return [
{
apiGroup: "kubeapps.com",
namespace: this.props.kubeappsNamespace,
resource: "apprepositories",
verbs: ["get"],
},
];
}
}

export default DeploymentForm;
34 changes: 33 additions & 1 deletion dashboard/src/shared/App.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,45 @@ describe("App", () => {
appRepositoryResourceName: testChartVersion.relationships.chart.data.repo.name,
chartName: testChartVersion.relationships.chart.data.name,
releaseName: "absent-ant",
repoUrl: testChartVersion.relationships.chart.data.repo.url,
version: testChartVersion.attributes.version,
}),
);
});
});

describe("upgrade", () => {
const expectedURL = `${TILLER_PROXY_ROOT_URL}/namespaces/default/releases/absent-ant`;
const testChartVersion: IChartVersion = {
attributes: {
version: "1.2.3",
},
relationships: {
chart: {
data: {
name: "test",
repo: {
name: "testrepo",
url: "http://example.com/charts",
},
},
},
},
} as IChartVersion;
it("upgrades an app in a namespace", async () => {
moxios.stubRequest(/.*/, { response: "ok", status: 200 });
expect(await App.upgrade("absent-ant", "default", "kubeapps", testChartVersion)).toBe("ok");
const request = moxios.requests.mostRecent();
expect(request.url).toBe(expectedURL);
expect(request.config.data).toEqual(
JSON.stringify({
appRepositoryResourceName: testChartVersion.relationships.chart.data.repo.name,
chartName: testChartVersion.relationships.chart.data.name,
releaseName: "absent-ant",
version: testChartVersion.attributes.version,
}),
);
});
});
describe("delete", () => {
[
{
Expand Down
7 changes: 1 addition & 6 deletions dashboard/src/shared/App.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AppRepository } from "./AppRepository";
import { axiosWithAuth } from "./AxiosInstance";
import { hapi } from "./hapi/release";
import { IAppOverview, IChartVersion } from "./types";
Expand Down Expand Up @@ -34,7 +33,6 @@ export class App {
appRepositoryResourceName: chartAttrs.repo.name,
chartName: chartAttrs.name,
releaseName,
repoUrl: chartAttrs.repo.url,
values,
version: chartVersion.attributes.version,
});
Expand All @@ -49,14 +47,11 @@ export class App {
values?: string,
) {
const chartAttrs = chartVersion.relationships.chart.data;
const repo = await AppRepository.get(chartAttrs.repo.name, kubeappsNamespace);
const auth = repo.spec.auth;
const endpoint = App.getResourceURL(namespace, releaseName);
const { data } = await axiosWithAuth.put(endpoint, {
auth,
appRepositoryResourceName: chartAttrs.repo.name,
chartName: chartAttrs.name,
releaseName,
repoUrl: chartAttrs.repo.url,
values,
version: chartVersion.attributes.version,
});
Expand Down

0 comments on commit 4b8fdea

Please sign in to comment.