@@ -140,8 +139,8 @@ export default function ApplicationStatus({
const packageStatus = codeToString(info.status);
if (
![
- InstalledPackageStatus_StatusReason.STATUS_REASON_INSTALLED,
- InstalledPackageStatus_StatusReason.STATUS_REASON_PENDING,
+ InstalledPackageStatus_StatusReason.INSTALLED,
+ InstalledPackageStatus_StatusReason.PENDING,
].includes(info?.status?.reason)
) {
return (
diff --git a/dashboard/src/components/Catalog/AvailablePackageDetailExcerpt.tsx b/dashboard/src/components/Catalog/AvailablePackageDetailExcerpt.tsx
index e30fc896096..404c50d60ef 100644
--- a/dashboard/src/components/Catalog/AvailablePackageDetailExcerpt.tsx
+++ b/dashboard/src/components/Catalog/AvailablePackageDetailExcerpt.tsx
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import AvailablePackageMaintainers from "components/PackageHeader/AvailablePackageMaintainers";
-import { AvailablePackageDetail } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import { AvailablePackageDetail } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
interface AvailablePackageDetailExcerptProps {
pkg?: AvailablePackageDetail;
diff --git a/dashboard/src/components/Catalog/Catalog.test.tsx b/dashboard/src/components/Catalog/Catalog.test.tsx
index 83ccec7d9af..0bae3c544e8 100644
--- a/dashboard/src/components/Catalog/Catalog.test.tsx
+++ b/dashboard/src/components/Catalog/Catalog.test.tsx
@@ -7,12 +7,17 @@ import FilterGroup from "components/FilterGroup/FilterGroup";
import InfoCard from "components/InfoCard/InfoCard";
import Alert from "components/js/Alert";
import LoadingWrapper from "components/LoadingWrapper";
-import { AvailablePackageSummary, Context } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import {
+ AvailablePackageReference,
+ AvailablePackageSummary,
+ Context,
+ PackageAppVersion,
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import {
PackageRepositoryDetail,
PackageRepositorySummary,
-} from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+} from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import { createMemoryHistory } from "history";
import React from "react";
import { act } from "react-dom/test-utils";
@@ -48,41 +53,41 @@ const defaultProps = {
namespace: "kubeapps",
kubeappsNamespace: "kubeapps",
};
-const availablePkgSummary1: AvailablePackageSummary = {
+const availablePkgSummary1 = new AvailablePackageSummary({
name: "foo",
categories: [""],
displayName: "foo",
iconUrl: "",
- latestVersion: { appVersion: "v1.0.0", pkgVersion: "" },
+ latestVersion: new PackageAppVersion({ appVersion: "v1.0.0", pkgVersion: "" }),
shortDescription: "",
- availablePackageRef: {
+ availablePackageRef: new AvailablePackageReference({
identifier: "foo/foo",
context: { cluster: "", namespace: "package-namespace" } as Context,
plugin: { name: "my.plugin", version: "0.0.1" } as Plugin,
- },
-};
-const availablePkgSummary2: AvailablePackageSummary = {
+ }),
+});
+const availablePkgSummary2 = new AvailablePackageSummary({
name: "bar",
categories: ["Database"],
displayName: "bar",
iconUrl: "",
- latestVersion: { appVersion: "v2.0.0", pkgVersion: "" },
+ latestVersion: new PackageAppVersion({ appVersion: "v2.0.0", pkgVersion: "" }),
shortDescription: "",
- availablePackageRef: {
+ availablePackageRef: new AvailablePackageReference({
identifier: "bar/bar",
context: { cluster: "", namespace: "package-namespace" } as Context,
plugin: { name: "my.plugin", version: "0.0.1" } as Plugin,
- },
-};
+ }),
+});
-const availablePkgSummary3: AvailablePackageSummary = {
+const availablePkgSummary3 = new AvailablePackageSummary({
...availablePkgSummary2,
- availablePackageRef: {
+ availablePackageRef: new AvailablePackageReference({
identifier: "bar/bar2",
context: { cluster: "", namespace: "package-namespace" } as Context,
plugin: { name: PluginNames.PACKAGES_KAPP, version: "0.0.1" } as Plugin,
- },
-};
+ }),
+});
const csv = {
metadata: {
diff --git a/dashboard/src/components/Catalog/CatalogItem.tsx b/dashboard/src/components/Catalog/CatalogItem.tsx
index 90224083040..8a3f58182ac 100644
--- a/dashboard/src/components/Catalog/CatalogItem.tsx
+++ b/dashboard/src/components/Catalog/CatalogItem.tsx
@@ -1,7 +1,7 @@
// Copyright 2018-2022 the Kubeapps contributors.
// SPDX-License-Identifier: Apache-2.0
-import { AvailablePackageSummary } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import { AvailablePackageSummary } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import OperatorCatalogItem from "./OperatorCatalogItem";
import PackageCatalogItem from "./PackageCatalogItem";
diff --git a/dashboard/src/components/Catalog/CatalogItems.test.tsx b/dashboard/src/components/Catalog/CatalogItems.test.tsx
index b8bd0cad20f..b141edfef03 100644
--- a/dashboard/src/components/Catalog/CatalogItems.test.tsx
+++ b/dashboard/src/components/Catalog/CatalogItems.test.tsx
@@ -2,39 +2,44 @@
// SPDX-License-Identifier: Apache-2.0
import InfoCard from "components/InfoCard";
-import { AvailablePackageSummary, Context } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+import {
+ AvailablePackageReference,
+ AvailablePackageSummary,
+ Context,
+ PackageAppVersion,
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import { defaultStore, mountWrapper } from "shared/specs/mountWrapper";
import { IClusterServiceVersion, PluginNames } from "shared/types";
import CatalogItem from "./CatalogItem";
import CatalogItems, { ICatalogItemsProps } from "./CatalogItems";
-const availablePackageSummary1: AvailablePackageSummary = {
+const availablePackageSummary1 = new AvailablePackageSummary({
name: "foo",
categories: [],
displayName: "foo",
iconUrl: "",
- latestVersion: { appVersion: "v1.0.0", pkgVersion: "" },
+ latestVersion: new PackageAppVersion({ appVersion: "v1.0.0", pkgVersion: "" }),
shortDescription: "",
- availablePackageRef: {
+ availablePackageRef: new AvailablePackageReference({
identifier: "foo/foo",
context: { cluster: "", namespace: "package-namespace" } as Context,
plugin: { name: "my.plugin", version: "0.0.1" } as Plugin,
- },
-};
-const availablePackageSummary2: AvailablePackageSummary = {
+ }),
+});
+const availablePackageSummary2 = new AvailablePackageSummary({
name: "bar",
categories: ["Database"],
displayName: "bar",
iconUrl: "",
- latestVersion: { appVersion: "v2.0.0", pkgVersion: "" },
+ latestVersion: new PackageAppVersion({ appVersion: "v2.0.0", pkgVersion: "" }),
shortDescription: "",
- availablePackageRef: {
+ availablePackageRef: new AvailablePackageReference({
identifier: "bar/bar",
context: { cluster: "", namespace: "package-namespace" } as Context,
plugin: { name: "my.plugin", version: "0.0.1" } as Plugin,
- },
-};
+ }),
+});
const csv = {
metadata: {
name: "test-csv",
diff --git a/dashboard/src/components/Catalog/CatalogItems.tsx b/dashboard/src/components/Catalog/CatalogItems.tsx
index 712ff21704b..84793de1ddc 100644
--- a/dashboard/src/components/Catalog/CatalogItems.tsx
+++ b/dashboard/src/components/Catalog/CatalogItems.tsx
@@ -1,7 +1,7 @@
// Copyright 2020-2022 the Kubeapps contributors.
// SPDX-License-Identifier: Apache-2.0
-import { AvailablePackageSummary } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import { AvailablePackageSummary } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import { useMemo } from "react";
import { getIcon } from "shared/Operators";
import { IClusterServiceVersion } from "shared/types";
diff --git a/dashboard/src/components/Config/PkgRepoList/PkgRepoButton.test.tsx b/dashboard/src/components/Config/PkgRepoList/PkgRepoButton.test.tsx
index c599915d7c1..d207a4ca976 100644
--- a/dashboard/src/components/Config/PkgRepoList/PkgRepoButton.test.tsx
+++ b/dashboard/src/components/Config/PkgRepoList/PkgRepoButton.test.tsx
@@ -5,7 +5,7 @@ import { CdsButton } from "@cds/react/button";
import { CdsIcon } from "@cds/react/icon";
import { CdsModal } from "@cds/react/modal";
import actions from "actions";
-import { PackageRepositoryReference } from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
+import { PackageRepositoryReference } from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
import { act } from "react-dom/test-utils";
import * as ReactRedux from "react-redux";
import { defaultStore, mountWrapper } from "shared/specs/mountWrapper";
diff --git a/dashboard/src/components/Config/PkgRepoList/PkgRepoButton.tsx b/dashboard/src/components/Config/PkgRepoList/PkgRepoButton.tsx
index a905dbabc33..ee86c29eddc 100644
--- a/dashboard/src/components/Config/PkgRepoList/PkgRepoButton.tsx
+++ b/dashboard/src/components/Config/PkgRepoList/PkgRepoButton.tsx
@@ -5,7 +5,7 @@ import { CdsButton } from "@cds/react/button";
import { CdsIcon } from "@cds/react/icon";
import { CdsModal, CdsModalContent, CdsModalHeader } from "@cds/react/modal";
import actions from "actions";
-import { PackageRepositoryReference } from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
+import { PackageRepositoryReference } from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
import { useState } from "react";
import { useDispatch } from "react-redux";
import { Action } from "redux";
diff --git a/dashboard/src/components/Config/PkgRepoList/PkgRepoControl.test.tsx b/dashboard/src/components/Config/PkgRepoList/PkgRepoControl.test.tsx
index d3efff2f681..3707b473b2d 100644
--- a/dashboard/src/components/Config/PkgRepoList/PkgRepoControl.test.tsx
+++ b/dashboard/src/components/Config/PkgRepoList/PkgRepoControl.test.tsx
@@ -4,7 +4,7 @@
import { CdsButton } from "@cds/react/button";
import actions from "actions";
import ConfirmDialog from "components/ConfirmDialog/ConfirmDialog";
-import { PackageRepositorySummary } from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
+import { PackageRepositorySummary } from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
import { act } from "react-dom/test-utils";
import * as ReactRedux from "react-redux";
import { defaultStore, mountWrapper } from "shared/specs/mountWrapper";
diff --git a/dashboard/src/components/Config/PkgRepoList/PkgRepoControl.tsx b/dashboard/src/components/Config/PkgRepoList/PkgRepoControl.tsx
index 53659bc6582..0f4a6cc88e1 100644
--- a/dashboard/src/components/Config/PkgRepoList/PkgRepoControl.tsx
+++ b/dashboard/src/components/Config/PkgRepoList/PkgRepoControl.tsx
@@ -5,7 +5,7 @@ import { CdsButton } from "@cds/react/button";
import {
PackageRepositoryReference,
PackageRepositorySummary,
-} from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
+} from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
import { useState } from "react";
import { useDispatch } from "react-redux";
import { Action } from "redux";
diff --git a/dashboard/src/components/Config/PkgRepoList/PkgRepoForm.test.tsx b/dashboard/src/components/Config/PkgRepoList/PkgRepoForm.test.tsx
index c6e7a58f852..c48a557e78f 100644
--- a/dashboard/src/components/Config/PkgRepoList/PkgRepoForm.test.tsx
+++ b/dashboard/src/components/Config/PkgRepoList/PkgRepoForm.test.tsx
@@ -1,19 +1,30 @@
// Copyright 2020-2022 the Kubeapps contributors.
// SPDX-License-Identifier: Apache-2.0
+import { Any } from "@bufbuild/protobuf";
+// import { Any } from "gen/google/protobuf/any";
import { CdsButton } from "@cds/react/button";
import { waitFor } from "@testing-library/react";
import actions from "actions";
import Alert from "components/js/Alert";
import {
+ DockerCredentials,
+ OpaqueCredentials,
PackageRepositoryAuth_PackageRepositoryAuthType,
PackageRepositoryDetail,
PackageRepositoryReference,
PackageRepositorySummary,
-} from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
-import { FluxPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/fluxv2/packages/v1alpha1/fluxv2";
-import { HelmPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm";
+ PackageRepositoryTlsConfig,
+ SshCredentials,
+ TlsCertKey,
+ UsernamePassword,
+} from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
+import { FluxPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/fluxv2/packages/v1alpha1/fluxv2_pb";
+import {
+ HelmPackageRepositoryCustomDetail,
+ RepositoryFilterRule,
+} from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm_pb";
import { act } from "react-dom/test-utils";
import * as ReactRedux from "react-redux";
import { IPackageRepositoryState } from "reducers/repos";
@@ -27,7 +38,10 @@ const defaultProps = {
kubeappsNamespace: "kubeapps",
helmGlobalNamespace: "kubeapps",
carvelGlobalNamespace: "carvel-global",
- packageRepoRef: { identifier: "test", context: { cluster: "default", namespace: "default" } },
+ packageRepoRef: new PackageRepositoryReference({
+ identifier: "test",
+ context: { cluster: "default", namespace: "default" },
+ }),
} as IPkgRepoFormProps;
const defaultState = {
@@ -42,30 +56,27 @@ const defaultState = {
const pkgRepoFormData = {
plugin: { name: PluginNames.PACKAGES_HELM, version: "v1alpha1" } as Plugin,
authHeader: "",
- authMethod:
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED,
+ authMethod: PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED,
isUserManaged: false,
- basicAuth: {
+ basicAuth: new UsernamePassword({
password: "",
username: "",
- },
+ }),
customCA: "",
customDetail: {
- imagesPullSecret: {
- secretRef: "",
- credentials: undefined,
- },
ociRepositories: [],
performValidation: true,
filterRules: undefined,
+ nodeSelector: {},
+ tolerations: [],
},
description: "",
- dockerRegCreds: {
+ dockerRegCreds: new DockerCredentials({
password: "",
username: "",
email: "",
server: "",
- },
+ }),
interval: "10m",
name: "",
passCredentials: false,
@@ -74,17 +85,17 @@ const pkgRepoFormData = {
skipTLS: false,
type: RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_HELM,
url: "",
- opaqueCreds: {
+ opaqueCreds: new OpaqueCredentials({
data: {},
- },
- sshCreds: {
+ }),
+ sshCreds: new SshCredentials({
knownHosts: "",
privateKey: "",
- },
- tlsCertKey: {
+ }),
+ tlsCertKey: new TlsCertKey({
cert: "",
key: "",
- },
+ }),
namespace: "default",
isNamespaceScoped: true,
} as IPkgRepoFormData;
@@ -278,12 +289,10 @@ it("should call the install method with OCI information", async () => {
plugin: { name: PluginNames.PACKAGES_HELM, version: "v1alpha1" },
customDetail: {
ociRepositories: ["apache", "jenkins"],
- imagesPullSecret: {
- secretRef: "",
- credentials: undefined,
- },
filterRule: undefined,
performValidation: true,
+ nodeSelector: {},
+ tolerations: [],
},
interval: "10m",
description: undefined,
@@ -317,12 +326,10 @@ it("should call the install skipping TLS verification", async () => {
plugin: { name: PluginNames.PACKAGES_HELM, version: "v1alpha1" },
customDetail: {
ociRepositories: [],
- imagesPullSecret: {
- secretRef: "",
- credentials: undefined,
- },
filterRule: undefined,
performValidation: true,
+ nodeSelector: {},
+ tolerations: [],
},
skipTLS: true,
interval: "10m",
@@ -357,12 +364,10 @@ it("should call the install passing credentials", async () => {
plugin: { name: PluginNames.PACKAGES_HELM, version: "v1alpha1" },
customDetail: {
ociRepositories: [],
- imagesPullSecret: {
- secretRef: "",
- credentials: undefined,
- },
filterRule: undefined,
performValidation: true,
+ nodeSelector: {},
+ tolerations: [],
},
passCredentials: true,
interval: "10m",
@@ -427,15 +432,13 @@ describe("when using a filter", () => {
plugin: { name: PluginNames.PACKAGES_HELM, version: "v1alpha1" },
customDetail: {
ociRepositories: [],
- imagesPullSecret: {
- secretRef: "",
- credentials: undefined,
- },
filterRule: {
jq: ".name == $var0 or .name == $var1",
variables: { $var0: "nginx", $var1: "wordpress" },
},
performValidation: true,
+ nodeSelector: {},
+ tolerations: [],
},
interval: "10m",
description: undefined,
@@ -471,15 +474,13 @@ describe("when using a filter", () => {
plugin: { name: PluginNames.PACKAGES_HELM, version: "v1alpha1" },
customDetail: {
ociRepositories: [],
- imagesPullSecret: {
- secretRef: "",
- credentials: undefined,
- },
+ nodeSelector: {},
filterRule: {
jq: ".name | test($var) | not",
variables: { $var: "nginx" },
},
performValidation: true,
+ tolerations: [],
},
interval: "10m",
description: undefined,
@@ -519,12 +520,9 @@ describe("when using a filter", () => {
plugin: { name: PluginNames.PACKAGES_HELM, version: "v1alpha1" },
customDetail: {
ociRepositories: ["apache", "jenkins"],
- imagesPullSecret: {
- secretRef: "",
- credentials: undefined,
- },
- filterRule: undefined,
+ nodeSelector: {},
performValidation: true,
+ tolerations: [],
},
interval: "10m",
description: undefined,
@@ -556,12 +554,10 @@ it("should call the install method with a description", async () => {
url: "https://helm.repo",
customDetail: {
ociRepositories: [],
- imagesPullSecret: {
- secretRef: "",
- credentials: undefined,
- },
+ nodeSelector: {},
filterRule: undefined,
performValidation: true,
+ tolerations: [],
},
interval: "10m",
description: "description test",
@@ -642,16 +638,18 @@ describe("when the repository info is already populated", () => {
});
it("should parse the existing filter (simple)", async () => {
- const testRepo = {
+ const testRepo = new PackageRepositoryDetail({
...repo,
type: "helm",
- customDetail: {
- filterRule: {
- jq: ".name == $var0 or .name == $var1",
- variables: { $var0: "nginx", $var1: "wordpress" },
- },
- } as Partial
,
- } as PackageRepositoryDetail;
+ customDetail: new Any({
+ value: new HelmPackageRepositoryCustomDetail({
+ filterRule: {
+ jq: ".name == $var0 or .name == $var1",
+ variables: { $var0: "nginx", $var1: "wordpress" },
+ },
+ }).toBinary(),
+ }),
+ });
let wrapper: any;
await act(async () => {
@@ -674,13 +672,18 @@ describe("when the repository info is already populated", () => {
});
it("should parse the existing filter (negated regex)", async () => {
- const testRepo = {
+ const testRepo = new PackageRepositoryDetail({
...repo,
type: "helm",
- customDetail: {
- filterRule: { jq: ".name | test($var) | not", variables: { $var: "nginx" } },
- } as Partial,
- } as PackageRepositoryDetail;
+ customDetail: new Any({
+ value: new HelmPackageRepositoryCustomDetail({
+ filterRule: new RepositoryFilterRule({
+ jq: ".name | test($var) | not",
+ variables: { $var: "nginx" },
+ }),
+ }).toBinary(),
+ }),
+ });
let wrapper: any;
await act(async () => {
@@ -763,10 +766,15 @@ describe("when the repository info is already populated", () => {
describe("when there is a kubeapps-handled secret associated to the repo", () => {
it("should parse the existing CA cert", async () => {
- const testRepo = {
+ const testRepo = new PackageRepositoryDetail({
...repo,
- tlsConfig: { certAuthority: "fooCA" },
- } as PackageRepositoryDetail;
+ tlsConfig: new PackageRepositoryTlsConfig({
+ packageRepoTlsConfigOneOf: {
+ case: "certAuthority",
+ value: "fooCA",
+ },
+ }),
+ });
let wrapper: any;
await act(async () => {
wrapper = mountWrapper(
@@ -782,13 +790,16 @@ describe("when the repository info is already populated", () => {
});
it("should parse the existing auth header", async () => {
- const testRepo = {
+ const testRepo = new PackageRepositoryDetail({
...repo,
auth: {
- type: PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_AUTHORIZATION_HEADER,
- header: "fooHeader",
+ type: PackageRepositoryAuth_PackageRepositoryAuthType.AUTHORIZATION_HEADER,
+ packageRepoAuthOneOf: {
+ case: "header",
+ value: "fooHeader",
+ },
},
- } as PackageRepositoryDetail;
+ });
let wrapper: any;
await act(async () => {
wrapper = mountWrapper(
@@ -807,13 +818,19 @@ describe("when the repository info is already populated", () => {
});
it("should parse the existing basic auth", async () => {
- const testRepo = {
+ const testRepo = new PackageRepositoryDetail({
...repo,
auth: {
- type: PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- usernamePassword: { username: "foo", password: "bar" },
+ type: PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ packageRepoAuthOneOf: {
+ case: "usernamePassword",
+ value: new UsernamePassword({
+ username: "foo",
+ password: "bar",
+ }),
+ },
},
- } as PackageRepositoryDetail;
+ });
let wrapper: any;
await act(async () => {
wrapper = mountWrapper(
@@ -833,13 +850,16 @@ describe("when the repository info is already populated", () => {
});
it("should parse a bearer token", async () => {
- const testRepo = {
+ const testRepo = new PackageRepositoryDetail({
...repo,
auth: {
- type: PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BEARER,
- header: "Bearer fooToken",
+ type: PackageRepositoryAuth_PackageRepositoryAuthType.BEARER,
+ packageRepoAuthOneOf: {
+ case: "header",
+ value: "Bearer fooToken",
+ },
},
- } as PackageRepositoryDetail;
+ });
let wrapper: any;
await act(async () => {
wrapper = mountWrapper(
@@ -858,18 +878,21 @@ describe("when the repository info is already populated", () => {
});
it("should select a docker secret as auth mechanism", async () => {
- const testRepo = {
+ const testRepo = new PackageRepositoryDetail({
...repo,
auth: {
- type: PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON,
- dockerCreds: {
- email: "foo@foo.foo",
- password: "bar",
- server: "foobar",
- username: "foo",
+ type: PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON,
+ packageRepoAuthOneOf: {
+ case: "dockerCreds",
+ value: new DockerCredentials({
+ email: "foo@foo.foo",
+ password: "bar",
+ server: "foobar",
+ username: "foo",
+ }),
},
},
- } as PackageRepositoryDetail;
+ });
let wrapper: any;
await act(async () => {
wrapper = mountWrapper(
@@ -891,15 +914,18 @@ describe("when the repository info is already populated", () => {
});
it("should select a opaque as auth mechanism", async () => {
- const testRepo = {
+ const testRepo = new PackageRepositoryDetail({
...repo,
auth: {
- type: PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_OPAQUE,
- opaqueCreds: {
- data: {},
+ type: PackageRepositoryAuth_PackageRepositoryAuthType.OPAQUE,
+ packageRepoAuthOneOf: {
+ case: "opaqueCreds",
+ value: new OpaqueCredentials({
+ data: {},
+ }),
},
},
- } as PackageRepositoryDetail;
+ });
let wrapper: any;
await act(async () => {
wrapper = mountWrapper(
@@ -918,16 +944,19 @@ describe("when the repository info is already populated", () => {
});
it("should select a ssh as auth mechanism", async () => {
- const testRepo = {
+ const testRepo = new PackageRepositoryDetail({
...repo,
auth: {
- type: PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_SSH,
- sshCreds: {
- knownHosts: "foo",
- privateKey: "bar",
+ type: PackageRepositoryAuth_PackageRepositoryAuthType.SSH,
+ packageRepoAuthOneOf: {
+ case: "sshCreds",
+ value: new SshCredentials({
+ knownHosts: "foo",
+ privateKey: "bar",
+ }),
},
},
- } as PackageRepositoryDetail;
+ });
let wrapper: any;
await act(async () => {
wrapper = mountWrapper(
@@ -947,16 +976,19 @@ describe("when the repository info is already populated", () => {
});
it("should select a tls as auth mechanism", async () => {
- const testRepo = {
+ const testRepo = new PackageRepositoryDetail({
...repo,
auth: {
- type: PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_TLS,
- tlsCertKey: {
- cert: "foo",
- key: "bar",
+ type: PackageRepositoryAuth_PackageRepositoryAuthType.TLS,
+ packageRepoAuthOneOf: {
+ case: "tlsCertKey",
+ value: new TlsCertKey({
+ cert: "foo",
+ key: "bar",
+ }),
},
},
- } as PackageRepositoryDetail;
+ });
let wrapper: any;
await act(async () => {
wrapper = mountWrapper(
@@ -994,13 +1026,15 @@ describe("auth provider selector for Flux repositories", () => {
} as PackageRepositoryDetail;
it("repository auth provider should appear as a valid option for Flux and OCI", async () => {
- const testRepo = {
+ const testRepo = new PackageRepositoryDetail({
...repo,
type: "oci",
- customDetail: {
- provider: "",
- } as Partial,
- } as PackageRepositoryDetail;
+ customDetail: new Any({
+ value: new FluxPackageRepositoryCustomDetail({
+ provider: "",
+ }).toBinary(),
+ }),
+ });
let wrapper: any;
await act(async () => {
wrapper = mountWrapper(
@@ -1066,13 +1100,21 @@ describe("auth provider selector for Flux repositories", () => {
});
it("repository auth provider selected should show the subsequent options dropdown", async () => {
- const testRepo = {
+ const customDetail = new FluxPackageRepositoryCustomDetail({
+ provider: "aws",
+ });
+ // UPTOHERE: Is there a difference between google's Any and
+ // connect's Any? (Well, yes, one has a constructor etc.)
+ // Currently logging is showing the typeUrl appearing as the
+ // provider value :/
+ const testRepo = new PackageRepositoryDetail({
...repo,
type: "oci",
customDetail: {
- provider: "aws",
- } as Partial,
- } as PackageRepositoryDetail;
+ typeUrl: FluxPackageRepositoryCustomDetail.typeName,
+ value: customDetail.toBinary(),
+ } as Any,
+ });
let wrapper: any;
await act(async () => {
wrapper = mountWrapper(
diff --git a/dashboard/src/components/Config/PkgRepoList/PkgRepoForm.tsx b/dashboard/src/components/Config/PkgRepoList/PkgRepoForm.tsx
index ed757b043fc..4ba85338027 100644
--- a/dashboard/src/components/Config/PkgRepoList/PkgRepoForm.tsx
+++ b/dashboard/src/components/Config/PkgRepoList/PkgRepoForm.tsx
@@ -22,10 +22,13 @@ import {
PackageRepositoryAuth_PackageRepositoryAuthType,
PackageRepositoryReference,
UsernamePassword,
-} from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
-import { FluxPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/fluxv2/packages/v1alpha1/fluxv2";
-import { HelmPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm";
+} from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
+import { FluxPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/fluxv2/packages/v1alpha1/fluxv2_pb";
+import {
+ HelmPackageRepositoryCustomDetail,
+ ImagesPullSecret,
+} from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm_pb";
import { useCallback, useEffect, useRef, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { Action } from "redux";
@@ -98,11 +101,11 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
// Auth type of the package repository
const [authMethod, setAuthMethod] = useState(
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED,
+ PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED,
);
// Auth type of the registry (for Helm-based repos)
const [helmPSAuthMethod, setHelmPsAuthMethod] = useState(
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED,
+ PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED,
);
// PACKAGE_REPOSITORY_AUTH_TYPE_AUTHORIZATION_HEADER
@@ -205,33 +208,95 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
setSkipTLS(!!repo.tlsConfig?.insecureSkipVerify);
setPassCredentials(!!repo.auth?.passCredentials);
setSyncInterval(repo.interval);
- setCustomCA(repo.tlsConfig?.certAuthority || "");
- setAuthCustomHeader(repo.auth?.header || "");
- setBearerToken(repo.auth?.header || "");
- setBasicPassword(repo.auth?.usernamePassword?.password || "");
- setBasicUser(repo.auth?.usernamePassword?.username || "");
- setSecretEmail(repo.auth?.dockerCreds?.email || "");
- setSecretPassword(repo.auth?.dockerCreds?.password || "");
- setSecretServer(repo.auth?.dockerCreds?.server || "");
- setSecretUser(repo.auth?.dockerCreds?.username || "");
- setSshKnownHosts(repo.auth?.sshCreds?.knownHosts || "");
- setSshPrivateKey(repo.auth?.sshCreds?.privateKey || "");
- setTlsAuthCert(repo.auth?.tlsCertKey?.cert || "");
- setTlsAuthKey(repo.auth?.tlsCertKey?.key || "");
- setOpaqueData(JSON.stringify(repo.auth?.opaqueCreds?.data) || "");
- setAuthMethod(
- repo.auth?.type ||
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED,
+ setCustomCA(
+ repo.tlsConfig?.packageRepoTlsConfigOneOf?.case === "certAuthority"
+ ? repo.tlsConfig?.packageRepoTlsConfigOneOf?.value
+ : "",
+ );
+ setAuthCustomHeader(
+ repo.auth?.packageRepoAuthOneOf?.case === "header"
+ ? repo.auth?.packageRepoAuthOneOf?.value
+ : "",
+ );
+ setBearerToken(
+ repo.auth?.packageRepoAuthOneOf?.case === "header"
+ ? repo.auth?.packageRepoAuthOneOf?.value
+ : "",
+ );
+ setBasicPassword(
+ repo.auth?.packageRepoAuthOneOf?.case === "usernamePassword"
+ ? repo.auth?.packageRepoAuthOneOf?.value.password
+ : "",
+ );
+ setBasicUser(
+ repo.auth?.packageRepoAuthOneOf?.case === "usernamePassword"
+ ? repo.auth?.packageRepoAuthOneOf?.value.username
+ : "",
+ );
+ setSecretEmail(
+ repo.auth?.packageRepoAuthOneOf?.case === "dockerCreds"
+ ? repo.auth?.packageRepoAuthOneOf?.value.email
+ : "",
+ );
+ setSecretPassword(
+ repo.auth?.packageRepoAuthOneOf?.case === "dockerCreds"
+ ? repo.auth?.packageRepoAuthOneOf?.value.password
+ : "",
+ );
+ setSecretServer(
+ repo.auth?.packageRepoAuthOneOf?.case === "dockerCreds"
+ ? repo.auth?.packageRepoAuthOneOf?.value.server
+ : "",
+ );
+ setSecretUser(
+ repo.auth?.packageRepoAuthOneOf?.case === "dockerCreds"
+ ? repo.auth?.packageRepoAuthOneOf?.value.username
+ : "",
+ );
+ setSshKnownHosts(
+ repo.auth?.packageRepoAuthOneOf?.case === "sshCreds"
+ ? repo.auth?.packageRepoAuthOneOf?.value.knownHosts
+ : "",
+ );
+ setSshPrivateKey(
+ repo.auth?.packageRepoAuthOneOf?.case === "sshCreds"
+ ? repo.auth?.packageRepoAuthOneOf?.value.privateKey
+ : "",
+ );
+ setTlsAuthCert(
+ repo.auth?.packageRepoAuthOneOf?.case === "tlsCertKey"
+ ? repo.auth?.packageRepoAuthOneOf?.value.cert
+ : "",
+ );
+ setTlsAuthKey(
+ repo.auth?.packageRepoAuthOneOf?.case === "tlsCertKey"
+ ? repo.auth?.packageRepoAuthOneOf?.value.key
+ : "",
+ );
+ setOpaqueData(
+ repo.auth?.packageRepoAuthOneOf?.case === "opaqueCreds"
+ ? JSON.stringify(repo.auth?.packageRepoAuthOneOf?.value.data)
+ : "",
);
- setSecretAuthName(repo.auth?.secretRef?.name || "");
- setSecretTLSName(repo.tlsConfig?.secretRef?.name || "");
- setIsUserManagedSecret(!!repo.auth?.secretRef?.name);
- setIsUserManagedCASecret(!!repo.tlsConfig?.secretRef?.name);
+ setAuthMethod(repo.auth?.type || PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED);
+ setSecretAuthName(
+ repo.auth?.packageRepoAuthOneOf?.case === "secretRef"
+ ? repo.auth?.packageRepoAuthOneOf?.value.name
+ : "",
+ );
+ setSecretTLSName(
+ repo.tlsConfig?.packageRepoTlsConfigOneOf?.case === "secretRef"
+ ? repo.tlsConfig?.packageRepoTlsConfigOneOf?.value.name
+ : "",
+ );
+ setIsUserManagedSecret(!!(repo.auth?.packageRepoAuthOneOf?.case === "secretRef"));
+ setIsUserManagedCASecret(!!(repo.tlsConfig?.packageRepoTlsConfigOneOf?.case === "secretRef"));
// setting custom details for the Helm plugin
- if (repo.packageRepoRef?.plugin?.name === PluginNames.PACKAGES_HELM) {
- const helmPackageRepositoryCustomDetail =
- repo.customDetail as Partial;
+ if (repo.packageRepoRef?.plugin?.name === PluginNames.PACKAGES_HELM && repo.customDetail) {
+ const helmPackageRepositoryCustomDetail = HelmPackageRepositoryCustomDetail.fromBinary(
+ repo.customDetail.value,
+ );
setOCIRepositories(helmPackageRepositoryCustomDetail?.ociRepositories?.join(", ") || "");
setPerformValidation(helmPackageRepositoryCustomDetail?.performValidation || false);
if (helmPackageRepositoryCustomDetail?.filterRule?.jq) {
@@ -247,36 +312,62 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
setProxyOptionsNoProxy(helmPackageRepositoryCustomDetail.proxyOptions.noProxy);
}
if (
- helmPackageRepositoryCustomDetail?.imagesPullSecret?.secretRef ||
- helmPackageRepositoryCustomDetail?.imagesPullSecret?.credentials
+ helmPackageRepositoryCustomDetail?.imagesPullSecret?.dockerRegistryCredentialOneOf
+ ?.case === "secretRef" ||
+ helmPackageRepositoryCustomDetail?.imagesPullSecret?.dockerRegistryCredentialOneOf
+ ?.case === "credentials"
) {
setUseSameAuthCreds(false);
setIsUserManagedPSSecret(
- !!helmPackageRepositoryCustomDetail?.imagesPullSecret?.secretRef,
+ !!(
+ helmPackageRepositoryCustomDetail?.imagesPullSecret?.dockerRegistryCredentialOneOf
+ ?.case === "secretRef"
+ ),
);
- setHelmPsAuthMethod(
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON,
+ setHelmPsAuthMethod(PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON);
+ setSecretPSName(
+ helmPackageRepositoryCustomDetail?.imagesPullSecret?.dockerRegistryCredentialOneOf
+ ?.case === "secretRef"
+ ? helmPackageRepositoryCustomDetail?.imagesPullSecret?.dockerRegistryCredentialOneOf
+ ?.value
+ : "",
);
- setSecretPSName(helmPackageRepositoryCustomDetail?.imagesPullSecret?.secretRef || "");
setPullSecretEmail(
- helmPackageRepositoryCustomDetail?.imagesPullSecret?.credentials?.email || "",
+ helmPackageRepositoryCustomDetail?.imagesPullSecret?.dockerRegistryCredentialOneOf
+ ?.case === "credentials"
+ ? helmPackageRepositoryCustomDetail?.imagesPullSecret?.dockerRegistryCredentialOneOf
+ ?.value.email
+ : "",
);
setPullSecretUser(
- helmPackageRepositoryCustomDetail?.imagesPullSecret?.credentials?.username || "",
+ helmPackageRepositoryCustomDetail?.imagesPullSecret?.dockerRegistryCredentialOneOf
+ ?.case === "credentials"
+ ? helmPackageRepositoryCustomDetail?.imagesPullSecret?.dockerRegistryCredentialOneOf
+ ?.value.username
+ : "",
);
setPullSecretPassword(
- helmPackageRepositoryCustomDetail?.imagesPullSecret?.credentials?.password || "",
+ helmPackageRepositoryCustomDetail?.imagesPullSecret?.dockerRegistryCredentialOneOf
+ ?.case === "credentials"
+ ? helmPackageRepositoryCustomDetail?.imagesPullSecret?.dockerRegistryCredentialOneOf
+ ?.value.password
+ : "",
);
setPullSecretServer(
- helmPackageRepositoryCustomDetail?.imagesPullSecret?.credentials?.server || "",
+ helmPackageRepositoryCustomDetail?.imagesPullSecret?.dockerRegistryCredentialOneOf
+ ?.case === "credentials"
+ ? helmPackageRepositoryCustomDetail?.imagesPullSecret?.dockerRegistryCredentialOneOf
+ ?.value.server
+ : "",
);
}
}
// setting custom details for the Flux plugin
if (repo.packageRepoRef?.plugin?.name === PluginNames.PACKAGES_FLUX && repo.customDetail) {
- const fluxPackageRepositoryCustomDetail =
- repo.customDetail as Partial;
+ const fluxPackageRepositoryCustomDetail = FluxPackageRepositoryCustomDetail.fromBinary(
+ repo.customDetail.value,
+ );
setAuthProvider(fluxPackageRepositoryCustomDetail?.provider || "");
}
}
@@ -285,7 +376,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
const hasAuthProvider = useCallback(() => authProvider !== "", [authProvider]);
const handleFluxAuthProviderAuthChange = useCallback(() => {
- setAuthMethod(PackageRepositoryAuth_PackageRepositoryAuthType.UNRECOGNIZED);
+ setAuthMethod(PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED);
setShowAuthProviderDetails(true);
if (!hasAuthProvider()) {
setAuthProvider("generic");
@@ -294,11 +385,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
useEffect(() => {
// Reset auth provider state as soon as there is an auth type selected
- if (
- authMethod === PackageRepositoryAuth_PackageRepositoryAuthType.UNRECOGNIZED ||
- authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED
- ) {
+ if (authMethod === PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED) {
if (hasAuthProvider()) {
handleFluxAuthProviderAuthChange();
}
@@ -327,10 +414,10 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
// send the proper header depending on the auth method
let finalHeader = "";
switch (authMethod) {
- case PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_AUTHORIZATION_HEADER:
+ case PackageRepositoryAuth_PackageRepositoryAuthType.AUTHORIZATION_HEADER:
finalHeader = authCustomHeader;
break;
- case PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BEARER:
+ case PackageRepositoryAuth_PackageRepositoryAuthType.BEARER:
finalHeader = bearerToken;
break;
}
@@ -397,35 +484,39 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
} as IPkgRepoFormData;
// enrich the request object with the corresponding plugin's custom details
+ let imagesPullSecret: ImagesPullSecret | undefined;
switch (plugin?.name) {
case PluginNames.PACKAGES_HELM:
- request.customDetail = {
+ if (
+ helmPSAuthMethod === PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON
+ ) {
+ if (isUserManagedPSSecret) {
+ imagesPullSecret = new ImagesPullSecret({
+ dockerRegistryCredentialOneOf: {
+ case: "secretRef",
+ value: useSameAuthCreds ? secretAuthName : secretPSName,
+ },
+ });
+ } else {
+ imagesPullSecret = new ImagesPullSecret({
+ dockerRegistryCredentialOneOf: {
+ case: "credentials",
+ value: {
+ email: useSameAuthCreds ? secretEmail : pullSecretEmail,
+ username: useSameAuthCreds ? secretUser : pullSecretUser,
+ password: useSameAuthCreds ? secretPassword : pullSecretPassword,
+ server: useSameAuthCreds ? secretServer : pullSecretServer,
+ },
+ },
+ });
+ }
+ }
+ request.customDetail = new HelmPackageRepositoryCustomDetail({
ociRepositories: ociRepoList,
performValidation,
filterRule: filter,
- imagesPullSecret: {
- // if using the same credentials toggle is set, use the repo auth's creds instead
- secretRef:
- helmPSAuthMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON &&
- isUserManagedPSSecret
- ? useSameAuthCreds
- ? secretAuthName
- : secretPSName
- : "",
- credentials:
- helmPSAuthMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON &&
- !isUserManagedPSSecret
- ? {
- email: useSameAuthCreds ? secretEmail : pullSecretEmail,
- username: useSameAuthCreds ? secretUser : pullSecretUser,
- password: useSameAuthCreds ? secretPassword : pullSecretPassword,
- server: useSameAuthCreds ? secretServer : pullSecretServer,
- }
- : undefined,
- },
- } as HelmPackageRepositoryCustomDetail;
+ imagesPullSecret,
+ });
break;
//TODO(agamez): add it once other PRs get merged
// case PluginNames.PACKAGES_KAPP:
@@ -438,8 +529,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
} as FluxPackageRepositoryCustomDetail;
// Backend won't accept UNRECOGNIZED
- request.authMethod =
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED;
+ request.authMethod = PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED;
}
break;
default:
@@ -487,11 +577,9 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
// if the user selects the docker config, suggest also setting the pull secret
if (
PackageRepositoryAuth_PackageRepositoryAuthType[e.target.value] ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON
) {
- setHelmPsAuthMethod(
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON,
- );
+ setHelmPsAuthMethod(PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON);
// if user hasn't set any field yet, suggest using the same pullsecret
if (
!secretPSName &&
@@ -513,9 +601,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
// if a unsupported auth method is selected, reset it to the default one
if (!getSupportedPackageRepositoryAuthTypes(plugin, newType).includes(authMethod)) {
- setAuthMethod(
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED,
- );
+ setAuthMethod(PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED);
}
};
const handlePluginRadioButtonChange = (e: React.ChangeEvent) => {
@@ -527,9 +613,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
// if a unsupported auth method is selected, reset it to the default one
if (!getSupportedPackageRepositoryAuthTypes(newPlugin, type).includes(authMethod)) {
- setAuthMethod(
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED,
- );
+ setAuthMethod(PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED);
}
// set some default values based on the selected plugin
@@ -703,8 +787,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
onChange={handleSecretAuthNameChange}
required={
isUserManagedSecret &&
- authMethod !==
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED
+ authMethod !== PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED
}
pattern={k8sObjectNameRegex}
title="Use lower case alphanumeric characters, '-' or '.'"
@@ -1068,13 +1151,11 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
name="auth"
value={
PackageRepositoryAuth_PackageRepositoryAuthType[
- PackageRepositoryAuth_PackageRepositoryAuthType
- .PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED
+ PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED
] || ""
}
checked={
- authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED
+ authMethod === PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED
}
onChange={handleAuthRadioButtonChange}
/>
@@ -1088,7 +1169,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
value="flux-auth-provider"
checked={
authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.UNRECOGNIZED &&
+ PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED &&
showAuthProviderDetails
}
onChange={handleFluxAuthProviderAuthChange}
@@ -1103,18 +1184,16 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
name="auth"
value={
PackageRepositoryAuth_PackageRepositoryAuthType[
- PackageRepositoryAuth_PackageRepositoryAuthType
- .PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH
] || ""
}
checked={
- authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH
+ authMethod === PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH
}
onChange={handleAuthRadioButtonChange}
disabled={
!getSupportedPackageRepositoryAuthTypes(plugin, type).includes(
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
)
}
/>
@@ -1127,18 +1206,16 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
name="auth"
value={
PackageRepositoryAuth_PackageRepositoryAuthType[
- PackageRepositoryAuth_PackageRepositoryAuthType
- .PACKAGE_REPOSITORY_AUTH_TYPE_BEARER
+ PackageRepositoryAuth_PackageRepositoryAuthType.BEARER
] || ""
}
checked={
- authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BEARER
+ authMethod === PackageRepositoryAuth_PackageRepositoryAuthType.BEARER
}
onChange={handleAuthRadioButtonChange}
disabled={
!getSupportedPackageRepositoryAuthTypes(plugin, type).includes(
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BEARER,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BEARER,
)
}
/>
@@ -1153,18 +1230,17 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
name="auth"
value={
PackageRepositoryAuth_PackageRepositoryAuthType[
- PackageRepositoryAuth_PackageRepositoryAuthType
- .PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON
] || ""
}
checked={
authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON
}
onChange={handleAuthRadioButtonChange}
disabled={
!getSupportedPackageRepositoryAuthTypes(plugin, type).includes(
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON,
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON,
)
}
/>
@@ -1179,18 +1255,17 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
name="auth"
value={
PackageRepositoryAuth_PackageRepositoryAuthType[
- PackageRepositoryAuth_PackageRepositoryAuthType
- .PACKAGE_REPOSITORY_AUTH_TYPE_AUTHORIZATION_HEADER
+ PackageRepositoryAuth_PackageRepositoryAuthType.AUTHORIZATION_HEADER
] || ""
}
checked={
authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_AUTHORIZATION_HEADER
+ PackageRepositoryAuth_PackageRepositoryAuthType.AUTHORIZATION_HEADER
}
onChange={handleAuthRadioButtonChange}
disabled={
!getSupportedPackageRepositoryAuthTypes(plugin, type).includes(
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_AUTHORIZATION_HEADER,
+ PackageRepositoryAuth_PackageRepositoryAuthType.AUTHORIZATION_HEADER,
)
}
/>
@@ -1205,18 +1280,14 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
name="auth"
value={
PackageRepositoryAuth_PackageRepositoryAuthType[
- PackageRepositoryAuth_PackageRepositoryAuthType
- .PACKAGE_REPOSITORY_AUTH_TYPE_SSH
+ PackageRepositoryAuth_PackageRepositoryAuthType.SSH
] || ""
}
- checked={
- authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_SSH
- }
+ checked={authMethod === PackageRepositoryAuth_PackageRepositoryAuthType.SSH}
onChange={handleAuthRadioButtonChange}
disabled={
!getSupportedPackageRepositoryAuthTypes(plugin, type).includes(
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_SSH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.SSH,
)
}
/>
@@ -1231,18 +1302,14 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
name="auth"
value={
PackageRepositoryAuth_PackageRepositoryAuthType[
- PackageRepositoryAuth_PackageRepositoryAuthType
- .PACKAGE_REPOSITORY_AUTH_TYPE_TLS
+ PackageRepositoryAuth_PackageRepositoryAuthType.TLS
] || ""
}
- checked={
- authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_TLS
- }
+ checked={authMethod === PackageRepositoryAuth_PackageRepositoryAuthType.TLS}
onChange={handleAuthRadioButtonChange}
disabled={
!getSupportedPackageRepositoryAuthTypes(plugin, type).includes(
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_TLS,
+ PackageRepositoryAuth_PackageRepositoryAuthType.TLS,
)
}
/>
@@ -1257,18 +1324,16 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
name="auth"
value={
PackageRepositoryAuth_PackageRepositoryAuthType[
- PackageRepositoryAuth_PackageRepositoryAuthType
- .PACKAGE_REPOSITORY_AUTH_TYPE_OPAQUE
+ PackageRepositoryAuth_PackageRepositoryAuthType.OPAQUE
] || ""
}
checked={
- authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_OPAQUE
+ authMethod === PackageRepositoryAuth_PackageRepositoryAuthType.OPAQUE
}
onChange={handleAuthRadioButtonChange}
disabled={
!getSupportedPackageRepositoryAuthTypes(plugin, type).includes(
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_OPAQUE,
+ PackageRepositoryAuth_PackageRepositoryAuthType.OPAQUE,
)
}
/>
@@ -1282,8 +1347,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
{isUserManagedSecretToggle("basic")}
@@ -1302,7 +1366,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
placeholder="username"
required={
authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH
}
/>
@@ -1317,7 +1381,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
placeholder="password"
required={
authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH
}
/>
@@ -1328,10 +1392,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
{/* Begin http bearer authentication */}
{isUserManagedSecretToggle("bearer")}
@@ -1349,7 +1410,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
placeholder="xrxNcWghpRLdcPHFgVRM73rr4N7qjvjm"
required={
authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BEARER
+ PackageRepositoryAuth_PackageRepositoryAuthType.BEARER
}
/>
@@ -1362,7 +1423,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
id="kubeapps-repo-auth-details-docker"
hidden={
authMethod !==
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON
}
>
{isUserManagedSecretToggle("docker")}
@@ -1380,7 +1441,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
placeholder="https://index.docker.io/v1/"
required={
authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON
}
/>
@@ -1394,7 +1455,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
placeholder="Username"
required={
authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON
}
/>
@@ -1409,7 +1470,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
placeholder="Password"
required={
authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON
}
/>
@@ -1432,7 +1493,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
id="kubeapps-repo-auth-details-custom"
hidden={
authMethod !==
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_AUTHORIZATION_HEADER
+ PackageRepositoryAuth_PackageRepositoryAuthType.AUTHORIZATION_HEADER
}
>
{isUserManagedSecretToggle("custom")}
@@ -1453,7 +1514,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
onChange={handleAuthCustomHeaderChange}
required={
authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_AUTHORIZATION_HEADER
+ PackageRepositoryAuth_PackageRepositoryAuthType.AUTHORIZATION_HEADER
}
/>
@@ -1464,10 +1525,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
{/* Begin SSH authentication */}
{isUserManagedSecretToggle("ssh")}
@@ -1486,8 +1544,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
value={sshKnownHosts || ""}
onChange={handleSshKnownHostsChange}
required={
- authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_SSH
+ authMethod === PackageRepositoryAuth_PackageRepositoryAuthType.SSH
}
/>
@@ -1505,8 +1562,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
value={sshPrivateKey || ""}
onChange={handleSshPrivateKeyChange}
required={
- authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_SSH
+ authMethod === PackageRepositoryAuth_PackageRepositoryAuthType.SSH
}
/>
@@ -1517,10 +1573,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
{/* Begin TLS authentication */}
{isUserManagedSecretToggle("tls")}
@@ -1539,8 +1592,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
value={tlsAuthCert || ""}
onChange={handleTlsAuthCertChange}
required={
- authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_TLS
+ authMethod === PackageRepositoryAuth_PackageRepositoryAuthType.TLS
}
/>
@@ -1556,8 +1608,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
value={tlsAuthKey || ""}
onChange={handleTlsAuthKeyChange}
required={
- authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_TLS
+ authMethod === PackageRepositoryAuth_PackageRepositoryAuthType.TLS
}
/>
@@ -1568,10 +1619,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
{/* Begin opaque authentication */}
{isUserManagedSecretToggle("opaque")}
@@ -1591,7 +1639,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
onChange={handleOpaqueDataChange}
required={
authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_OPAQUE
+ PackageRepositoryAuth_PackageRepositoryAuthType.OPAQUE
}
/>
@@ -1611,8 +1659,12 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
disabled={
!!repo.name &&
["aws", "azure", "gcp"].includes(
- (repo.customDetail as Partial
)
- ?.provider || "",
+ (repo.customDetail
+ ? FluxPackageRepositoryCustomDetail.fromBinary(
+ repo.customDetail?.value,
+ )
+ : undefined
+ )?.provider || "",
)
}
>
@@ -1661,18 +1713,17 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
name="auth"
value={
PackageRepositoryAuth_PackageRepositoryAuthType[
- PackageRepositoryAuth_PackageRepositoryAuthType
- .PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED
+ PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED
] || ""
}
checked={
helmPSAuthMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED
+ PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED
}
onChange={handleImgPSChange}
required={
authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON
}
/>
@@ -1687,18 +1738,17 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
name="auth"
value={
PackageRepositoryAuth_PackageRepositoryAuthType[
- PackageRepositoryAuth_PackageRepositoryAuthType
- .PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON
] || ""
}
checked={
helmPSAuthMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON
}
onChange={handleImgPSChange}
required={
authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON
}
/>
@@ -1711,17 +1761,18 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
id="kubeapps-repo-imagePullSecrets-details-docker"
hidden={
helmPSAuthMethod !==
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON
}
>
{authMethod ===
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON &&
- !(
- !!(repo?.customDetail as Partial)
- ?.imagesPullSecret?.credentials ||
- !!(repo?.customDetail as Partial)
- ?.imagesPullSecret?.secretRef
- ) && (
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON &&
+ !!(
+ repo.customDetail
+ ? HelmPackageRepositoryCustomDetail.fromBinary(
+ repo.customDetail?.value,
+ )
+ : undefined
+ )?.imagesPullSecret?.dockerRegistryCredentialOneOf.value && (
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
@@ -1755,11 +1806,12 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
checked={isUserManagedPSSecret}
disabled={
!!(
- repo?.customDetail as Partial
- )?.imagesPullSecret?.credentials ||
- !!(
- repo?.customDetail as Partial
- )?.imagesPullSecret?.secretRef
+ repo.customDetail
+ ? HelmPackageRepositoryCustomDetail.fromBinary(
+ repo.customDetail?.value,
+ )
+ : undefined
+ )?.imagesPullSecret?.dockerRegistryCredentialOneOf.value
}
/>
@@ -1780,7 +1832,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
required={
isUserManagedPSSecret &&
helmPSAuthMethod !==
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED
+ PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED
}
pattern={k8sObjectNameRegex}
title="Use lower case alphanumeric characters, '-' or '.'"
@@ -1814,7 +1866,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
required={
!isUserManagedPSSecret &&
helmPSAuthMethod !==
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED
+ PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED
}
/>
@@ -1831,7 +1883,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
required={
!isUserManagedPSSecret &&
helmPSAuthMethod !==
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED
+ PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED
}
/>
@@ -1849,7 +1901,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
required={
!isUserManagedPSSecret &&
helmPSAuthMethod !==
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED
+ PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED
}
/>
@@ -2017,8 +2069,7 @@ export function PkgRepoForm(props: IPkgRepoFormProps) {
checked={isUserManagedCASecret}
disabled={
skipTLS ||
- (!!repo?.name &&
- (!!repo?.tlsConfig?.certAuthority || !!repo?.tlsConfig?.secretRef))
+ (!!repo?.name && !!repo?.tlsConfig?.packageRepoTlsConfigOneOf.value)
}
/>
diff --git a/dashboard/src/components/Config/PkgRepoList/PkgRepoList.test.tsx b/dashboard/src/components/Config/PkgRepoList/PkgRepoList.test.tsx
index 8d33289b3da..a0be81b245f 100644
--- a/dashboard/src/components/Config/PkgRepoList/PkgRepoList.test.tsx
+++ b/dashboard/src/components/Config/PkgRepoList/PkgRepoList.test.tsx
@@ -9,13 +9,13 @@ import Tooltip from "components/js/Tooltip";
import {
PackageRepositoriesPermissions,
PackageRepositorySummary,
-} from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
+} from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
import { act } from "react-dom/test-utils";
import * as ReactRedux from "react-redux";
import { Link } from "react-router-dom";
import { IPackageRepositoryState } from "reducers/repos";
import { Kube } from "shared/Kube";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import { defaultStore, getStore, initialState, mountWrapper } from "shared/specs/mountWrapper";
import { IStoreState, PluginNames } from "shared/types";
import { PkgRepoControl } from "./PkgRepoControl";
@@ -78,12 +78,12 @@ it("fetches repos from all namespaces", () => {
...initialState,
repos: {
reposPermissions: [
- {
+ new PackageRepositoriesPermissions({
global: {
list: true,
},
namespace: {},
- },
+ }),
] as PackageRepositoriesPermissions[],
},
} as Partial),
@@ -215,7 +215,7 @@ describe("global and namespaced repositories", () => {
it("shows the global repositories with the buttons enabled based on permissions", async () => {
const permissions = [
- {
+ new PackageRepositoriesPermissions({
plugin: plugin,
global: {
create: true,
@@ -229,7 +229,7 @@ describe("global and namespaced repositories", () => {
list: true,
update: true,
},
- },
+ }),
] as PackageRepositoriesPermissions[];
let wrapper: any;
@@ -315,12 +315,12 @@ describe("global and namespaced repositories", () => {
repos: {
reposSummaries: [namespacedRepo],
reposPermissions: [
- {
+ new PackageRepositoriesPermissions({
global: {
list: true,
},
namespace: {},
- },
+ }),
] as PackageRepositoriesPermissions[],
} as IPackageRepositoryState,
} as Partial),
@@ -339,12 +339,12 @@ describe("global and namespaced repositories", () => {
repos: {
reposSummaries: [namespacedRepo],
reposPermissions: [
- {
+ new PackageRepositoriesPermissions({
global: {
list: true,
},
namespace: {},
- },
+ }),
] as PackageRepositoriesPermissions[],
} as IPackageRepositoryState,
} as Partial),
diff --git a/dashboard/src/components/Config/PkgRepoList/PkgRepoList.tsx b/dashboard/src/components/Config/PkgRepoList/PkgRepoList.tsx
index 481cfc6382a..02052339ee1 100644
--- a/dashboard/src/components/Config/PkgRepoList/PkgRepoList.tsx
+++ b/dashboard/src/components/Config/PkgRepoList/PkgRepoList.tsx
@@ -15,12 +15,12 @@ import {
PackageRepositoriesPermissions,
PackageRepositoryReference,
PackageRepositorySummary,
-} from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
+} from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
import qs from "qs";
import { useCallback, useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { Link, useLocation } from "react-router-dom";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import { IStoreState } from "shared/types";
import { app } from "shared/url";
import { getPluginName } from "shared/utils";
diff --git a/dashboard/src/components/DeploymentForm/DeploymentForm.test.tsx b/dashboard/src/components/DeploymentForm/DeploymentForm.test.tsx
index 8f775f89737..dec6d9b9297 100644
--- a/dashboard/src/components/DeploymentForm/DeploymentForm.test.tsx
+++ b/dashboard/src/components/DeploymentForm/DeploymentForm.test.tsx
@@ -11,9 +11,9 @@ import {
AvailablePackageReference,
PackageAppVersion,
ReconciliationOptions,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
-import { GetServiceAccountNamesResponse } from "gen/kubeappsapis/plugins/resources/v1alpha1/resources";
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
+import { GetServiceAccountNamesResponse } from "gen/kubeappsapis/plugins/resources/v1alpha1/resources_pb";
import { createMemoryHistory } from "history";
import { act } from "react-dom/test-utils";
import * as ReactRedux from "react-redux";
diff --git a/dashboard/src/components/DeploymentForm/DeploymentForm.tsx b/dashboard/src/components/DeploymentForm/DeploymentForm.tsx
index de17b9cdcb8..d3f6bfd062f 100644
--- a/dashboard/src/components/DeploymentForm/DeploymentForm.tsx
+++ b/dashboard/src/components/DeploymentForm/DeploymentForm.tsx
@@ -16,8 +16,8 @@ import { push } from "connected-react-router";
import {
AvailablePackageReference,
ReconciliationOptions,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import React, { useEffect, useRef, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import * as ReactRouter from "react-router-dom";
@@ -73,10 +73,12 @@ export default function DeploymentForm() {
const [pluginObj] = useState({ name: pluginName, version: pluginVersion } as Plugin);
const onChangeSA = (e: React.FormEvent) => {
- setReconciliationOptions({
- ...reconciliationOptions,
- serviceAccountName: e.currentTarget.value,
- });
+ setReconciliationOptions(
+ new ReconciliationOptions({
+ ...reconciliationOptions,
+ serviceAccountName: e.currentTarget.value,
+ }),
+ );
};
const [packageReference] = useState({
diff --git a/dashboard/src/components/DeploymentForm/DeploymentFormBody/DeploymentFormBody.test.tsx b/dashboard/src/components/DeploymentForm/DeploymentFormBody/DeploymentFormBody.test.tsx
index 23102160855..e069a3dd84c 100644
--- a/dashboard/src/components/DeploymentForm/DeploymentFormBody/DeploymentFormBody.test.tsx
+++ b/dashboard/src/components/DeploymentForm/DeploymentFormBody/DeploymentFormBody.test.tsx
@@ -6,7 +6,7 @@ import { JSONSchemaType } from "ajv";
import {
AvailablePackageDetail,
PackageAppVersion,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import { act } from "react-dom/test-utils";
import { MonacoDiffEditor } from "react-monaco-editor";
import { defaultStore, getStore, initialState, mountWrapper } from "shared/specs/mountWrapper";
diff --git a/dashboard/src/components/OperatorInstance/OperatorInstance.tsx b/dashboard/src/components/OperatorInstance/OperatorInstance.tsx
index d2067a0e66a..5c4e9cc338c 100644
--- a/dashboard/src/components/OperatorInstance/OperatorInstance.tsx
+++ b/dashboard/src/components/OperatorInstance/OperatorInstance.tsx
@@ -58,6 +58,9 @@ function parseResource(
if (crd.resources) {
crd.resources?.forEach(r => {
switch (r.kind) {
+ // TODO(minelson): Audit code to see if we can switch to use the normal ResourceRef
+ // here instead, then remove the shared/ResourceRef with the extra fields.
+ // https://github.com/vmware-tanzu/kubeapps/issues/6062
case "Deployment":
result.deployments.push(fromCRD(r, kind, cluster, namespace, ownerRef));
break;
diff --git a/dashboard/src/components/PackageHeader/AvailablePackageMaintainers.test.tsx b/dashboard/src/components/PackageHeader/AvailablePackageMaintainers.test.tsx
index 8767a727a07..e955ff0b5de 100644
--- a/dashboard/src/components/PackageHeader/AvailablePackageMaintainers.test.tsx
+++ b/dashboard/src/components/PackageHeader/AvailablePackageMaintainers.test.tsx
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { shallow } from "enzyme";
-import { Maintainer } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import { Maintainer } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import AvailablePackageMaintainers from "./AvailablePackageMaintainers";
const tests: Array<{
@@ -13,14 +13,14 @@ const tests: Array<{
}> = [
{
expectedLinks: [null],
- maintainers: [{ name: "Test Author", email: "" }],
+ maintainers: [new Maintainer({ name: "Test Author", email: "" })],
name: "with no email",
},
{
expectedLinks: [null, "mailto:test@example.com"],
maintainers: [
- { name: "Test Author", email: "" },
- { name: "Test Author 2", email: "test@example.com" },
+ new Maintainer({ name: "Test Author", email: "" }),
+ new Maintainer({ name: "Test Author 2", email: "test@example.com" }),
],
name: "with email",
},
@@ -28,8 +28,8 @@ const tests: Array<{
expectedLinks: ["https://github.com/test1", "https://github.com/test2"],
githubIDAsNames: true,
maintainers: [
- { name: "test1", email: "" },
- { name: "test2", email: "test@example.com" },
+ new Maintainer({ name: "test1", email: "" }),
+ new Maintainer({ name: "test2", email: "test@example.com" }),
],
name: "with github ids",
},
diff --git a/dashboard/src/components/PackageHeader/AvailablePackageMaintainers.tsx b/dashboard/src/components/PackageHeader/AvailablePackageMaintainers.tsx
index fd02b8467e6..84189b7809c 100644
--- a/dashboard/src/components/PackageHeader/AvailablePackageMaintainers.tsx
+++ b/dashboard/src/components/PackageHeader/AvailablePackageMaintainers.tsx
@@ -1,7 +1,7 @@
// Copyright 2021-2022 the Kubeapps contributors.
// SPDX-License-Identifier: Apache-2.0
-import { Maintainer } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import { Maintainer } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import React from "react";
interface IAvailablePackageMaintainersProps {
maintainers: Maintainer[];
diff --git a/dashboard/src/components/PackageHeader/PackageHeader.test.tsx b/dashboard/src/components/PackageHeader/PackageHeader.test.tsx
index 28118701e03..7bb5a1b581f 100644
--- a/dashboard/src/components/PackageHeader/PackageHeader.test.tsx
+++ b/dashboard/src/components/PackageHeader/PackageHeader.test.tsx
@@ -6,11 +6,11 @@ import {
AvailablePackageDetail,
Context,
PackageAppVersion,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import PackageHeader, { IPackageHeaderProps } from "./PackageHeader";
const testProps: IPackageHeaderProps = {
- availablePackageDetail: {
+ availablePackageDetail: new AvailablePackageDetail({
shortDescription: "A Test Package",
name: "foo",
categories: [""],
@@ -34,7 +34,7 @@ const testProps: IPackageHeaderProps = {
pkgVersion: "1.2.3",
appVersion: "4.5.6",
},
- } as AvailablePackageDetail,
+ }),
versions: [
{
pkgVersion: "0.1.2",
@@ -64,14 +64,14 @@ it("uses the icon", () => {
it("uses the first version as default in the select input", () => {
const versions: PackageAppVersion[] = [
- {
+ new PackageAppVersion({
pkgVersion: "1.2.3",
appVersion: "10.0.0",
- },
- {
+ }),
+ new PackageAppVersion({
pkgVersion: "1.2.4",
appVersion: "10.0.0",
- },
+ }),
];
const wrapper = mount();
expect(wrapper.find("select").prop("value")).toBe("1.2.3");
@@ -79,14 +79,14 @@ it("uses the first version as default in the select input", () => {
it("uses the current version as default in the select input", () => {
const versions: PackageAppVersion[] = [
- {
+ new PackageAppVersion({
pkgVersion: "1.2.3",
appVersion: "10.0.0",
- },
- {
+ }),
+ new PackageAppVersion({
pkgVersion: "1.2.4",
appVersion: "10.0.0",
- },
+ }),
];
const wrapper = mount(
,
diff --git a/dashboard/src/components/PackageHeader/PackageHeader.tsx b/dashboard/src/components/PackageHeader/PackageHeader.tsx
index cc6317923e9..8da689d9d64 100644
--- a/dashboard/src/components/PackageHeader/PackageHeader.tsx
+++ b/dashboard/src/components/PackageHeader/PackageHeader.tsx
@@ -6,7 +6,7 @@ import PageHeader from "components/PageHeader/PageHeader";
import {
AvailablePackageDetail,
PackageAppVersion,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import React from "react";
import placeholder from "icons/placeholder.svg";
import "./PackageHeader.css";
diff --git a/dashboard/src/components/PackageHeader/PackageVersionSelector.tsx b/dashboard/src/components/PackageHeader/PackageVersionSelector.tsx
index 3b0cf1de32a..32bc33f15f9 100644
--- a/dashboard/src/components/PackageHeader/PackageVersionSelector.tsx
+++ b/dashboard/src/components/PackageHeader/PackageVersionSelector.tsx
@@ -3,7 +3,7 @@
import { CdsControlMessage } from "@cds/react/forms";
import { CdsSelect } from "@cds/react/select";
-import { PackageAppVersion } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import { PackageAppVersion } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import React from "react";
interface IPackageVersionSelectorProps {
versions: PackageAppVersion[];
diff --git a/dashboard/src/components/PackageHeader/PackageView.test.tsx b/dashboard/src/components/PackageHeader/PackageView.test.tsx
index d46c25fc62d..784cc9a8623 100644
--- a/dashboard/src/components/PackageHeader/PackageView.test.tsx
+++ b/dashboard/src/components/PackageHeader/PackageView.test.tsx
@@ -9,8 +9,8 @@ import {
Context,
Maintainer,
PackageAppVersion,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import { createMemoryHistory } from "history";
import * as ReactRedux from "react-redux";
import { Route, Router } from "react-router-dom";
@@ -34,12 +34,12 @@ const defaultProps = {
plugin: { name: "my.plugin", version: "0.0.1" } as Plugin,
};
-const testVersion: PackageAppVersion = {
+const testVersion = new PackageAppVersion({
pkgVersion: "1.2.3",
appVersion: "4.5.6",
-};
+});
-const defaultAvailablePkgDetail: AvailablePackageDetail = {
+const defaultAvailablePkgDetail = new AvailablePackageDetail({
name: "foo",
categories: [""],
displayName: "foo",
@@ -49,11 +49,11 @@ const defaultAvailablePkgDetail: AvailablePackageDetail = {
sourceUrls: ["test"],
shortDescription: "test",
longDescription: "test",
- availablePackageRef: {
+ availablePackageRef: new AvailablePackageReference({
identifier: "foo/foo",
context: { cluster: "", namespace: "package-namespace" } as Context,
plugin: { name: "my.plugin", version: "0.0.1" } as Plugin,
- },
+ }),
valuesSchema: "test",
defaultValues: "test",
additionalDefaultValues: {},
@@ -63,7 +63,7 @@ const defaultAvailablePkgDetail: AvailablePackageDetail = {
appVersion: testVersion.appVersion,
pkgVersion: testVersion.pkgVersion,
} as PackageAppVersion,
-};
+});
const defaultPackageState = {
isFetching: false,
@@ -308,7 +308,9 @@ describe("AvailablePackageMaintainers githubIDAsNames prop value", () => {
for (const t of tests) {
it(`for ${t.name}`, () => {
const myAvailablePkgDetail = defaultAvailablePkgDetail;
- myAvailablePkgDetail.maintainers = [{ name: "John Smith", email: "john@example.com" }];
+ myAvailablePkgDetail.maintainers = [
+ new Maintainer({ name: "John Smith", email: "john@example.com" }),
+ ];
myAvailablePkgDetail.repoUrl = t.repoURL;
const wrapper = mountWrapper(
diff --git a/dashboard/src/components/PackageHeader/PackageView.tsx b/dashboard/src/components/PackageHeader/PackageView.tsx
index c17fd7fbed7..4bc3bc20039 100644
--- a/dashboard/src/components/PackageHeader/PackageView.tsx
+++ b/dashboard/src/components/PackageHeader/PackageView.tsx
@@ -10,8 +10,8 @@ import Column from "components/js/Column";
import Row from "components/js/Row";
import LoadingWrapper from "components/LoadingWrapper";
import { push } from "connected-react-router";
-import { AvailablePackageReference } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+import { AvailablePackageReference } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import { useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import * as ReactRouter from "react-router-dom";
diff --git a/dashboard/src/components/PageHeader/PageHeader.test.tsx b/dashboard/src/components/PageHeader/PageHeader.test.tsx
index e7b2cf21458..6c758690645 100644
--- a/dashboard/src/components/PageHeader/PageHeader.test.tsx
+++ b/dashboard/src/components/PageHeader/PageHeader.test.tsx
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { mount } from "enzyme";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import PageHeader from "./PageHeader";
const defaultProps = {
diff --git a/dashboard/src/components/PageHeader/PageHeader.tsx b/dashboard/src/components/PageHeader/PageHeader.tsx
index 5967a8b4ffa..4ad156e094c 100644
--- a/dashboard/src/components/PageHeader/PageHeader.tsx
+++ b/dashboard/src/components/PageHeader/PageHeader.tsx
@@ -6,7 +6,7 @@ import Column from "components/js/Column";
import Row from "components/js/Row";
import { getPluginIcon, getPluginPackageName } from "shared/utils";
import "./PageHeader.css";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
export interface IPageHeaderProps {
title: string;
diff --git a/dashboard/src/components/SelectRepoForm/SelectRepoForm.test.tsx b/dashboard/src/components/SelectRepoForm/SelectRepoForm.test.tsx
index 792d47fe9a1..7463d960997 100644
--- a/dashboard/src/components/SelectRepoForm/SelectRepoForm.test.tsx
+++ b/dashboard/src/components/SelectRepoForm/SelectRepoForm.test.tsx
@@ -4,9 +4,9 @@
import { CdsButton } from "@cds/react/button";
import actions from "actions";
import Alert from "components/js/Alert";
-import { InstalledPackageDetail } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
-import { PackageRepositorySummary } from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+import { InstalledPackageDetail } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
+import { PackageRepositorySummary } from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import * as ReactRedux from "react-redux";
import { IPackageRepositoryState } from "reducers/repos";
import { defaultStore, getStore, initialState, mountWrapper } from "shared/specs/mountWrapper";
diff --git a/dashboard/src/components/SelectRepoForm/SelectRepoForm.tsx b/dashboard/src/components/SelectRepoForm/SelectRepoForm.tsx
index 558059a8d39..c46e5669ab5 100644
--- a/dashboard/src/components/SelectRepoForm/SelectRepoForm.tsx
+++ b/dashboard/src/components/SelectRepoForm/SelectRepoForm.tsx
@@ -4,7 +4,7 @@
import { CdsButton } from "@cds/react/button";
import actions from "actions";
import Alert from "components/js/Alert";
-import { InstalledPackageDetail } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import { InstalledPackageDetail } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import { useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { Link } from "react-router-dom";
diff --git a/dashboard/src/components/UpgradeForm/UpgradeForm.test.tsx b/dashboard/src/components/UpgradeForm/UpgradeForm.test.tsx
index 128e74f8811..f2f534179bf 100644
--- a/dashboard/src/components/UpgradeForm/UpgradeForm.test.tsx
+++ b/dashboard/src/components/UpgradeForm/UpgradeForm.test.tsx
@@ -17,8 +17,8 @@ import {
Maintainer,
PackageAppVersion,
VersionReference,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import { cloneDeep } from "lodash";
import { act } from "react-dom/test-utils";
import * as ReactRedux from "react-redux";
@@ -35,10 +35,10 @@ import {
import * as url from "shared/url";
import UpgradeForm from "./UpgradeForm";
-const testVersion: PackageAppVersion = {
+const testVersion = new PackageAppVersion({
pkgVersion: "1.2.3",
appVersion: "4.5.6",
-};
+});
const schema = { properties: { foo: { type: "string" } } };
@@ -86,19 +86,18 @@ const installedPkgDetail = {
plugin: { name: "my.plugin", version: "0.0.1" } as Plugin,
} as AvailablePackageReference,
currentVersion: { appVersion: "10.0.0", pkgVersion: "1.0.0" } as PackageAppVersion,
- installedPackageRef: {
+ installedPackageRef: new InstalledPackageReference({
identifier: "stable/bar",
- pkgVersion: "1.0.0",
context: { cluster: defaultProps.cluster, namespace: defaultProps.repoNamespace } as Context,
plugin: { name: "my.plugin", version: "0.0.1" } as Plugin,
- } as InstalledPackageReference,
+ }),
latestMatchingVersion: { appVersion: "10.0.0", pkgVersion: "1.0.0" } as PackageAppVersion,
latestVersion: { appVersion: "10.0.0", pkgVersion: "1.0.0" } as PackageAppVersion,
pkgVersionReference: { version: "1" } as VersionReference,
reconciliationOptions: {},
status: {
ready: true,
- reason: InstalledPackageStatus_StatusReason.STATUS_REASON_INSTALLED,
+ reason: InstalledPackageStatus_StatusReason.INSTALLED,
userReason: "deployed",
} as InstalledPackageStatus,
} as CustomInstalledPackageDetail;
@@ -721,8 +720,8 @@ describe("when receiving new props", () => {
...state.apps,
selected: {
...state.apps.selected,
- values: t.deployedValues,
- },
+ valuesApplied: t.deployedValues,
+ } as CustomInstalledPackageDetail,
} as IInstalledPackageState,
packages: {
selected: {
diff --git a/dashboard/src/containers/AccessURLTableContainer/AccessURLTableContainer.test.tsx b/dashboard/src/containers/AccessURLTableContainer/AccessURLTableContainer.test.tsx
index 049d8ba86b8..68132567880 100644
--- a/dashboard/src/containers/AccessURLTableContainer/AccessURLTableContainer.test.tsx
+++ b/dashboard/src/containers/AccessURLTableContainer/AccessURLTableContainer.test.tsx
@@ -6,7 +6,7 @@ import { initialKinds } from "reducers/kube";
import configureMockStore from "redux-mock-store";
import thunk from "redux-thunk";
import { keyForResourceRef } from "shared/ResourceRef";
-import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import { IKubeItem, IKubeState, IResource, IStoreState } from "shared/types";
import AccessURLTableContainer from ".";
import AccessURLTable from "../../components/AppView/AccessURLTable";
diff --git a/dashboard/src/containers/AccessURLTableContainer/AccessURLTableContainer.tsx b/dashboard/src/containers/AccessURLTableContainer/AccessURLTableContainer.tsx
index 8ef5f96650c..7ec849b9078 100644
--- a/dashboard/src/containers/AccessURLTableContainer/AccessURLTableContainer.tsx
+++ b/dashboard/src/containers/AccessURLTableContainer/AccessURLTableContainer.tsx
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { connect } from "react-redux";
-import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import { IStoreState } from "shared/types";
import AccessURLTable from "../../components/AppView/AccessURLTable";
import { filterByResourceRefs } from "../helpers";
diff --git a/dashboard/src/containers/ApplicationStatusContainer/ApplicationStatusContainer.test.tsx b/dashboard/src/containers/ApplicationStatusContainer/ApplicationStatusContainer.test.tsx
index 8fff4774011..413a25c7ef7 100644
--- a/dashboard/src/containers/ApplicationStatusContainer/ApplicationStatusContainer.test.tsx
+++ b/dashboard/src/containers/ApplicationStatusContainer/ApplicationStatusContainer.test.tsx
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { shallow } from "enzyme";
-import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import { initialKinds } from "reducers/kube";
import configureMockStore from "redux-mock-store";
import thunk from "redux-thunk";
diff --git a/dashboard/src/containers/ApplicationStatusContainer/ApplicationStatusContainer.ts b/dashboard/src/containers/ApplicationStatusContainer/ApplicationStatusContainer.ts
index 22ed83e58ec..e3dcd0c041c 100644
--- a/dashboard/src/containers/ApplicationStatusContainer/ApplicationStatusContainer.ts
+++ b/dashboard/src/containers/ApplicationStatusContainer/ApplicationStatusContainer.ts
@@ -4,7 +4,7 @@
import {
InstalledPackageDetail,
ResourceRef,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import { connect } from "react-redux";
import ApplicationStatus from "../../components/ApplicationStatus";
import { IStoreState } from "../../shared/types";
diff --git a/dashboard/src/containers/helpers/index.test.ts b/dashboard/src/containers/helpers/index.test.ts
index 695f54139ae..3624411b026 100644
--- a/dashboard/src/containers/helpers/index.test.ts
+++ b/dashboard/src/containers/helpers/index.test.ts
@@ -4,7 +4,7 @@
import { keyForResourceRef } from "shared/ResourceRef";
import { IKubeItem, IKubeState, IResource } from "shared/types";
import { filterByResourceRefs } from ".";
-import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
describe("filterByResourceRefs", () => {
const svc1 = {
diff --git a/dashboard/src/containers/helpers/index.ts b/dashboard/src/containers/helpers/index.ts
index 0c7a76cf5de..eb43ae13efd 100644
--- a/dashboard/src/containers/helpers/index.ts
+++ b/dashboard/src/containers/helpers/index.ts
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { keyForResourceRef } from "shared/ResourceRef";
-import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import { IKubeState } from "shared/types";
// Takes a set of ResourceRefs and the resources from the Redux state and
diff --git a/dashboard/src/reducers/availablepackages.test.ts b/dashboard/src/reducers/availablepackages.test.ts
index 6d378549ae3..a9f54b1db6c 100644
--- a/dashboard/src/reducers/availablepackages.test.ts
+++ b/dashboard/src/reducers/availablepackages.test.ts
@@ -3,10 +3,13 @@
import {
AvailablePackageDetail,
+ AvailablePackageReference,
AvailablePackageSummary,
Context,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+ GetAvailablePackageSummariesResponse,
+ PackageAppVersion,
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import { getType } from "typesafe-actions";
import actions from "../actions";
import { IPackageState, IReceivePackagesActionPayload } from "../shared/types";
@@ -18,33 +21,33 @@ const currentPageToken = "currentPageToken";
describe("packageReducer", () => {
let initialState: IPackageState;
- const availablePackageSummary1: AvailablePackageSummary = {
+ const availablePackageSummary1 = new AvailablePackageSummary({
name: "foo",
categories: [""],
displayName: "foo",
iconUrl: "",
- latestVersion: { appVersion: "v1.0.0", pkgVersion: "" },
+ latestVersion: new PackageAppVersion({ appVersion: "v1.0.0", pkgVersion: "" }),
shortDescription: "",
- availablePackageRef: {
+ availablePackageRef: new AvailablePackageReference({
identifier: "foo/foo",
context: { cluster: "", namespace: "package-namespace" } as Context,
plugin: { name: "my.plugin", version: "0.0.1" } as Plugin,
- },
- };
+ }),
+ });
- const availablePackageSummary2: AvailablePackageSummary = {
+ const availablePackageSummary2 = new AvailablePackageSummary({
name: "bar",
categories: ["Database"],
displayName: "bar",
iconUrl: "",
- latestVersion: { appVersion: "v2.0.0", pkgVersion: "" },
+ latestVersion: new PackageAppVersion({ appVersion: "v2.0.0", pkgVersion: "" }),
shortDescription: "",
- availablePackageRef: {
+ availablePackageRef: new AvailablePackageReference({
identifier: "bar/bar",
context: { cluster: "", namespace: "package-namespace" } as Context,
plugin: { name: "my.plugin", version: "0.0.1" } as Plugin,
- },
- };
+ }),
+ });
beforeEach(() => {
initialState = {
@@ -432,11 +435,11 @@ describe("packageReducer", () => {
const state2 = packageReducer(state1, {
type: getType(actions.availablepackages.receiveAvailablePackageSummaries) as any,
payload: {
- response: {
+ response: new GetAvailablePackageSummariesResponse({
availablePackageSummaries: [],
nextPageToken,
categories: ["foo"],
- },
+ }),
paginationToken: currentPageToken,
} as IReceivePackagesActionPayload,
});
@@ -525,12 +528,12 @@ describe("packageReducer", () => {
const state = packageReducer(initialState, {
type: getType(actions.availablepackages.receiveSelectedAvailablePackageDetail) as any,
payload: {
- selectedPackage: {
+ selectedPackage: new AvailablePackageDetail({
...packageDetail,
additionalDefaultValues: {
"values-custom": "custom: values",
},
- } as AvailablePackageDetail,
+ }),
},
});
@@ -541,13 +544,13 @@ describe("packageReducer", () => {
const state = packageReducer(initialState, {
type: getType(actions.availablepackages.receiveSelectedAvailablePackageDetail) as any,
payload: {
- selectedPackage: {
+ selectedPackage: new AvailablePackageDetail({
...packageDetail,
additionalDefaultValues: {
"values-custom": "custom: values",
"values-other": "more: customdefaultvalues",
},
- } as AvailablePackageDetail,
+ }),
},
});
@@ -561,13 +564,13 @@ describe("packageReducer", () => {
...initialState,
selected: {
...initialState.selected,
- availablePackageDetail: {
+ availablePackageDetail: new AvailablePackageDetail({
...initialState.selected.availablePackageDetail!,
additionalDefaultValues: {
"values-custom": "custom: values",
"values-other": "more: customdefaultvalues",
},
- },
+ }),
values: "default: values",
},
};
@@ -603,12 +606,12 @@ describe("defaultValues", () => {
it("returns a custom default file when there is exactly one custom default in the pkg", () => {
const result = defaultValues(
- {
+ new AvailablePackageDetail({
...packageDetail,
additionalDefaultValues: {
"values-custom": "custom: values",
},
- },
+ }),
"other-default",
);
@@ -617,13 +620,13 @@ describe("defaultValues", () => {
it("returns the default file when there is more than one custom default in the pkg", () => {
const result = defaultValues(
- {
+ new AvailablePackageDetail({
...packageDetail,
additionalDefaultValues: {
"values-custom": "custom: values",
"other-custom": "other: values",
},
- },
+ }),
"other-default",
);
@@ -632,13 +635,13 @@ describe("defaultValues", () => {
it("returns the specific custom default file when specified", () => {
const result = defaultValues(
- {
+ new AvailablePackageDetail({
...packageDetail,
additionalDefaultValues: {
"values-custom": "custom: values",
"other-custom": "other: values",
},
- },
+ }),
"other-custom",
);
diff --git a/dashboard/src/reducers/availablepackages.ts b/dashboard/src/reducers/availablepackages.ts
index 5001652f966..723f10d311e 100644
--- a/dashboard/src/reducers/availablepackages.ts
+++ b/dashboard/src/reducers/availablepackages.ts
@@ -8,7 +8,7 @@ import { getType } from "typesafe-actions";
import actions from "../actions";
import { PackagesAction } from "../actions/availablepackages";
import { NamespaceAction } from "../actions/namespace";
-import { AvailablePackageDetail } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import { AvailablePackageDetail } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
export const initialState: IPackageState = {
isFetching: false,
diff --git a/dashboard/src/reducers/installedpackages.ts b/dashboard/src/reducers/installedpackages.ts
index 3ed5b25ead8..b0692928fae 100644
--- a/dashboard/src/reducers/installedpackages.ts
+++ b/dashboard/src/reducers/installedpackages.ts
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
import { LocationChangeAction, LOCATION_CHANGE } from "connected-react-router";
-import { InstalledPackageDetailCustomDataHelm } from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm";
-import { IInstalledPackageState } from "shared/types";
+import { InstalledPackageDetailCustomDataHelm } from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm_pb";
+import { CustomInstalledPackageDetail, IInstalledPackageState } from "shared/types";
import { getType } from "typesafe-actions";
import actions from "../actions";
import { InstalledPackagesAction } from "../actions/installedpackages";
@@ -33,9 +33,8 @@ const installedPackagesReducer = (
case getType(actions.installedpackages.selectInstalledPackage): {
let revision: number;
try {
- // TODO(agamez): verify why the field is not automatically decoded.
- revision = InstalledPackageDetailCustomDataHelm.decode(
- action.payload.pkg?.customDetail?.value as unknown as Uint8Array,
+ revision = InstalledPackageDetailCustomDataHelm.fromBinary(
+ action.payload.pkg!.customDetail!.value,
).releaseRevision;
} catch (error) {
// If the decoding fails, ignore it and just fall back to "no revisions"
@@ -48,7 +47,7 @@ const installedPackagesReducer = (
...action.payload.pkg,
// TODO(agamez): remove it once we have a core mechanism for rolling back
revision: revision,
- },
+ } as CustomInstalledPackageDetail,
selectedDetails: action.payload.details,
};
}
@@ -60,7 +59,7 @@ const installedPackagesReducer = (
...state.selected!,
revision: state.selected!.revision,
status: action.payload,
- },
+ } as CustomInstalledPackageDetail,
};
}
return state;
diff --git a/dashboard/src/reducers/kube.test.ts b/dashboard/src/reducers/kube.test.ts
index 2d3bc27d9a1..bbcc046a505 100644
--- a/dashboard/src/reducers/kube.test.ts
+++ b/dashboard/src/reducers/kube.test.ts
@@ -5,11 +5,6 @@ import { IKubeState, IResource } from "shared/types";
import { getType } from "typesafe-actions";
import actions from "../actions";
import kubeReducer, { initialKinds } from "./kube";
-import {
- Context,
- InstalledPackageReference,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
-import { Kube } from "shared/Kube";
describe("kubeReducer", () => {
let initialState: IKubeState;
@@ -88,69 +83,5 @@ describe("kubeReducer", () => {
});
});
});
-
- describe("requestResources", () => {
- // Ensure our shared/Kube helper is not calling out on the network.
- jest.mock("shared/Kube");
-
- const subscribe = jest.fn(() => true);
-
- beforeEach(() => {
- const observable = {
- subscribe,
- };
- Kube.getResources = jest.fn(() => observable as any);
- });
-
- afterEach(() => {
- jest.resetAllMocks();
- });
-
- const pkg = {
- context: {
- cluster: "default",
- namespace: "test",
- } as Context,
- identifier: "test-pkg",
- } as InstalledPackageReference;
- const key = `${pkg.context?.cluster}/${pkg.context?.namespace}/${pkg.identifier}`;
-
- const defaultPayload = {
- pkg,
- refs: [],
- watch: false,
- handler: jest.fn(),
- onError: jest.fn(),
- onComplete: jest.fn(),
- };
-
- it("adds a new subscription to the state when watching the requested package", () => {
- const newState = kubeReducer(undefined, {
- type: getType(actions.kube.requestResources),
- payload: {
- ...defaultPayload,
- watch: true,
- },
- });
-
- expect(Kube.getResources).toBeCalledWith(pkg, [], true);
- expect(subscribe).toHaveBeenCalled();
- expect(newState.subscriptions[key]).toBeDefined();
- });
-
- it("does not add a new subscription to the state when getting the requested package", () => {
- const newState = kubeReducer(undefined, {
- type: getType(actions.kube.requestResources),
- payload: {
- ...defaultPayload,
- watch: false,
- },
- });
-
- expect(Kube.getResources).toBeCalledWith(pkg, [], false);
- expect(subscribe).toHaveBeenCalled();
- expect(newState.subscriptions[key]).toBeUndefined();
- });
- });
});
});
diff --git a/dashboard/src/reducers/kube.ts b/dashboard/src/reducers/kube.ts
index 6abef79a0da..00974d07e9d 100644
--- a/dashboard/src/reducers/kube.ts
+++ b/dashboard/src/reducers/kube.ts
@@ -153,32 +153,23 @@ const kubeReducer = (
return { ...state, items: { ...state.items, ...erroredItem } };
}
case getType(actions.kube.requestResources): {
- const { pkg, refs, handler, watch, onError, onComplete } = action.payload;
- const observable = Kube.getResources(pkg, refs, watch);
- const subscription = observable.subscribe({
- next(r) {
- handler(r);
- },
- error(e) {
- onError(e);
- },
- complete() {
- onComplete();
- },
- });
- // We only record the subscription if watching the result, since otherwise
- // the call is terminated by the server automatically once results are
- // returned and we don't need any book-keeping.
- if (watch) {
- const key = `${pkg.context?.cluster}/${pkg.context?.namespace}/${pkg.identifier}`;
- return {
- ...state,
- subscriptions: {
- ...state.subscriptions,
- [key]: subscription,
- },
- };
- }
+ const { pkg, refs, handler, watch } = action.payload;
+ const asyncResponses = Kube.getResources(pkg, refs, watch);
+
+ // With the change from improbable's grpc-web, which used a subscription
+ // to the connect grpc-web, which uses an async iterator, we'll no longer
+ // need to handle neither the subscription state nor the errors.
+ // TODO(absoludity): Remove the subscription state as well as the extra
+ // args passed in for error handling and completion.
+ // Existing tests only tested the subscription state, so add tests for the actual
+ // content state (of responses).
+ const processResponses = async () => {
+ for await (const response of asyncResponses) {
+ handler(response);
+ }
+ };
+ processResponses();
+
return state;
}
case getType(actions.kube.closeRequestResources): {
diff --git a/dashboard/src/reducers/repos.test.ts b/dashboard/src/reducers/repos.test.ts
index 79076411ade..f724ac9cda5 100644
--- a/dashboard/src/reducers/repos.test.ts
+++ b/dashboard/src/reducers/repos.test.ts
@@ -5,13 +5,13 @@ import {
PackageRepositoriesPermissions,
PackageRepositoryDetail,
PackageRepositorySummary,
-} from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
+} from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
import { getType } from "typesafe-actions";
import actions from "../actions";
import reposReducer, { IPackageRepositoryState } from "./repos";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import { PluginNames } from "shared/types";
-import { Context } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import { Context } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
describe("reposReducer", () => {
let initialState: IPackageRepositoryState;
@@ -72,7 +72,7 @@ describe("reposReducer", () => {
});
it("unsets isFetching and receive repo", () => {
- const repoDetail = { name: "foo" } as PackageRepositoryDetail;
+ const repoDetail = new PackageRepositoryDetail({ name: "foo" });
const state = reposReducer(undefined, {
type: actionTypes.requestRepos,
payload: "",
@@ -124,17 +124,17 @@ describe("reposReducer", () => {
});
it("updates a repo", () => {
- const repoSummary = {
+ const repoSummary = new PackageRepositorySummary({
name: "foo",
url: "foo",
packageRepoRef: { context: { namespace: "ns" } },
- } as PackageRepositorySummary;
+ });
expect(
reposReducer(
{ ...initialState, reposSummaries: [repoSummary] },
{
type: actionTypes.repoUpdated,
- payload: { ...repoSummary, url: "bar" },
+ payload: new PackageRepositorySummary({ ...repoSummary, url: "bar" }),
},
),
).toEqual({
@@ -146,7 +146,7 @@ describe("reposReducer", () => {
it("unsets isFetching and receive repos permissions", () => {
const plugin = { name: PluginNames.PACKAGES_HELM, version: "0.0.1" } as Plugin;
const reposPermissions = [
- {
+ new PackageRepositoriesPermissions({
plugin: plugin,
global: {
create: true,
@@ -160,7 +160,7 @@ describe("reposReducer", () => {
list: true,
update: true,
},
- },
+ }),
] as PackageRepositoriesPermissions[];
const state = reposReducer(undefined, {
type: actionTypes.requestReposPermissions,
diff --git a/dashboard/src/reducers/repos.ts b/dashboard/src/reducers/repos.ts
index ef3f9dae040..723a6109865 100644
--- a/dashboard/src/reducers/repos.ts
+++ b/dashboard/src/reducers/repos.ts
@@ -6,13 +6,13 @@ import {
PackageRepositoriesPermissions,
PackageRepositoryDetail,
PackageRepositorySummary,
-} from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
-import { FluxPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/fluxv2/packages/v1alpha1/fluxv2";
-import { HelmPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm";
+} from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
+import { FluxPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/fluxv2/packages/v1alpha1/fluxv2_pb";
+import { HelmPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm_pb";
import {
KappControllerPackageRepositoryCustomDetail,
PackageRepositoryFetch,
-} from "gen/kubeappsapis/plugins/kapp_controller/packages/v1alpha1/kapp_controller";
+} from "gen/kubeappsapis/plugins/kapp_controller/packages/v1alpha1/kapp_controller_pb";
import { PluginNames } from "shared/types";
import { getType } from "typesafe-actions";
import actions from "../actions";
@@ -39,9 +39,12 @@ export const initialState: IPackageRepositoryState = {
reposPermissions: [] as PackageRepositoriesPermissions[],
};
-const helmPackageRepositoryCustomDetail = {
+const helmPackageRepositoryCustomDetail = new HelmPackageRepositoryCustomDetail({
imagesPullSecret: {
- secretRef: "",
+ dockerRegistryCredentialOneOf: {
+ case: "secretRef",
+ value: "",
+ },
},
ociRepositories: [],
performValidation: false,
@@ -56,7 +59,7 @@ const helmPackageRepositoryCustomDetail = {
httpsProxy: "",
noProxy: "",
},
-} as HelmPackageRepositoryCustomDetail;
+});
const kappPackageRepositoryCustomDetail = {
fetch: {} as PackageRepositoryFetch,
@@ -88,9 +91,7 @@ const reposReducer = (
case PluginNames.PACKAGES_HELM:
customDetail = helmPackageRepositoryCustomDetail;
try {
- customDetail = HelmPackageRepositoryCustomDetail.decode(
- action.payload.customDetail.value,
- );
+ customDetail = action.payload.customDetail.value;
repoWithCustomDetail = { ...action.payload, customDetail };
} catch (error) {
repoWithCustomDetail = { ...action.payload };
@@ -99,9 +100,7 @@ const reposReducer = (
case PluginNames.PACKAGES_KAPP:
customDetail = kappPackageRepositoryCustomDetail;
try {
- customDetail = KappControllerPackageRepositoryCustomDetail.decode(
- action.payload.customDetail.value,
- );
+ customDetail = action.payload.customDetail.value;
repoWithCustomDetail = { ...action.payload, customDetail };
} catch (error) {
repoWithCustomDetail = { ...action.payload };
@@ -110,9 +109,7 @@ const reposReducer = (
case PluginNames.PACKAGES_FLUX:
customDetail = fluxPackageRepositoryCustomDetail;
try {
- customDetail = FluxPackageRepositoryCustomDetail.decode(
- action.payload.customDetail.value,
- );
+ customDetail = action.payload.customDetail.value;
repoWithCustomDetail = { ...action.payload, customDetail };
} catch (error) {
repoWithCustomDetail = { ...action.payload };
@@ -126,7 +123,7 @@ const reposReducer = (
return {
...state,
isFetching: false,
- repoDetail: repoWithCustomDetail,
+ repoDetail: new PackageRepositoryDetail(repoWithCustomDetail),
errors: {},
};
}
diff --git a/dashboard/src/shared/Auth.test.ts b/dashboard/src/shared/Auth.test.ts
index f18572b89c6..d5d3ff6d735 100644
--- a/dashboard/src/shared/Auth.test.ts
+++ b/dashboard/src/shared/Auth.test.ts
@@ -1,9 +1,9 @@
// Copyright 2019-2022 the Kubeapps contributors.
// SPDX-License-Identifier: Apache-2.0
-import { grpc } from "@improbable-eng/grpc-web";
+import { Code } from "@bufbuild/connect";
import { AxiosResponse } from "axios";
-import { CheckNamespaceExistsRequest } from "gen/kubeappsapis/plugins/resources/v1alpha1/resources";
+import { CheckNamespaceExistsResponse } from "gen/kubeappsapis/plugins/resources/v1alpha1/resources_pb";
import jwt from "jsonwebtoken";
import { Auth } from "./Auth";
import { SupportedThemes } from "./Config";
@@ -13,13 +13,15 @@ import { initialState } from "./specs/mountWrapper";
describe("Auth", () => {
// Create a real client, but we'll stub out the function we're interested in.
const client = new KubeappsGrpcClient().getResourcesServiceClientImpl();
- let mockClientCheckNamespaceExists: jest.MockedFunction;
+ let mockClientCheckNamespaceExists: jest.MockedFunction;
beforeEach(() => {
mockClientCheckNamespaceExists = jest
.fn()
- .mockImplementation(() => Promise.resolve({ exists: true } as CheckNamespaceExistsRequest));
- jest.spyOn(client, "CheckNamespaceExists").mockImplementation(mockClientCheckNamespaceExists);
+ .mockImplementation(() =>
+ Promise.resolve(new CheckNamespaceExistsResponse({ exists: true })),
+ );
+ jest.spyOn(client, "checkNamespaceExists").mockImplementation(mockClientCheckNamespaceExists);
jest.spyOn(Auth, "resourcesServiceClient").mockImplementation(() => client);
});
afterEach(() => {
@@ -41,8 +43,8 @@ describe("Auth", () => {
it("should return without error when the endpoint returns PermissionDenied with the given token", async () => {
mockClientCheckNamespaceExists = jest
.fn()
- .mockImplementation(() => Promise.reject({ code: grpc.Code.PermissionDenied }));
- jest.spyOn(client, "CheckNamespaceExists").mockImplementation(mockClientCheckNamespaceExists);
+ .mockImplementation(() => Promise.reject({ code: Code.PermissionDenied }));
+ jest.spyOn(client, "checkNamespaceExists").mockImplementation(mockClientCheckNamespaceExists);
await Auth.validateToken("othercluster", "foo");
expect(Auth.resourcesServiceClient).toHaveBeenCalledWith("foo");
@@ -59,17 +61,17 @@ describe("Auth", () => {
{
name: "should throw an invalid token error for 401 responses",
response: { status: 401, data: "ignored anyway" },
- grpcCode: grpc.Code.Unauthenticated,
+ grpcCode: Code.Unauthenticated,
expectedError: new Error("invalid token"),
},
{
name: "should throw a standard error for a 404 response",
- grpcCode: grpc.Code.NotFound,
+ grpcCode: Code.NotFound,
expectedError: new Error("not found"),
},
{
name: "should throw a standard error for a 500 response",
- grpcCode: grpc.Code.Internal,
+ grpcCode: Code.Internal,
expectedError: new Error("internal error"),
},
].forEach(testCase => {
@@ -78,7 +80,7 @@ describe("Auth", () => {
.fn()
.mockImplementation(() => Promise.reject({ code: testCase.grpcCode }));
jest
- .spyOn(client, "CheckNamespaceExists")
+ .spyOn(client, "checkNamespaceExists")
.mockImplementation(mockClientCheckNamespaceExists);
await expect(Auth.validateToken("default", "foo")).rejects.toThrow(testCase.expectedError);
@@ -103,15 +105,13 @@ describe("Auth", () => {
it("returns false if the request results in a non-grpc-web response", async () => {
mockClientCheckNamespaceExists = jest.fn().mockImplementation(() =>
Promise.reject({
- code: grpc.Code.PermissionDenied,
- metadata: {
- headersMap: {
- "content-type": ["not-grpc-content-type"],
- },
- },
+ code: Code.PermissionDenied,
+ metadata: new Headers({
+ "content-type": "not-grpc-content-type",
+ }),
}),
);
- jest.spyOn(client, "CheckNamespaceExists").mockImplementation(mockClientCheckNamespaceExists);
+ jest.spyOn(client, "checkNamespaceExists").mockImplementation(mockClientCheckNamespaceExists);
const isAuthed = await Auth.isAuthenticatedWithCookie("somecluster");
@@ -121,15 +121,13 @@ describe("Auth", () => {
it("returns true if the request to api root results in a 403", async () => {
mockClientCheckNamespaceExists = jest.fn().mockImplementation(() =>
Promise.reject({
- code: grpc.Code.PermissionDenied,
- metadata: {
- headersMap: {
- "content-type": ["application/grpc-web+proto"],
- },
- },
+ code: Code.PermissionDenied,
+ metadata: new Headers({
+ "content-type": "application/grpc-web+proto",
+ }),
}),
);
- jest.spyOn(client, "CheckNamespaceExists").mockImplementation(mockClientCheckNamespaceExists);
+ jest.spyOn(client, "checkNamespaceExists").mockImplementation(mockClientCheckNamespaceExists);
const isAuthed = await Auth.isAuthenticatedWithCookie("somecluster");
@@ -139,15 +137,13 @@ describe("Auth", () => {
it("returns true if the request to api root results in a 403 with another grpc protocol", async () => {
mockClientCheckNamespaceExists = jest.fn().mockImplementation(() =>
Promise.reject({
- code: grpc.Code.PermissionDenied,
- metadata: {
- headersMap: {
- "content-type": ["application/grpc-web+thrift"],
- },
- },
+ code: Code.PermissionDenied,
+ metadata: new Headers({
+ "content-type": "application/grpc-web+thrift",
+ }),
}),
);
- jest.spyOn(client, "CheckNamespaceExists").mockImplementation(mockClientCheckNamespaceExists);
+ jest.spyOn(client, "checkNamespaceExists").mockImplementation(mockClientCheckNamespaceExists);
const isAuthed = await Auth.isAuthenticatedWithCookie("somecluster");
@@ -156,15 +152,13 @@ describe("Auth", () => {
it("returns false if the request results in a 401", async () => {
mockClientCheckNamespaceExists = jest.fn().mockImplementation(() =>
Promise.reject({
- code: grpc.Code.Unauthenticated,
- metadata: {
- headersMap: {
- "content-type": ["not-grpc-content-type"],
- },
- },
+ code: Code.Unauthenticated,
+ metadata: new Headers({
+ "content-type": "not-grpc-content-type",
+ }),
}),
);
- jest.spyOn(client, "CheckNamespaceExists").mockImplementation(mockClientCheckNamespaceExists);
+ jest.spyOn(client, "checkNamespaceExists").mockImplementation(mockClientCheckNamespaceExists);
const isAuthed = await Auth.isAuthenticatedWithCookie("somecluster");
diff --git a/dashboard/src/shared/Auth.ts b/dashboard/src/shared/Auth.ts
index c508be0a63f..8db76a1436e 100644
--- a/dashboard/src/shared/Auth.ts
+++ b/dashboard/src/shared/Auth.ts
@@ -1,7 +1,7 @@
// Copyright 2018-2022 the Kubeapps contributors.
// SPDX-License-Identifier: Apache-2.0
-import { grpc } from "@improbable-eng/grpc-web";
+import { Code } from "@bufbuild/connect";
import { AxiosResponse } from "axios";
import jwt from "jsonwebtoken";
import { get } from "lodash";
@@ -17,7 +17,7 @@ const AuthTokenOIDCKey = "kubeapps_auth_token_oidc";
export class Auth {
public static resourcesServiceClient = (token?: string) =>
- new KubeappsGrpcClient().getResourcesServiceClientImpl(token);
+ new KubeappsGrpcClient(token).getResourcesServiceClientImpl();
public static getAuthToken() {
return localStorage.getItem(AuthTokenKey);
@@ -73,11 +73,11 @@ export class Auth {
// Throws an error if the token is invalid
public static async validateToken(cluster: string, token: string) {
try {
- await this.resourcesServiceClient(token).CheckNamespaceExists({
+ await this.resourcesServiceClient(token).checkNamespaceExists({
context: { cluster, namespace: "default" },
});
} catch (e: any) {
- if (e.code === grpc.Code.Unauthenticated) {
+ if (e.code === Code.Unauthenticated) {
throw new UnauthorizedNetworkError("invalid token");
}
// https://kubernetes.io/docs/reference/access-authn-authz/authentication/#anonymous-requests
@@ -86,11 +86,11 @@ export class Auth {
// don't make any assumptions over RBAC for the requested namespace or
// other required authz permissions until operations on those resources
// are attempted (though we may want to revisit this in the future).
- if (e.code !== grpc.Code.PermissionDenied) {
- if (e.code === grpc.Code.NotFound) {
+ if (e.code !== Code.PermissionDenied) {
+ if (e.code === Code.NotFound) {
throw new NotFoundNetworkError("not found");
}
- if (e.code === grpc.Code.Internal) {
+ if (e.code === Code.Internal) {
throw new InternalServerNetworkError("internal error");
}
throw new InternalServerNetworkError(`${e.code}: ${e.message}`);
@@ -101,8 +101,8 @@ export class Auth {
// isErrorFromAPIsServer returns true if the response is a 403 determined to have originated
// from the grpc-web APIs server, rather than the auth proxy.
public static isErrorFromAPIsServer(e: any): boolean {
- const contentType = e.metadata?.headersMap["content-type"] as string[];
- if (contentType.some(v => v.startsWith("application/grpc-web"))) {
+ const contentType = (e.metadata?.get("content-type") || "") as string;
+ if (contentType.startsWith("application/grpc-web")) {
return true;
}
return false;
@@ -151,14 +151,14 @@ export class Auth {
// it could potentially return a false positive.
public static async isAuthenticatedWithCookie(cluster: string): Promise {
try {
- await this.resourcesServiceClient().CheckNamespaceExists({
+ await this.resourcesServiceClient().checkNamespaceExists({
context: { cluster, namespace: "default" },
});
} catch (e: any) {
// The only error response which can possibly mean we did authenticate is
// a 403 from the k8s api server (ie. we got through to k8s api server
// but RBAC doesn't authorize us).
- if (e.code !== grpc.Code.PermissionDenied) {
+ if (e.code !== Code.PermissionDenied) {
return false;
}
diff --git a/dashboard/src/shared/Config.ts b/dashboard/src/shared/Config.ts
index 8c01835f404..be0d9775b66 100644
--- a/dashboard/src/shared/Config.ts
+++ b/dashboard/src/shared/Config.ts
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import axios from "axios";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import * as url from "shared/url";
import { PackageRepositoriesService } from "./PackageRepositoriesService";
diff --git a/dashboard/src/shared/InstalledPackage.test.ts b/dashboard/src/shared/InstalledPackage.test.ts
index 544b3fe06da..195a159218d 100644
--- a/dashboard/src/shared/InstalledPackage.test.ts
+++ b/dashboard/src/shared/InstalledPackage.test.ts
@@ -10,9 +10,9 @@ import {
InstalledPackageReference,
UpdateInstalledPackageResponse,
VersionReference,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
-import { RollbackInstalledPackageResponse } from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm";
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
+import { RollbackInstalledPackageResponse } from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm_pb";
import { InstalledPackage } from "./InstalledPackage";
import { KubeappsGrpcClient } from "./KubeappsGrpcClient";
import { PluginNames } from "./types";
@@ -46,7 +46,7 @@ describe("InstalledPackage", () => {
} as InstalledPackageReference,
} as CreateInstalledPackageResponse),
);
- setMockCoreClient("CreateInstalledPackage", mockCreateInstalledPackage);
+ setMockCoreClient("createInstalledPackage", mockCreateInstalledPackage);
const availablePackageSummaries = await InstalledPackage.CreateInstalledPackage(
t.args.targetContext,
@@ -94,7 +94,7 @@ describe("InstalledPackage", () => {
} as InstalledPackageReference,
} as UpdateInstalledPackageResponse),
);
- setMockCoreClient("UpdateInstalledPackage", mockUpdateInstalledPackage);
+ setMockCoreClient("updateInstalledPackage", mockUpdateInstalledPackage);
const availablePackageSummaries = await InstalledPackage.UpdateInstalledPackage(
t.args.installedPackageRef,
@@ -160,7 +160,7 @@ describe("InstalledPackage", () => {
const mockRollbackInstalledPackage = jest
.fn()
.mockImplementation(() => Promise.resolve({} as RollbackInstalledPackageResponse));
- setMockHelmClient("RollbackInstalledPackage", mockRollbackInstalledPackage);
+ setMockHelmClient("rollbackInstalledPackage", mockRollbackInstalledPackage);
const res = await InstalledPackage.RollbackInstalledPackage(
t.args.installedPackageRef,
@@ -186,7 +186,7 @@ describe("InstalledPackage", () => {
.mockImplementation(() => Promise.resolve({} as GetInstalledPackageResourceRefsResponse));
setMockCoreClient(
- "GetInstalledPackageResourceRefs",
+ "getInstalledPackageResourceRefs",
mockClientGetInstalledPackageResourceRefs,
);
diff --git a/dashboard/src/shared/InstalledPackage.ts b/dashboard/src/shared/InstalledPackage.ts
index 953b0c3bd93..11633c06c7b 100644
--- a/dashboard/src/shared/InstalledPackage.ts
+++ b/dashboard/src/shared/InstalledPackage.ts
@@ -10,11 +10,11 @@ import {
ReconciliationOptions,
UpdateInstalledPackageRequest,
VersionReference,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import {
RollbackInstalledPackageRequest,
RollbackInstalledPackageResponse,
-} from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm";
+} from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm_pb";
import { KubeappsGrpcClient } from "./KubeappsGrpcClient";
import { convertGrpcAuthError, getPluginsSupportingRollback } from "./utils";
@@ -31,7 +31,7 @@ export class InstalledPackage {
size?: number,
) {
return await this.packagesServiceClient()
- .GetInstalledPackageSummaries({
+ .getInstalledPackageSummaries({
context: { cluster: cluster, namespace: namespace },
paginationOptions: { pageSize: size || 0, pageToken: pageToken || "" },
})
@@ -42,7 +42,7 @@ export class InstalledPackage {
public static async GetInstalledPackageDetail(installedPackageRef?: InstalledPackageReference) {
return await this.packagesServiceClient()
- .GetInstalledPackageDetail({
+ .getInstalledPackageDetail({
installedPackageRef: installedPackageRef,
})
.catch((e: any) => {
@@ -54,7 +54,7 @@ export class InstalledPackage {
installedPackageRef?: InstalledPackageReference,
) {
return await this.packagesServiceClient()
- .GetInstalledPackageResourceRefs({ installedPackageRef })
+ .getInstalledPackageResourceRefs({ installedPackageRef })
.catch((e: any) => {
throw convertGrpcAuthError(e);
});
@@ -69,7 +69,7 @@ export class InstalledPackage {
reconciliationOptions?: ReconciliationOptions,
) {
return await this.packagesServiceClient()
- .CreateInstalledPackage({
+ .createInstalledPackage({
name,
values,
targetContext,
@@ -89,7 +89,7 @@ export class InstalledPackage {
reconciliationOptions?: ReconciliationOptions,
) {
return await this.packagesServiceClient()
- .UpdateInstalledPackage({
+ .updateInstalledPackage({
installedPackageRef,
pkgVersionReference,
values,
@@ -110,7 +110,7 @@ export class InstalledPackage {
getPluginsSupportingRollback().includes(installedPackageRef.plugin.name)
) {
return await this.helmPackagesServiceClient()
- .RollbackInstalledPackage({
+ .rollbackInstalledPackage({
installedPackageRef,
releaseRevision,
} as RollbackInstalledPackageRequest)
@@ -124,7 +124,7 @@ export class InstalledPackage {
public static async DeleteInstalledPackage(installedPackageRef: InstalledPackageReference) {
return await this.packagesServiceClient()
- .DeleteInstalledPackage({
+ .deleteInstalledPackage({
installedPackageRef,
} as DeleteInstalledPackageRequest)
.catch((e: any) => {
diff --git a/dashboard/src/shared/Kube.test.ts b/dashboard/src/shared/Kube.test.ts
index a5d479112c9..6fc3b78c8ae 100644
--- a/dashboard/src/shared/Kube.test.ts
+++ b/dashboard/src/shared/Kube.test.ts
@@ -2,7 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
import MockAdapter from "axios-mock-adapter";
-import { CanIRequest, CanIResponse } from "gen/kubeappsapis/plugins/resources/v1alpha1/resources";
+import {
+ CanIRequest,
+ CanIResponse,
+} from "gen/kubeappsapis/plugins/resources/v1alpha1/resources_pb";
import { axiosWithAuth } from "./AxiosInstance";
import { Kube } from "./Kube";
import KubeappsGrpcClient from "./KubeappsGrpcClient";
@@ -152,7 +155,7 @@ describe("Kube", () => {
describe("canI", () => {
// Create a real client, but we'll stub out the function we're interested in.
const client = new KubeappsGrpcClient().getResourcesServiceClientImpl();
- let mockClientCanI: jest.MockedFunction;
+ let mockClientCanI: jest.MockedFunction;
beforeEach(() => {});
afterEach(() => {
@@ -163,7 +166,7 @@ describe("Kube", () => {
mockClientCanI = jest
.fn()
.mockImplementation(() => Promise.resolve({ allowed: true } as CanIResponse));
- jest.spyOn(client, "CanI").mockImplementation(mockClientCanI);
+ jest.spyOn(client, "canI").mockImplementation(mockClientCanI);
jest.spyOn(Kube, "resourcesServiceClient").mockImplementation(() => client);
const allowed = await Kube.canI(clusterName, "v1", "namespaces", "create", "");
@@ -192,7 +195,7 @@ describe("Kube", () => {
throw new Error("error");
}),
);
- jest.spyOn(client, "CanI").mockImplementation(mockClientCanI);
+ jest.spyOn(client, "canI").mockImplementation(mockClientCanI);
jest.spyOn(Kube, "resourcesServiceClient").mockImplementation(() => client);
const allowed = await Kube.canI(clusterName, "v1", "secrets", "list", "");
diff --git a/dashboard/src/shared/Kube.ts b/dashboard/src/shared/Kube.ts
index 99a31fcff79..be17049e59d 100644
--- a/dashboard/src/shared/Kube.ts
+++ b/dashboard/src/shared/Kube.ts
@@ -4,11 +4,11 @@
import {
InstalledPackageReference,
ResourceRef,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import {
GetServiceAccountNamesRequest,
GetServiceAccountNamesResponse,
-} from "gen/kubeappsapis/plugins/resources/v1alpha1/resources";
+} from "gen/kubeappsapis/plugins/resources/v1alpha1/resources_pb";
import * as url from "shared/url";
import { axiosWithAuth } from "./AxiosInstance";
import { KubeappsGrpcClient } from "./KubeappsGrpcClient";
@@ -28,7 +28,7 @@ export class Kube {
refs: ResourceRef[],
watch: boolean,
) {
- return this.resourcesServiceClient().GetResources({
+ return this.resourcesServiceClient().getResources({
installedPackageRef: pkgRef,
resourceRefs: refs,
watch,
@@ -82,7 +82,7 @@ export class Kube {
return false;
}
// TODO(rcastelblanq) Migrate the CanI endpoint to a proper RBAC/Auth plugin
- const response = await this.resourcesServiceClient().CanI({
+ const response = await this.resourcesServiceClient().canI({
context: { cluster, namespace },
group: group,
resource: resource,
@@ -99,7 +99,7 @@ export class Kube {
namespace: string,
): Promise {
return await this.resourcesServiceClient()
- .GetServiceAccountNames({
+ .getServiceAccountNames({
context: { cluster, namespace },
} as GetServiceAccountNamesRequest)
.catch((e: any) => {
diff --git a/dashboard/src/shared/KubeappsGrpcClient.test.ts b/dashboard/src/shared/KubeappsGrpcClient.test.ts
index 61d968a8ab3..8b899ce573e 100644
--- a/dashboard/src/shared/KubeappsGrpcClient.test.ts
+++ b/dashboard/src/shared/KubeappsGrpcClient.test.ts
@@ -1,20 +1,16 @@
// Copyright 2021-2022 the Kubeapps contributors.
// SPDX-License-Identifier: Apache-2.0
-import { grpc } from "@improbable-eng/grpc-web";
-import { FakeTransportBuilder } from "@improbable-eng/grpc-web-fake-transport";
import { KubeappsGrpcClient } from "./KubeappsGrpcClient";
describe("kubeapps grpc client creation", () => {
- const fakeEmptyTransport = new FakeTransportBuilder().withMessages([]).build();
-
it("should create a kubeapps grpc client", async () => {
- const kubeappsGrpcClient = new KubeappsGrpcClient(fakeEmptyTransport);
+ const kubeappsGrpcClient = new KubeappsGrpcClient();
expect(kubeappsGrpcClient).not.toBeNull();
});
it("should create the clients for each core service", async () => {
- const kubeappsGrpcClient = new KubeappsGrpcClient(fakeEmptyTransport);
+ const kubeappsGrpcClient = new KubeappsGrpcClient();
const serviceClients = [
kubeappsGrpcClient.getPluginsServiceClientImpl(),
kubeappsGrpcClient.getPackagesServiceClientImpl(),
@@ -25,7 +21,7 @@ describe("kubeapps grpc client creation", () => {
});
it("should create the clients for each plugin service", async () => {
- const kubeappsGrpcClient = new KubeappsGrpcClient(fakeEmptyTransport);
+ const kubeappsGrpcClient = new KubeappsGrpcClient();
const packagesServiceClients = [
kubeappsGrpcClient.getHelmPackagesServiceClientImpl(),
kubeappsGrpcClient.getKappControllerPackagesServiceClientImpl(),
@@ -40,97 +36,3 @@ describe("kubeapps grpc client creation", () => {
repositoriesServiceClients.every(sc => expect(sc).not.toBeNull());
});
});
-
-describe("kubeapps grpc core plugin service", () => {
- afterEach(() => {
- jest.restoreAllMocks();
- });
-
- const fakeErrorransport = new FakeTransportBuilder()
- .withPreTrailersError(grpc.Code.Internal, "boom")
- .build();
- const fakeUnauthenticatedTransport = new FakeTransportBuilder()
- .withPreTrailersError(grpc.Code.Unauthenticated, "you shall not pass")
- .build();
- const fakeAuthTransport = new FakeTransportBuilder()
- .withHeaders(new grpc.Metadata({ authorization: "Bearer topsecret" }))
- .build();
-
- it("it fails when an internal error is thrown", async () => {
- const kubeappsGrpcClient = new KubeappsGrpcClient(fakeErrorransport);
- const getPluginsServiceClientImpl = kubeappsGrpcClient.getPluginsServiceClientImpl();
- const getConfiguredPlugins = getPluginsServiceClientImpl.GetConfiguredPlugins({});
- await expect(getConfiguredPlugins).rejects.toThrowError("boom");
- });
-
- it("it fails when unauthenticated", async () => {
- const kubeappsGrpcClient = new KubeappsGrpcClient(fakeUnauthenticatedTransport);
- const getPluginsServiceClientImpl = kubeappsGrpcClient.getPluginsServiceClientImpl();
- const getConfiguredPlugins = getPluginsServiceClientImpl.GetConfiguredPlugins({});
- await expect(getConfiguredPlugins).rejects.toThrowError("you shall not pass");
- });
-
- it("it set the metadata if using token auth", async () => {
- const kubeappsGrpcClient = new KubeappsGrpcClient(fakeAuthTransport);
- jest.spyOn(window.localStorage.__proto__, "getItem").mockReturnValue("topsecret");
-
- const getClientMetadataMock = jest.spyOn(KubeappsGrpcClient.prototype, "getClientMetadata");
- kubeappsGrpcClient.getPluginsServiceClientImpl();
- const expectedMetadata = new grpc.Metadata({ authorization: "Bearer topsecret" });
- expect(getClientMetadataMock.mock.results[0].value).toEqual(expectedMetadata);
- });
-
- it("it doesn't set the metadata if not using token auth", async () => {
- const kubeappsGrpcClient = new KubeappsGrpcClient(fakeAuthTransport);
- jest.spyOn(window.localStorage.__proto__, "getItem").mockReturnValue(null);
-
- const getClientMetadataMock = jest.spyOn(KubeappsGrpcClient.prototype, "getClientMetadata");
- kubeappsGrpcClient.getPluginsServiceClientImpl();
- expect(getClientMetadataMock.mock.results[0].value).toBeUndefined();
- });
-
- // TODO(agamez): try to also mock the messages using the new FakeTransportBuilder().withMessages([])
- // More details: https://github.com/vmware-tanzu/kubeapps/issues/3165#issuecomment-882944035
-});
-
-describe("kubeapps grpc resources plugin service", () => {
- afterEach(() => {
- jest.restoreAllMocks();
- });
-
- const fakeAuthTransport = new FakeTransportBuilder()
- .withHeaders(new grpc.Metadata({ authorization: "Bearer topsecret" }))
- .build();
-
- it("it set the metadata if using token auth", async () => {
- const kubeappsGrpcClient = new KubeappsGrpcClient(fakeAuthTransport);
- jest.spyOn(window.localStorage.__proto__, "getItem").mockReturnValue("topsecret");
-
- const getClientMetadataMock = jest.spyOn(KubeappsGrpcClient.prototype, "getClientMetadata");
- kubeappsGrpcClient.getResourcesServiceClientImpl();
-
- const expectedMetadata = new grpc.Metadata({ authorization: "Bearer topsecret" });
- expect(getClientMetadataMock.mock.results[0].value).toEqual(expectedMetadata);
- });
-
- it("it doesn't set the metadata if not using token auth", async () => {
- const kubeappsGrpcClient = new KubeappsGrpcClient(fakeAuthTransport);
- jest.spyOn(window.localStorage.__proto__, "getItem").mockReturnValue(null);
- const getClientMetadataMock = jest.spyOn(KubeappsGrpcClient.prototype, "getClientMetadata");
-
- kubeappsGrpcClient.getResourcesServiceClientImpl();
-
- expect(getClientMetadataMock.mock.results[0].value).toBeUndefined();
- });
-
- it("it sets the metadata if passed an explicit token", async () => {
- const kubeappsGrpcClient = new KubeappsGrpcClient(fakeAuthTransport);
- jest.spyOn(window.localStorage.__proto__, "getItem").mockReturnValue(null);
- const getClientMetadataMock = jest.spyOn(KubeappsGrpcClient.prototype, "getClientMetadata");
-
- kubeappsGrpcClient.getResourcesServiceClientImpl("topsecret");
-
- const expectedMetadata = new grpc.Metadata({ authorization: "Bearer topsecret" });
- expect(getClientMetadataMock.mock.results[0].value).toEqual(expectedMetadata);
- });
-});
diff --git a/dashboard/src/shared/KubeappsGrpcClient.ts b/dashboard/src/shared/KubeappsGrpcClient.ts
index 1c7296887e0..8849cd801ac 100644
--- a/dashboard/src/shared/KubeappsGrpcClient.ts
+++ b/dashboard/src/shared/KubeappsGrpcClient.ts
@@ -1,67 +1,68 @@
// Copyright 2021-2022 the Kubeapps contributors.
// SPDX-License-Identifier: Apache-2.0
-
-import { grpc } from "@improbable-eng/grpc-web";
-import { PackagesServiceClientImpl } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
-import { RepositoriesServiceClientImpl } from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
-import { PluginsServiceClientImpl } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
-import {
- FluxV2PackagesServiceClientImpl,
- FluxV2RepositoriesServiceClientImpl,
-} from "gen/kubeappsapis/plugins/fluxv2/packages/v1alpha1/fluxv2";
+import type { ServiceType } from "@bufbuild/protobuf";
+import { createGrpcWebTransport } from "@bufbuild/connect-web";
+import { createPromiseClient, Interceptor, PromiseClient, Transport } from "@bufbuild/connect";
+import { PackagesService } from "gen/kubeappsapis/core/packages/v1alpha1/packages_connect";
+import { RepositoriesService } from "gen/kubeappsapis/core/packages/v1alpha1/repositories_connect";
+import { PluginsService } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_connect";
+import { ResourcesService } from "gen/kubeappsapis/plugins/resources/v1alpha1/resources_connect";
import {
- HelmPackagesServiceClientImpl,
- HelmRepositoriesServiceClientImpl,
-} from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm";
+ HelmPackagesService,
+ HelmRepositoriesService,
+} from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm_connect";
import {
- KappControllerPackagesServiceClientImpl,
- KappControllerRepositoriesServiceClientImpl,
-} from "gen/kubeappsapis/plugins/kapp_controller/packages/v1alpha1/kapp_controller";
+ KappControllerPackagesService,
+ KappControllerRepositoriesService,
+} from "gen/kubeappsapis/plugins/kapp_controller/packages/v1alpha1/kapp_controller_connect";
import {
- GrpcWebImpl,
- ResourcesServiceClientImpl,
-} from "gen/kubeappsapis/plugins/resources/v1alpha1/resources";
+ FluxV2PackagesService,
+ FluxV2RepositoriesService,
+} from "gen/kubeappsapis/plugins/fluxv2/packages/v1alpha1/fluxv2_connect";
+
import { Auth } from "./Auth";
import * as URL from "./url";
export class KubeappsGrpcClient {
- private transport: grpc.TransportFactory;
+ private transport: Transport;
- constructor(transport?: grpc.TransportFactory) {
- this.transport = transport ?? grpc.CrossBrowserHttpTransport({});
+ // Creates a client with a transport, ensuring the transport includes the auth header.
+ constructor(token?: string) {
+ const auth: Interceptor = next => async req => {
+ const t = token ? token : Auth.getAuthToken();
+ if (t) {
+ req.header.set("Authorization", t);
+ }
+ return await next(req);
+ };
+ this.transport = createGrpcWebTransport({
+ baseUrl: `/${URL.api.kubeappsapis}`,
+ interceptors: [auth],
+ });
}
// getClientMetadata, if using token authentication, creates grpc metadata
// and the token in the 'authorization' field
public getClientMetadata(token?: string) {
- if (token) {
- return new grpc.Metadata({ authorization: `Bearer ${token}` });
- }
-
- return Auth.getAuthToken()
- ? new grpc.Metadata({ authorization: `Bearer ${Auth.getAuthToken()}` })
- : undefined;
+ const t = token ? token : Auth.getAuthToken();
+ return t ? new Headers({ Authorization: `Bearer ${t}` }) : undefined;
}
- // getGrpcClient returns a grpc client
- public getGrpcClient = (token?: string) => {
- return new GrpcWebImpl(URL.api.kubeappsapis, {
- transport: this.transport,
- metadata: this.getClientMetadata(token),
- });
+ public getGrpcClient = (service: T): PromiseClient => {
+ return createPromiseClient(service, this.transport);
};
// Core APIs
public getPackagesServiceClientImpl() {
- return new PackagesServiceClientImpl(this.getGrpcClient());
+ return this.getGrpcClient(PackagesService);
}
public getRepositoriesServiceClientImpl() {
- return new RepositoriesServiceClientImpl(this.getGrpcClient());
+ return this.getGrpcClient(RepositoriesService);
}
public getPluginsServiceClientImpl() {
- return new PluginsServiceClientImpl(this.getGrpcClient());
+ return this.getGrpcClient(PluginsService);
}
// Resources API
@@ -69,8 +70,9 @@ export class KubeappsGrpcClient {
// The resources API client implementation takes an optional token
// only because it is used to validate token authentication before
// the token is stored.
- public getResourcesServiceClientImpl(token?: string) {
- return new ResourcesServiceClientImpl(this.getGrpcClient(token));
+ // TODO: investigate the token here.
+ public getResourcesServiceClientImpl() {
+ return this.getGrpcClient(ResourcesService);
}
// Plugins (packages/repositories) APIs
@@ -78,25 +80,25 @@ export class KubeappsGrpcClient {
// Helm
public getHelmPackagesServiceClientImpl() {
- return new HelmPackagesServiceClientImpl(this.getGrpcClient());
+ return this.getGrpcClient(HelmPackagesService);
}
public getHelmRepositoriesServiceClientImpl() {
- return new HelmRepositoriesServiceClientImpl(this.getGrpcClient());
+ return this.getGrpcClient(HelmRepositoriesService);
}
// KappController
public getKappControllerPackagesServiceClientImpl() {
- return new KappControllerPackagesServiceClientImpl(this.getGrpcClient());
+ return this.getGrpcClient(KappControllerPackagesService);
}
public getKappControllerRepositoriesServiceClientImpl() {
- return new KappControllerRepositoriesServiceClientImpl(this.getGrpcClient());
+ return this.getGrpcClient(KappControllerRepositoriesService);
}
// Fluxv2
public getFluxv2PackagesServiceClientImpl() {
- return new FluxV2PackagesServiceClientImpl(this.getGrpcClient());
+ return this.getGrpcClient(FluxV2PackagesService);
}
public getFluxV2RepositoriesServiceClientImpl() {
- return new FluxV2RepositoriesServiceClientImpl(this.getGrpcClient());
+ return this.getGrpcClient(FluxV2RepositoriesService);
}
}
diff --git a/dashboard/src/shared/Namespace.ts b/dashboard/src/shared/Namespace.ts
index 26bda1b2aab..688b26b94ce 100644
--- a/dashboard/src/shared/Namespace.ts
+++ b/dashboard/src/shared/Namespace.ts
@@ -12,7 +12,7 @@ export default class Namespace {
public static async list(cluster: string) {
const { namespaceNames } = await this.resourcesServiceClient()
- .GetNamespaceNames({ cluster: cluster })
+ .getNamespaceNames({ cluster: cluster })
.catch((e: any) => {
throw convertGrpcAuthError(e);
});
@@ -25,7 +25,7 @@ export default class Namespace {
labels: { [key: string]: string },
) {
await this.resourcesServiceClient()
- .CreateNamespace({
+ .createNamespace({
context: {
cluster,
namespace,
@@ -39,7 +39,7 @@ export default class Namespace {
public static async exists(cluster: string, namespace: string) {
const { exists } = await this.resourcesServiceClient()
- .CheckNamespaceExists({
+ .checkNamespaceExists({
context: {
cluster,
namespace,
diff --git a/dashboard/src/shared/PackageRepositoriesService.test.ts b/dashboard/src/shared/PackageRepositoriesService.test.ts
index 303ba6692e1..c417cd9a478 100644
--- a/dashboard/src/shared/PackageRepositoriesService.test.ts
+++ b/dashboard/src/shared/PackageRepositoriesService.test.ts
@@ -11,71 +11,86 @@ import {
PackageRepositoryAuth_PackageRepositoryAuthType,
PackageRepositoryReference,
UpdatePackageRepositoryResponse,
-} from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
-import { HelmPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm";
-import { KappControllerPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/kapp_controller/packages/v1alpha1/kapp_controller";
+} from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
+import { Context } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
+import {
+ HelmPackageRepositoryCustomDetail,
+ ImagesPullSecret,
+ PodSecurityContext,
+ ProxyOptions,
+ RepositoryFilterRule,
+} from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm_pb";
+import {
+ KappControllerPackageRepositoryCustomDetail,
+ PackageRepositoryFetch,
+ PackageRepositoryImgpkg,
+ VersionSelection,
+ VersionSelectionSemver,
+ VersionSelectionSemverPrereleases,
+} from "gen/kubeappsapis/plugins/kapp_controller/packages/v1alpha1/kapp_controller_pb";
import KubeappsGrpcClient from "./KubeappsGrpcClient";
import { PackageRepositoriesService } from "./PackageRepositoriesService";
import { IPkgRepoFormData, PluginNames, RepositoryStorageTypes } from "./types";
const cluster = "cluster";
const namespace = "namespace";
-const plugin: Plugin = { name: "my.plugin", version: "0.0.1" };
+const plugin: Plugin = new Plugin({ name: "my.plugin", version: "0.0.1" });
-const helmCustomDetail: HelmPackageRepositoryCustomDetail = {
- imagesPullSecret: {
- secretRef: "test-1",
- credentials: undefined,
- },
+const helmCustomDetail: HelmPackageRepositoryCustomDetail = new HelmPackageRepositoryCustomDetail({
+ imagesPullSecret: new ImagesPullSecret({
+ dockerRegistryCredentialOneOf: {
+ case: "secretRef",
+ value: "test-1",
+ },
+ }),
ociRepositories: ["apache", "jenkins"],
performValidation: true,
- filterRule: {
+ filterRule: new RepositoryFilterRule({
jq: ".name == $var0 or .name == $var1",
variables: { $var0: "nginx", $var1: "wordpress" },
- },
- proxyOptions: {
+ }),
+ proxyOptions: new ProxyOptions({
enabled: true,
httpProxy: "http://proxy",
httpsProxy: "https://proxy",
noProxy: "localhost",
- },
+ }),
// these options are not used by the UI
tolerations: [],
nodeSelector: {},
- securityContext: {
+ securityContext: new PodSecurityContext({
supplementalGroups: [],
fSGroup: undefined,
runAsGroup: undefined,
runAsNonRoot: undefined,
runAsUser: undefined,
- },
-};
+ }),
+});
-const kappCustomDetail: KappControllerPackageRepositoryCustomDetail = {
- fetch: {
- imgpkgBundle: {
- tagSelection: {
- semver: {
+const kappCustomDetail = new KappControllerPackageRepositoryCustomDetail({
+ fetch: new PackageRepositoryFetch({
+ imgpkgBundle: new PackageRepositoryImgpkg({
+ tagSelection: new VersionSelection({
+ semver: new VersionSelectionSemver({
constraints: ">= 1.0.0",
- prereleases: {
+ prereleases: new VersionSelectionSemverPrereleases({
identifiers: ["alpha", "beta"],
- },
- },
- },
- },
+ }),
+ }),
+ }),
+ }),
git: undefined,
http: undefined,
image: undefined,
inline: undefined,
- },
-};
+ }),
+});
const pkgRepoFormData = {
plugin,
authHeader: "",
- authMethod:
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED,
+ authMethod: PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED,
basicAuth: {
password: "",
username: "",
@@ -132,13 +147,15 @@ describe("RepositoriesService", () => {
],
} as GetPackageRepositorySummariesResponse),
);
- setMockCoreClient("GetPackageRepositorySummaries", mockGetPackageRepositorySummaries);
+ setMockCoreClient("getPackageRepositorySummaries", mockGetPackageRepositorySummaries);
const getPackageRepositorySummariesResponse =
- await PackageRepositoriesService.getPackageRepositorySummaries({
- cluster,
- namespace,
- });
+ await PackageRepositoriesService.getPackageRepositorySummaries(
+ new Context({
+ cluster,
+ namespace,
+ }),
+ );
expect(getPackageRepositorySummariesResponse).toStrictEqual({
packageRepositorySummaries: [
{ name: "repo1", packageRepoRef },
@@ -156,7 +173,7 @@ describe("RepositoriesService", () => {
detail: { name: "repo1", packageRepoRef },
} as GetPackageRepositoryDetailResponse),
);
- setMockCoreClient("GetPackageRepositoryDetail", mockGetPackageRepositoryDetail);
+ setMockCoreClient("getPackageRepositoryDetail", mockGetPackageRepositoryDetail);
const getPackageRepositoryDetailResponse =
await PackageRepositoriesService.getPackageRepositoryDetail(packageRepoRef);
@@ -176,7 +193,7 @@ describe("RepositoriesService", () => {
} as PackageRepositoryReference,
} as AddPackageRepositoryResponse),
);
- setMockCoreClient("AddPackageRepository", mockAddPackageRepository);
+ setMockCoreClient("addPackageRepository", mockAddPackageRepository);
const addPackageRepositoryResponse = await PackageRepositoriesService.addPackageRepository(
cluster,
@@ -211,7 +228,7 @@ describe("RepositoriesService", () => {
} as PackageRepositoryReference,
} as UpdatePackageRepositoryResponse),
);
- setMockCoreClient("UpdatePackageRepository", mockUpdatePackageRepository);
+ setMockCoreClient("updatePackageRepository", mockUpdatePackageRepository);
const updatePackageRepositoryResponse =
await PackageRepositoriesService.updatePackageRepository(cluster, pkgRepoFormData);
@@ -239,15 +256,17 @@ describe("RepositoriesService", () => {
it("deletePackageRepository", async () => {
const mockDeletePackageRepository = jest.fn().mockImplementation(() =>
- Promise.resolve({
- packageRepoRef: {
- identifier: pkgRepoFormData.name,
- context: { cluster, namespace },
- plugin,
- } as PackageRepositoryReference,
- } as DeletePackageRepositoryResponse),
+ Promise.resolve(
+ new DeletePackageRepositoryResponse({
+ packageRepoRef: {
+ identifier: pkgRepoFormData.name,
+ context: { cluster, namespace },
+ plugin,
+ } as PackageRepositoryReference,
+ }),
+ ),
);
- setMockCoreClient("DeletePackageRepository", mockDeletePackageRepository);
+ setMockCoreClient("deletePackageRepository", mockDeletePackageRepository);
const deletePackageRepositoryResponse =
await PackageRepositoriesService.deletePackageRepository({
@@ -255,13 +274,15 @@ describe("RepositoriesService", () => {
context: { cluster, namespace },
plugin,
} as PackageRepositoryReference);
- expect(deletePackageRepositoryResponse).toStrictEqual({
- packageRepoRef: {
- identifier: pkgRepoFormData.name,
- context: { cluster, namespace },
- plugin,
- } as PackageRepositoryReference,
- } as DeletePackageRepositoryResponse);
+ expect(deletePackageRepositoryResponse).toStrictEqual(
+ new DeletePackageRepositoryResponse({
+ packageRepoRef: new PackageRepositoryReference({
+ identifier: pkgRepoFormData.name,
+ context: { cluster, namespace },
+ plugin,
+ }),
+ }),
+ );
expect(mockDeletePackageRepository).toHaveBeenCalledWith({
packageRepoRef: {
context: { cluster, namespace },
@@ -276,7 +297,7 @@ describe("buildEncodedCustomDetail encoding", () => {
it("returns undefined if the plugin is not supported)", async () => {
const encodedCustomDetail = PackageRepositoriesService["buildEncodedCustomDetail"]({
...pkgRepoFormData,
- plugin: { name: "my.plugin", version: "0.0.1" },
+ plugin: new Plugin({ name: "my.plugin", version: "0.0.1" }),
customDetail: undefined,
});
expect(encodedCustomDetail).toStrictEqual(undefined);
@@ -285,7 +306,7 @@ describe("buildEncodedCustomDetail encoding", () => {
it("returns undefined if no custom details (helm)", async () => {
const encodedCustomDetail = PackageRepositoriesService["buildEncodedCustomDetail"]({
...pkgRepoFormData,
- plugin: { name: PluginNames.PACKAGES_HELM, version: "v1alpha1" },
+ plugin: new Plugin({ name: PluginNames.PACKAGES_HELM, version: "v1alpha1" }),
customDetail: undefined,
});
expect(encodedCustomDetail).toBe(undefined);
@@ -294,7 +315,7 @@ describe("buildEncodedCustomDetail encoding", () => {
it("returns encoded empty value if no custom details (kapp)", async () => {
const encodedCustomDetail = PackageRepositoriesService["buildEncodedCustomDetail"]({
...pkgRepoFormData,
- plugin: { name: PluginNames.PACKAGES_KAPP, version: "v1alpha1" },
+ plugin: new Plugin({ name: PluginNames.PACKAGES_KAPP, version: "v1alpha1" }),
customDetail: undefined,
});
expect(encodedCustomDetail).toBe(undefined);
@@ -303,38 +324,35 @@ describe("buildEncodedCustomDetail encoding", () => {
it("encodes the custom details (helm)", async () => {
const encodedCustomDetail = PackageRepositoriesService["buildEncodedCustomDetail"]({
...pkgRepoFormData,
- plugin: { name: PluginNames.PACKAGES_HELM, version: "v1alpha1" },
+ plugin: new Plugin({ name: PluginNames.PACKAGES_HELM, version: "v1alpha1" }),
customDetail: helmCustomDetail,
});
expect(encodedCustomDetail?.typeUrl).toBe(
"kubeappsapis.plugins.helm.packages.v1alpha1.HelmPackageRepositoryCustomDetail",
);
- expect(encodedCustomDetail?.value.byteLength).toBe(149);
- expect(
- HelmPackageRepositoryCustomDetail.decode(encodedCustomDetail?.value as any),
- ).toStrictEqual(helmCustomDetail);
+ expect(encodedCustomDetail?.value.byteLength).toBe(147);
+ expect(HelmPackageRepositoryCustomDetail.fromBinary(encodedCustomDetail!.value)).toStrictEqual(
+ helmCustomDetail,
+ );
});
it("encodes the custom details (kapp)", async () => {
const encodedCustomDetail = PackageRepositoriesService["buildEncodedCustomDetail"]({
...pkgRepoFormData,
- plugin: { name: PluginNames.PACKAGES_KAPP, version: "v1alpha1" },
+ plugin: new Plugin({ name: PluginNames.PACKAGES_KAPP, version: "v1alpha1" }),
customDetail: kappCustomDetail,
});
expect(encodedCustomDetail?.typeUrl).toBe(
"kubeappsapis.plugins.kapp_controller.packages.v1alpha1.KappControllerPackageRepositoryCustomDetail",
);
- expect(encodedCustomDetail?.value.byteLength).toBe(33);
- expect(
- KappControllerPackageRepositoryCustomDetail.decode(encodedCustomDetail?.value as any),
- ).toStrictEqual(kappCustomDetail);
+ expect(encodedCustomDetail?.value).toStrictEqual(kappCustomDetail);
});
it("getRepositoriesPermissions", async () => {
const mockGetRepositoriesPermissions = jest.fn().mockImplementation(() =>
Promise.resolve({
permissions: [
- {
+ new PackageRepositoriesPermissions({
plugin: plugin,
global: {
create: true,
@@ -342,16 +360,16 @@ describe("buildEncodedCustomDetail encoding", () => {
namespace: {
list: true,
},
- },
+ }),
],
} as GetPackageRepositoryPermissionsResponse),
);
- setMockCoreClient("GetPackageRepositoryPermissions", mockGetRepositoriesPermissions);
+ setMockCoreClient("getPackageRepositoryPermissions", mockGetRepositoriesPermissions);
const getPackageRepositoryPermissionsResponse =
await PackageRepositoriesService.getRepositoriesPermissions(cluster, namespace);
expect(getPackageRepositoryPermissionsResponse).toStrictEqual([
- {
+ new PackageRepositoriesPermissions({
plugin: plugin,
global: {
create: true,
@@ -359,7 +377,7 @@ describe("buildEncodedCustomDetail encoding", () => {
namespace: {
list: true,
},
- },
+ }),
] as PackageRepositoriesPermissions[]);
expect(mockGetRepositoriesPermissions).toHaveBeenCalledWith({
context: { cluster, namespace },
diff --git a/dashboard/src/shared/PackageRepositoriesService.ts b/dashboard/src/shared/PackageRepositoriesService.ts
index 52a366ab3fc..d82e0483301 100644
--- a/dashboard/src/shared/PackageRepositoriesService.ts
+++ b/dashboard/src/shared/PackageRepositoriesService.ts
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { Any } from "gen/google/protobuf/any";
-import { Context } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import { Context } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import {
AddPackageRepositoryRequest,
DeletePackageRepositoryResponse,
@@ -19,21 +19,14 @@ import {
TlsCertKey,
UpdatePackageRepositoryRequest,
UsernamePassword,
-} from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
-import { GetConfiguredPluginsResponse } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+} from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
+import { GetConfiguredPluginsResponse } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import {
HelmPackageRepositoryCustomDetail,
- protobufPackage as helmProtobufPackage,
ProxyOptions,
-} from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm";
-import {
- KappControllerPackageRepositoryCustomDetail,
- protobufPackage as kappControllerProtobufPackage,
-} from "gen/kubeappsapis/plugins/kapp_controller/packages/v1alpha1/kapp_controller";
-import {
- FluxPackageRepositoryCustomDetail,
- protobufPackage as fluxv2ProtobufPackage,
-} from "gen/kubeappsapis/plugins/fluxv2/packages/v1alpha1/fluxv2";
+} from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm_pb";
+import { KappControllerPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/kapp_controller/packages/v1alpha1/kapp_controller_pb";
+import { FluxPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/fluxv2/packages/v1alpha1/fluxv2_pb";
import KubeappsGrpcClient from "./KubeappsGrpcClient";
import { IPkgRepoFormData, PluginNames } from "./types";
import { convertGrpcAuthError } from "./utils";
@@ -48,7 +41,7 @@ export class PackageRepositoriesService {
context: Context,
): Promise {
return await this.coreRepositoriesClient()
- .GetPackageRepositorySummaries({ context })
+ .getPackageRepositorySummaries({ context })
.catch((e: any) => {
throw convertGrpcAuthError(e);
});
@@ -58,7 +51,7 @@ export class PackageRepositoriesService {
packageRepoRef: PackageRepositoryReference,
): Promise {
return await this.coreRepositoriesClient()
- .GetPackageRepositoryDetail({ packageRepoRef })
+ .getPackageRepositoryDetail({ packageRepoRef })
.catch((e: any) => {
throw convertGrpcAuthError(e);
});
@@ -73,7 +66,7 @@ export class PackageRepositoriesService {
);
return await this.coreRepositoriesClient()
- .AddPackageRepository(addPackageRepositoryRequest)
+ .addPackageRepository(addPackageRepositoryRequest)
.catch((e: any) => {
throw convertGrpcAuthError(e);
});
@@ -88,7 +81,7 @@ export class PackageRepositoriesService {
);
return await this.coreRepositoriesClient()
- .UpdatePackageRepository(updatePackageRepositoryRequest)
+ .updatePackageRepository(updatePackageRepositoryRequest)
.catch((e: any) => {
throw convertGrpcAuthError(e);
});
@@ -98,7 +91,7 @@ export class PackageRepositoriesService {
packageRepoRef: PackageRepositoryReference,
): Promise {
return await this.coreRepositoriesClient()
- .DeletePackageRepository({
+ .deletePackageRepository({
packageRepoRef,
})
.catch((e: any) => {
@@ -135,91 +128,117 @@ export class PackageRepositoriesService {
// auth/tls - user entered
if (!request.isUserManaged) {
switch (request.authMethod) {
- case (PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_AUTHORIZATION_HEADER,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BEARER):
+ case (PackageRepositoryAuth_PackageRepositoryAuthType.AUTHORIZATION_HEADER,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BEARER):
if (request.authHeader) {
- addPackageRepositoryRequest.auth = {
+ addPackageRepositoryRequest.auth = new PackageRepositoryAuth({
...addPackageRepositoryRequest.auth,
- header: request.authHeader,
- } as PackageRepositoryAuth;
+ packageRepoAuthOneOf: {
+ case: "header",
+ value: request.authHeader,
+ },
+ });
}
break;
- case PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH:
+ case PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH:
if (Object.values(request.basicAuth).some(e => !!e)) {
- addPackageRepositoryRequest.auth = {
+ addPackageRepositoryRequest.auth = new PackageRepositoryAuth({
...addPackageRepositoryRequest.auth,
- usernamePassword: {
- username: request.basicAuth.username,
- password: request.basicAuth.password,
- } as UsernamePassword,
- } as PackageRepositoryAuth;
+ packageRepoAuthOneOf: {
+ case: "usernamePassword",
+ value: {
+ username: request.basicAuth.username,
+ password: request.basicAuth.password,
+ } as UsernamePassword,
+ },
+ });
}
break;
- case PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON:
+ case PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON:
if (Object.values(request.dockerRegCreds).some(e => !!e)) {
- addPackageRepositoryRequest.auth = {
+ addPackageRepositoryRequest.auth = new PackageRepositoryAuth({
...addPackageRepositoryRequest.auth,
- dockerCreds: { ...request.dockerRegCreds } as DockerCredentials,
- } as PackageRepositoryAuth;
+ packageRepoAuthOneOf: {
+ case: "dockerCreds",
+ value: { ...request.dockerRegCreds } as DockerCredentials,
+ },
+ });
}
break;
- case PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_SSH:
+ case PackageRepositoryAuth_PackageRepositoryAuthType.SSH:
if (Object.values(request.sshCreds).some(e => !!e)) {
- addPackageRepositoryRequest.auth = {
+ addPackageRepositoryRequest.auth = new PackageRepositoryAuth({
...addPackageRepositoryRequest.auth,
- sshCreds: {
- ...request.sshCreds,
- } as SshCredentials,
- } as PackageRepositoryAuth;
+ packageRepoAuthOneOf: {
+ case: "sshCreds",
+ value: {
+ ...request.sshCreds,
+ } as SshCredentials,
+ },
+ });
}
break;
- case PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_TLS:
+ case PackageRepositoryAuth_PackageRepositoryAuthType.TLS:
if (Object.values(request.tlsCertKey).some(e => !!e)) {
- addPackageRepositoryRequest.auth = {
+ addPackageRepositoryRequest.auth = new PackageRepositoryAuth({
...addPackageRepositoryRequest.auth,
- tlsCertKey: { ...request.tlsCertKey } as TlsCertKey,
- } as PackageRepositoryAuth;
+ packageRepoAuthOneOf: {
+ case: "tlsCertKey",
+ value: { ...request.tlsCertKey } as TlsCertKey,
+ },
+ });
}
break;
- case PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_OPAQUE:
+ case PackageRepositoryAuth_PackageRepositoryAuthType.OPAQUE:
if (Object.values(request.opaqueCreds.data).some(e => !!e)) {
- addPackageRepositoryRequest.auth = {
+ addPackageRepositoryRequest.auth = new PackageRepositoryAuth({
...addPackageRepositoryRequest.auth,
- opaqueCreds: { ...request.opaqueCreds } as OpaqueCredentials,
- } as PackageRepositoryAuth;
+ packageRepoAuthOneOf: {
+ case: "opaqueCreds",
+ value: { ...request.opaqueCreds } as OpaqueCredentials,
+ },
+ });
}
break;
}
if (request.customCA) {
- addPackageRepositoryRequest.tlsConfig = {
+ addPackageRepositoryRequest.tlsConfig = new PackageRepositoryTlsConfig({
...addPackageRepositoryRequest.tlsConfig,
- certAuthority: request.customCA,
- } as PackageRepositoryTlsConfig;
+ packageRepoTlsConfigOneOf: {
+ case: "certAuthority",
+ value: request.customCA,
+ },
+ });
}
}
// auth/tls - user managed
if (request.isUserManaged) {
if (request.secretTLSName) {
- addPackageRepositoryRequest.tlsConfig = {
+ addPackageRepositoryRequest.tlsConfig = new PackageRepositoryTlsConfig({
...addPackageRepositoryRequest.tlsConfig,
- secretRef: {
- name: request.secretTLSName,
- } as SecretKeyReference,
- } as PackageRepositoryTlsConfig;
+ packageRepoTlsConfigOneOf: {
+ case: "secretRef",
+ value: {
+ name: request.secretTLSName,
+ },
+ },
+ });
}
if (
- request.authMethod !==
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED &&
+ request.authMethod !== PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED &&
request.secretAuthName
) {
- addPackageRepositoryRequest.auth = {
+ addPackageRepositoryRequest.auth = new PackageRepositoryAuth({
...addPackageRepositoryRequest.auth,
- secretRef: {
- name: request.secretAuthName,
- } as SecretKeyReference,
- } as PackageRepositoryAuth;
+ packageRepoAuthOneOf: {
+ case: "secretRef",
+ value: new SecretKeyReference({
+ name: request.secretAuthName,
+ }),
+ },
+ });
}
}
@@ -238,19 +257,20 @@ export class PackageRepositoriesService {
}
if (isUpdate) {
- const updatePackageRepositoryRequest: UpdatePackageRepositoryRequest = {
- description: addPackageRepositoryRequest.description,
- interval: addPackageRepositoryRequest.interval,
- url: addPackageRepositoryRequest.url,
- auth: addPackageRepositoryRequest.auth,
- customDetail: addPackageRepositoryRequest.customDetail,
- tlsConfig: addPackageRepositoryRequest.tlsConfig,
- packageRepoRef: {
- identifier: addPackageRepositoryRequest.name,
- context: addPackageRepositoryRequest.context,
- plugin: addPackageRepositoryRequest.plugin,
- },
- };
+ const updatePackageRepositoryRequest: UpdatePackageRepositoryRequest =
+ new UpdatePackageRepositoryRequest({
+ description: addPackageRepositoryRequest.description,
+ interval: addPackageRepositoryRequest.interval,
+ url: addPackageRepositoryRequest.url,
+ auth: addPackageRepositoryRequest.auth,
+ customDetail: addPackageRepositoryRequest.customDetail,
+ tlsConfig: addPackageRepositoryRequest.tlsConfig,
+ packageRepoRef: new PackageRepositoryReference({
+ identifier: addPackageRepositoryRequest.name,
+ context: addPackageRepositoryRequest.context,
+ plugin: addPackageRepositoryRequest.plugin,
+ }),
+ });
return updatePackageRepositoryRequest;
}
return addPackageRepositoryRequest;
@@ -268,7 +288,7 @@ export class PackageRepositoriesService {
switch (request.plugin?.name) {
case PluginNames.PACKAGES_HELM: {
const detail = request.customDetail as HelmPackageRepositoryCustomDetail;
- const helmCustomDetail = {
+ const helmCustomDetail = new HelmPackageRepositoryCustomDetail({
// populate the non-optional fields
ociRepositories: detail?.ociRepositories || [],
performValidation: !!detail?.performValidation,
@@ -278,47 +298,45 @@ export class PackageRepositoriesService {
securityContext: {
supplementalGroups: [],
},
- } as HelmPackageRepositoryCustomDetail;
+ });
// populate the imagesPullSecret if it's not empty
if (
- detail?.imagesPullSecret?.secretRef ||
- (detail?.imagesPullSecret?.credentials &&
- Object.values((detail?.imagesPullSecret?.credentials || {}) as DockerCredentials).some(
- e => !!e,
- ))
+ detail?.imagesPullSecret?.dockerRegistryCredentialOneOf?.case === "secretRef" ||
+ (detail?.imagesPullSecret?.dockerRegistryCredentialOneOf?.case === "credentials" &&
+ Object.values(
+ (detail?.imagesPullSecret?.dockerRegistryCredentialOneOf?.value ||
+ {}) as DockerCredentials,
+ ).some(e => !!e))
) {
helmCustomDetail.imagesPullSecret = detail.imagesPullSecret;
}
+ helmCustomDetail.imagesPullSecret?.fromJsonString(JSON.stringify(detail.imagesPullSecret));
// populate the proxyOptions if it's not empty
if (Object.values((detail?.proxyOptions || {}) as ProxyOptions).some(e => !!e)) {
- helmCustomDetail.proxyOptions = {
+ helmCustomDetail.proxyOptions = new ProxyOptions({
enabled: detail.proxyOptions?.enabled || false,
httpProxy: detail.proxyOptions?.httpProxy || "",
httpsProxy: detail.proxyOptions?.httpsProxy || "",
noProxy: detail.proxyOptions?.noProxy || "",
- };
+ });
}
return {
- typeUrl: `${helmProtobufPackage}.HelmPackageRepositoryCustomDetail`,
- value: HelmPackageRepositoryCustomDetail.encode(helmCustomDetail).finish(),
+ typeUrl: HelmPackageRepositoryCustomDetail.typeName,
+ value: helmCustomDetail.toBinary(),
} as Any;
}
case PluginNames.PACKAGES_KAPP:
return {
- typeUrl: `${kappControllerProtobufPackage}.KappControllerPackageRepositoryCustomDetail`,
- value: KappControllerPackageRepositoryCustomDetail.encode(
- request.customDetail as KappControllerPackageRepositoryCustomDetail,
- ).finish(),
+ typeUrl: KappControllerPackageRepositoryCustomDetail.typeName,
+ value: request.customDetail,
} as Any;
case PluginNames.PACKAGES_FLUX:
return {
- typeUrl: `${fluxv2ProtobufPackage}.FluxPackageRepositoryCustomDetail`,
- value: FluxPackageRepositoryCustomDetail.encode(
- request.customDetail as FluxPackageRepositoryCustomDetail,
- ).finish(),
+ typeUrl: FluxPackageRepositoryCustomDetail.typeName,
+ value: request.customDetail,
} as Any;
default:
return;
@@ -327,14 +345,14 @@ export class PackageRepositoriesService {
public static async getConfiguredPlugins(): Promise {
return await this.pluginsServiceClientImpl()
- .GetConfiguredPlugins({})
+ .getConfiguredPlugins({})
.catch((e: any) => {
throw convertGrpcAuthError(e);
});
}
public static async getRepositoriesPermissions(cluster: string, namespace: string) {
- const resp = await this.coreRepositoriesClient().GetPackageRepositoryPermissions({
+ const resp = await this.coreRepositoriesClient().getPackageRepositoryPermissions({
context: {
cluster: cluster,
namespace: namespace,
diff --git a/dashboard/src/shared/PackagesService.test.ts b/dashboard/src/shared/PackagesService.test.ts
index 3bf846063e3..f741ff6c091 100644
--- a/dashboard/src/shared/PackagesService.test.ts
+++ b/dashboard/src/shared/PackagesService.test.ts
@@ -7,8 +7,8 @@ import {
GetAvailablePackageSummariesResponse,
GetAvailablePackageVersionsResponse,
PackageAppVersion,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import { KubeappsGrpcClient } from "./KubeappsGrpcClient";
import PackagesService from "./PackagesService";
@@ -107,7 +107,7 @@ describe("App", () => {
// Create a real client, but we'll stub out the function we're interested in.
const mockClient = new KubeappsGrpcClient().getPackagesServiceClientImpl();
jest
- .spyOn(mockClient, "GetAvailablePackageSummaries")
+ .spyOn(mockClient, "getAvailablePackageSummaries")
.mockImplementation(mockClientGetAvailablePackageSummaries);
jest.spyOn(PackagesService, "packagesServiceClient").mockImplementation(() => mockClient);
const availablePackageSummaries = await PackagesService.getAvailablePackageSummaries(
diff --git a/dashboard/src/shared/PackagesService.ts b/dashboard/src/shared/PackagesService.ts
index bbdf5e6dab4..1635981942a 100644
--- a/dashboard/src/shared/PackagesService.ts
+++ b/dashboard/src/shared/PackagesService.ts
@@ -6,7 +6,7 @@ import {
GetAvailablePackageDetailResponse,
GetAvailablePackageSummariesResponse,
GetAvailablePackageVersionsResponse,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import { KubeappsGrpcClient } from "./KubeappsGrpcClient";
import { convertGrpcAuthError } from "./utils";
@@ -25,7 +25,7 @@ export default class PackagesService {
query?: string,
): Promise {
return await this.packagesServiceClient()
- .GetAvailablePackageSummaries({
+ .getAvailablePackageSummaries({
context: { cluster: cluster, namespace: namespace },
filterOptions: {
query: query,
@@ -42,7 +42,7 @@ export default class PackagesService {
availablePackageReference?: AvailablePackageReference,
): Promise {
return await this.packagesServiceClient()
- .GetAvailablePackageVersions({
+ .getAvailablePackageVersions({
availablePackageRef: availablePackageReference,
})
.catch((e: any) => {
@@ -55,7 +55,7 @@ export default class PackagesService {
version?: string,
): Promise {
return await this.packagesServiceClient()
- .GetAvailablePackageDetail({
+ .getAvailablePackageDetail({
pkgVersion: version,
availablePackageRef: availablePackageReference,
})
diff --git a/dashboard/src/shared/ResourceRef.test.ts b/dashboard/src/shared/ResourceRef.test.ts
index 645c4117200..6333151f315 100644
--- a/dashboard/src/shared/ResourceRef.test.ts
+++ b/dashboard/src/shared/ResourceRef.test.ts
@@ -3,27 +3,24 @@
import ResourceRef, { fromCRD } from "./ResourceRef";
import { IClusterServiceVersionCRDResource } from "./types";
-import { ResourceRef as APIResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
const clusterName = "cluster-name";
describe("ResourceRef", () => {
describe("constructor", () => {
it("returns a ResourceRef with the correct details", () => {
- const apiRef = {
+ const ref = new ResourceRef(clusterName, "deployments", true, "releaseNamespace", {
apiVersion: "apps/v1",
kind: "Deployment",
name: "foo",
namespace: "bar",
- } as APIResourceRef;
-
- const ref = new ResourceRef(apiRef, clusterName, "deployments", true, "releaseNamespace");
+ });
expect(ref).toBeInstanceOf(ResourceRef);
expect(ref).toEqual({
cluster: clusterName,
- apiVersion: apiRef.apiVersion,
- kind: apiRef.kind,
- name: apiRef.name,
+ apiVersion: "apps/v1",
+ kind: "Deployment",
+ name: "foo",
namespace: "bar",
namespaced: true,
plural: "deployments",
@@ -31,13 +28,11 @@ describe("ResourceRef", () => {
});
it("sets a default namespace if not in the resource", () => {
- const r = {
+ const ref = new ResourceRef(clusterName, "deployments", true, "default", {
apiVersion: "apps/v1",
kind: "Deployment",
name: "foo",
- } as APIResourceRef;
-
- const ref = new ResourceRef(r, clusterName, "deployments", true, "default");
+ });
expect(ref.namespace).toBe("default");
});
@@ -62,7 +57,7 @@ describe("ResourceRef", () => {
expect(res).toMatchObject({
apiVersion: "apps/v1",
kind: "Deployment",
- name: undefined,
+ name: "",
namespace: "default",
filter: { metadata: { ownerReferences: [ownerRef] } },
});
@@ -88,7 +83,7 @@ describe("ResourceRef", () => {
expect(res).toMatchObject({
apiVersion: "rbac.authorization.k8s.io/v1",
kind: "ClusterRole",
- name: undefined,
+ name: "",
namespace: "",
filter: { metadata: { ownerReferences: [ownerRef] } },
});
diff --git a/dashboard/src/shared/ResourceRef.ts b/dashboard/src/shared/ResourceRef.ts
index 6a6c9e61df2..e6455ad8eb8 100644
--- a/dashboard/src/shared/ResourceRef.ts
+++ b/dashboard/src/shared/ResourceRef.ts
@@ -1,8 +1,9 @@
// Copyright 2019-2022 the Kubeapps contributors.
// SPDX-License-Identifier: Apache-2.0
+import type { PartialMessage } from "@bufbuild/protobuf";
import { IClusterServiceVersionCRDResource, IKind } from "./types";
-import { ResourceRef as APIResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+import { ResourceRef as APIResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
export function fromCRD(
r: IClusterServiceVersionCRDResource,
@@ -11,11 +12,10 @@ export function fromCRD(
namespace: string,
ownerReference: any,
) {
- const apiResourceRef = {
+ const ref = new ResourceRef(cluster, kind.plural, kind.namespaced, namespace, {
apiVersion: kind.apiVersion,
kind: r.kind,
- } as APIResourceRef;
- const ref = new ResourceRef(apiResourceRef, cluster, kind.plural, kind.namespaced, namespace);
+ });
ref.filter = {
metadata: { ownerReferences: [ownerReference] },
};
@@ -29,32 +29,28 @@ export const keyForResourceRef = (r: APIResourceRef) =>
// ResourceRef defines a reference to a namespaced Kubernetes API Object and
// provides helpers to retrieve the resource URL
-class ResourceRef {
+class ResourceRef extends APIResourceRef {
public cluster: string;
- public apiVersion: string;
- public kind: string;
public plural: string;
public namespaced: boolean;
- public name: string;
- public namespace: string;
public filter: any;
// Creates a new ResourceRef instance from an existing IResource. Provide
// defaultNamespace to set if the IResource doesn't specify a namespace.
+ //constructor(data?: PartialMessage) {
constructor(
- apiRef: APIResourceRef,
cluster: string,
plural: string,
namespaced: boolean,
releaseNamespace: string,
+ data?: PartialMessage,
) {
+ data = data || {};
+ data.namespace = namespaced ? data.namespace || releaseNamespace || "" : "";
+ super(data);
+ this.namespaced = namespaced;
this.cluster = cluster;
this.plural = plural;
- this.apiVersion = apiRef.apiVersion;
- this.kind = apiRef.kind;
- this.name = apiRef.name;
- this.namespace = namespaced ? apiRef.namespace || releaseNamespace || "" : "";
- this.namespaced = namespaced;
return this;
}
}
diff --git a/dashboard/src/shared/Secret.test.ts b/dashboard/src/shared/Secret.test.ts
index eac234b6359..e3d3b2f3d43 100644
--- a/dashboard/src/shared/Secret.test.ts
+++ b/dashboard/src/shared/Secret.test.ts
@@ -6,27 +6,29 @@ import {
CreateSecretResponse,
GetSecretNamesResponse,
SecretType,
-} from "gen/kubeappsapis/plugins/resources/v1alpha1/resources";
+} from "gen/kubeappsapis/plugins/resources/v1alpha1/resources_pb";
import { KubeappsGrpcClient } from "./KubeappsGrpcClient";
import Secret from "./Secret";
describe("getSecretNames", () => {
const expectedSecretNames = {
- "secret-one": SecretType.SECRET_TYPE_DOCKER_CONFIG_JSON,
- "secret-two": SecretType.SECRET_TYPE_OPAQUE_UNSPECIFIED,
- "secret-three": SecretType.SECRET_TYPE_DOCKER_CONFIG_JSON,
+ "secret-one": SecretType.DOCKER_CONFIG_JSON,
+ "secret-two": SecretType.OPAQUE_UNSPECIFIED,
+ "secret-three": SecretType.DOCKER_CONFIG_JSON,
};
// Create a real client, but we'll stub out the function we're interested in.
const client = new KubeappsGrpcClient().getResourcesServiceClientImpl();
- let mockClientGetSecretNames: jest.MockedFunction;
+ let mockClientGetSecretNames: jest.MockedFunction;
beforeEach(() => {
mockClientGetSecretNames = jest.fn().mockImplementation(() =>
- Promise.resolve({
- secretNames: expectedSecretNames,
- } as GetSecretNamesResponse),
+ Promise.resolve(
+ new GetSecretNamesResponse({
+ secretNames: expectedSecretNames,
+ }),
+ ),
);
- jest.spyOn(client, "GetSecretNames").mockImplementation(mockClientGetSecretNames);
+ jest.spyOn(client, "getSecretNames").mockImplementation(mockClientGetSecretNames);
jest.spyOn(Secret, "resourcesServiceClient").mockImplementation(() => client);
});
afterEach(() => {
@@ -43,13 +45,13 @@ describe("getSecretNames", () => {
describe("createSecret", () => {
// Create a real client, but we'll stub out the function we're interested in.
const client = new KubeappsGrpcClient().getResourcesServiceClientImpl();
- let mockClientCreateSecret: jest.MockedFunction;
+ let mockClientCreateSecret: jest.MockedFunction;
beforeEach(() => {
mockClientCreateSecret = jest
.fn()
.mockImplementation(() => Promise.resolve({} as CreateSecretResponse));
- jest.spyOn(client, "CreateSecret").mockImplementation(mockClientCreateSecret);
+ jest.spyOn(client, "createSecret").mockImplementation(mockClientCreateSecret);
jest.spyOn(Secret, "resourcesServiceClient").mockImplementation(() => client);
});
afterEach(() => {
@@ -67,17 +69,19 @@ describe("createSecret", () => {
await Secret.createPullSecret("default", name, user, password, email, server, namespace);
- expect(mockClientCreateSecret).toHaveBeenCalledWith({
- context: {
- cluster,
- namespace,
- },
- name,
- stringData: {
- ".dockerconfigjson":
- '{"auths":{"docker.io":{"username":"foo","password":"pass","email":"foo@bar.com","auth":"Zm9vOnBhc3M="}}}',
- },
- type: SecretType.SECRET_TYPE_DOCKER_CONFIG_JSON,
- } as CreateSecretRequest);
+ expect(mockClientCreateSecret).toHaveBeenCalledWith(
+ new CreateSecretRequest({
+ context: {
+ cluster,
+ namespace,
+ },
+ name,
+ stringData: {
+ ".dockerconfigjson":
+ '{"auths":{"docker.io":{"username":"foo","password":"pass","email":"foo@bar.com","auth":"Zm9vOnBhc3M="}}}',
+ },
+ type: SecretType.DOCKER_CONFIG_JSON,
+ }),
+ );
});
});
diff --git a/dashboard/src/shared/Secret.ts b/dashboard/src/shared/Secret.ts
index 388645701e7..c78be60f0c5 100644
--- a/dashboard/src/shared/Secret.ts
+++ b/dashboard/src/shared/Secret.ts
@@ -4,7 +4,7 @@
import {
CreateSecretRequest,
SecretType,
-} from "gen/kubeappsapis/plugins/resources/v1alpha1/resources";
+} from "gen/kubeappsapis/plugins/resources/v1alpha1/resources_pb";
import { KubeappsGrpcClient } from "./KubeappsGrpcClient";
import { convertGrpcAuthError } from "./utils";
@@ -15,7 +15,7 @@ export default class Secret {
// TODO(agamez): unused method, remove?
public static async getDockerConfigSecretNames(cluster: string, namespace: string) {
const result = await this.resourcesServiceClient()
- .GetSecretNames({
+ .getSecretNames({
context: {
cluster,
namespace,
@@ -27,7 +27,7 @@ export default class Secret {
const secretNames = [];
for (const [name, type] of Object.entries(result.secretNames)) {
- if (type === SecretType.SECRET_TYPE_DOCKER_CONFIG_JSON) {
+ if (type === SecretType.DOCKER_CONFIG_JSON) {
secretNames.push(name);
}
}
@@ -55,17 +55,19 @@ export default class Secret {
},
};
await this.resourcesServiceClient()
- .CreateSecret({
- context: {
- cluster,
- namespace,
- },
- name,
- type: SecretType.SECRET_TYPE_DOCKER_CONFIG_JSON,
- stringData: {
- ".dockerconfigjson": JSON.stringify(dockercfg),
- },
- } as CreateSecretRequest)
+ .createSecret(
+ new CreateSecretRequest({
+ context: {
+ cluster,
+ namespace,
+ },
+ name,
+ type: SecretType.DOCKER_CONFIG_JSON,
+ stringData: {
+ ".dockerconfigjson": JSON.stringify(dockercfg),
+ },
+ }),
+ )
.catch((e: any) => {
throw convertGrpcAuthError(e);
});
diff --git a/dashboard/src/shared/types.ts b/dashboard/src/shared/types.ts
index 3ec3f0744df..aea05bae0c5 100644
--- a/dashboard/src/shared/types.ts
+++ b/dashboard/src/shared/types.ts
@@ -1,6 +1,7 @@
// Copyright 2018-2022 the Kubeapps contributors.
// SPDX-License-Identifier: Apache-2.0
+import type { PartialMessage } from "@bufbuild/protobuf";
import { JSONSchemaType, ErrorObject } from "ajv";
import { RouterState } from "connected-react-router";
import {
@@ -11,7 +12,7 @@ import {
InstalledPackageSummary,
PackageAppVersion,
ResourceRef,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import {
DockerCredentials,
OpaqueCredentials,
@@ -19,11 +20,11 @@ import {
SshCredentials,
TlsCertKey,
UsernamePassword,
-} from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
-import { FluxPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/fluxv2/packages/v1alpha1/fluxv2";
-import { HelmPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm";
-import { KappControllerPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/kapp_controller/packages/v1alpha1/kapp_controller";
+} from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
+import { FluxPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/fluxv2/packages/v1alpha1/fluxv2_pb";
+import { HelmPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm_pb";
+import { KappControllerPackageRepositoryCustomDetail } from "gen/kubeappsapis/plugins/kapp_controller/packages/v1alpha1/kapp_controller_pb";
import { IOperatorsState } from "reducers/operators";
import { Subscription } from "rxjs";
import { IAuthState } from "../reducers/auth";
@@ -424,8 +425,13 @@ export interface IAjvValidateResult {
// type for handling Helm installed packages, which includes the revision,
// a field not present in other packages
-export interface CustomInstalledPackageDetail extends InstalledPackageDetail {
+export class CustomInstalledPackageDetail extends InstalledPackageDetail {
revision: number;
+
+ constructor(revision: number, data?: PartialMessage) {
+ super(data);
+ this.revision = revision;
+ }
}
// enum for the type of package repository storage
diff --git a/dashboard/src/shared/url.ts b/dashboard/src/shared/url.ts
index 5d92265c28e..122979facaf 100644
--- a/dashboard/src/shared/url.ts
+++ b/dashboard/src/shared/url.ts
@@ -4,7 +4,7 @@
import {
AvailablePackageReference,
InstalledPackageReference,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
+} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
export const app = {
apps: {
diff --git a/dashboard/src/shared/utils.test.ts b/dashboard/src/shared/utils.test.ts
index 0a33b7a9d00..826a6418a4e 100644
--- a/dashboard/src/shared/utils.test.ts
+++ b/dashboard/src/shared/utils.test.ts
@@ -1,8 +1,9 @@
// Copyright 2022 the Kubeapps contributors.
// SPDX-License-Identifier: Apache-2.0
-import { InstalledPackageStatus_StatusReason } from "gen/kubeappsapis/core/packages/v1alpha1/packages";
-import { PackageRepositoryAuth_PackageRepositoryAuthType } from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
+import { InstalledPackageStatus_StatusReason } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
+import { PackageRepositoryAuth_PackageRepositoryAuthType } from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import carvelIcon from "icons/carvel.svg";
import fluxIcon from "icons/flux.svg";
import helmIcon from "icons/helm.svg";
@@ -84,9 +85,15 @@ it("getPluginIcon", () => {
expect(getPluginIcon("helm")).toBe(helmIcon);
expect(getPluginIcon("operator")).toBe(olmIcon);
expect(getPluginIcon("fluflu")).toBe(placeholder);
- expect(getPluginIcon({ name: PluginNames.PACKAGES_HELM, version: "" })).toBe(helmIcon);
- expect(getPluginIcon({ name: PluginNames.PACKAGES_FLUX, version: "" })).toBe(fluxIcon);
- expect(getPluginIcon({ name: PluginNames.PACKAGES_KAPP, version: "" })).toBe(carvelIcon);
+ expect(getPluginIcon(new Plugin({ name: PluginNames.PACKAGES_HELM, version: "" }))).toBe(
+ helmIcon,
+ );
+ expect(getPluginIcon(new Plugin({ name: PluginNames.PACKAGES_FLUX, version: "" }))).toBe(
+ fluxIcon,
+ );
+ expect(getPluginIcon(new Plugin({ name: PluginNames.PACKAGES_KAPP, version: "" }))).toBe(
+ carvelIcon,
+ );
});
it("getPluginName", () => {
@@ -94,9 +101,11 @@ it("getPluginName", () => {
expect(getPluginName("helm")).toBe("Helm");
expect(getPluginName("operator")).toBe("Operator");
expect(getPluginName("fluflu")).toBe("unknown plugin");
- expect(getPluginName({ name: PluginNames.PACKAGES_HELM, version: "" })).toBe("Helm");
- expect(getPluginName({ name: PluginNames.PACKAGES_FLUX, version: "" })).toBe("Flux");
- expect(getPluginName({ name: PluginNames.PACKAGES_KAPP, version: "" })).toBe("Carvel");
+ expect(getPluginName(new Plugin({ name: PluginNames.PACKAGES_HELM, version: "" }))).toBe("Helm");
+ expect(getPluginName(new Plugin({ name: PluginNames.PACKAGES_FLUX, version: "" }))).toBe("Flux");
+ expect(getPluginName(new Plugin({ name: PluginNames.PACKAGES_KAPP, version: "" }))).toBe(
+ "Carvel",
+ );
});
it("getPluginPackageName", () => {
@@ -104,26 +113,28 @@ it("getPluginPackageName", () => {
expect(getPluginPackageName("helm")).toBe("Helm Chart");
expect(getPluginPackageName("operator")).toBe("Operator");
expect(getPluginPackageName("fluflu")).toBe("unknown plugin package");
- expect(getPluginPackageName({ name: PluginNames.PACKAGES_HELM, version: "" })).toBe("Helm Chart");
- expect(getPluginPackageName({ name: PluginNames.PACKAGES_FLUX, version: "" })).toBe(
+ expect(getPluginPackageName(new Plugin({ name: PluginNames.PACKAGES_HELM, version: "" }))).toBe(
+ "Helm Chart",
+ );
+ expect(getPluginPackageName(new Plugin({ name: PluginNames.PACKAGES_FLUX, version: "" }))).toBe(
"Helm Chart via Flux",
);
- expect(getPluginPackageName({ name: PluginNames.PACKAGES_KAPP, version: "" })).toBe(
+ expect(getPluginPackageName(new Plugin({ name: PluginNames.PACKAGES_KAPP, version: "" }))).toBe(
"Carvel Package",
);
expect(getPluginPackageName("chart", true)).toBe("Helm Charts");
expect(getPluginPackageName("helm", true)).toBe("Helm Charts");
expect(getPluginPackageName("operator", true)).toBe("Operators");
expect(getPluginPackageName("fluflu", true)).toBe("unknown plugin packages");
- expect(getPluginPackageName({ name: PluginNames.PACKAGES_HELM, version: "" }, true)).toBe(
- "Helm Charts",
- );
- expect(getPluginPackageName({ name: PluginNames.PACKAGES_FLUX, version: "" }, true)).toBe(
- "Helm Charts via Flux",
- );
- expect(getPluginPackageName({ name: PluginNames.PACKAGES_KAPP, version: "" }, true)).toBe(
- "Carvel Packages",
- );
+ expect(
+ getPluginPackageName(new Plugin({ name: PluginNames.PACKAGES_HELM, version: "" }), true),
+ ).toBe("Helm Charts");
+ expect(
+ getPluginPackageName(new Plugin({ name: PluginNames.PACKAGES_FLUX, version: "" }), true),
+ ).toBe("Helm Charts via Flux");
+ expect(
+ getPluginPackageName(new Plugin({ name: PluginNames.PACKAGES_KAPP, version: "" }), true),
+ ).toBe("Carvel Packages");
});
it("getPluginByName", () => {
@@ -161,157 +172,148 @@ it("getPluginsSupportingRollback", () => {
});
it("getAppStatusLabel", () => {
- expect(getAppStatusLabel(InstalledPackageStatus_StatusReason.STATUS_REASON_UNSPECIFIED)).toBe(
- "unspecified",
- );
- expect(getAppStatusLabel(InstalledPackageStatus_StatusReason.STATUS_REASON_FAILED)).toBe(
- "failed",
- );
- expect(getAppStatusLabel(InstalledPackageStatus_StatusReason.STATUS_REASON_INSTALLED)).toBe(
- "installed",
- );
- expect(getAppStatusLabel(InstalledPackageStatus_StatusReason.STATUS_REASON_PENDING)).toBe(
- "pending",
- );
- expect(getAppStatusLabel(InstalledPackageStatus_StatusReason.STATUS_REASON_UNINSTALLED)).toBe(
- "uninstalled",
- );
- expect(getAppStatusLabel(InstalledPackageStatus_StatusReason.UNRECOGNIZED)).toBe("unrecognized");
+ expect(getAppStatusLabel(InstalledPackageStatus_StatusReason.UNSPECIFIED)).toBe("unspecified");
+ expect(getAppStatusLabel(InstalledPackageStatus_StatusReason.FAILED)).toBe("failed");
+ expect(getAppStatusLabel(InstalledPackageStatus_StatusReason.INSTALLED)).toBe("installed");
+ expect(getAppStatusLabel(InstalledPackageStatus_StatusReason.PENDING)).toBe("pending");
+ expect(getAppStatusLabel(InstalledPackageStatus_StatusReason.UNINSTALLED)).toBe("uninstalled");
});
it("getSupportedPackageRepositoryAuthTypes", () => {
expect(
- getSupportedPackageRepositoryAuthTypes({
- name: PluginNames.PACKAGES_HELM,
- version: "",
- }).toString(),
+ getSupportedPackageRepositoryAuthTypes(
+ new Plugin({
+ name: PluginNames.PACKAGES_HELM,
+ version: "",
+ }),
+ ).toString(),
).toBe(
[
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_AUTHORIZATION_HEADER,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BEARER,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON,
+ PackageRepositoryAuth_PackageRepositoryAuthType.AUTHORIZATION_HEADER,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BEARER,
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON,
].toString(),
);
expect(
getSupportedPackageRepositoryAuthTypes(
- { name: PluginNames.PACKAGES_HELM, version: "" },
+ new Plugin({ name: PluginNames.PACKAGES_HELM, version: "" }),
RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_HELM,
).toString(),
).toBe(
[
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_AUTHORIZATION_HEADER,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BEARER,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON,
+ PackageRepositoryAuth_PackageRepositoryAuthType.AUTHORIZATION_HEADER,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BEARER,
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON,
].toString(),
);
expect(
getSupportedPackageRepositoryAuthTypes(
- { name: PluginNames.PACKAGES_HELM, version: "" },
+ new Plugin({ name: PluginNames.PACKAGES_HELM, version: "" }),
RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_OCI,
).toString(),
).toBe(
[
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_AUTHORIZATION_HEADER,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BEARER,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON,
+ PackageRepositoryAuth_PackageRepositoryAuthType.AUTHORIZATION_HEADER,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BEARER,
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON,
].toString(),
);
expect(
- getSupportedPackageRepositoryAuthTypes({
- name: PluginNames.PACKAGES_FLUX,
- version: "",
- }).toString(),
+ getSupportedPackageRepositoryAuthTypes(
+ new Plugin({
+ name: PluginNames.PACKAGES_FLUX,
+ version: "",
+ }),
+ ).toString(),
).toBe(
[
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_TLS,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.TLS,
].toString(),
);
expect(
getSupportedPackageRepositoryAuthTypes(
- { name: PluginNames.PACKAGES_FLUX, version: "" },
+ new Plugin({ name: PluginNames.PACKAGES_FLUX, version: "" }),
RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_HELM,
).toString(),
).toBe(
[
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_TLS,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.TLS,
].toString(),
);
expect(
getSupportedPackageRepositoryAuthTypes(
- { name: PluginNames.PACKAGES_FLUX, version: "" },
+ new Plugin({ name: PluginNames.PACKAGES_FLUX, version: "" }),
RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_OCI,
).toString(),
).toBe(
[
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON,
].toString(),
);
expect(
- getSupportedPackageRepositoryAuthTypes({
- name: PluginNames.PACKAGES_KAPP,
- version: "",
- }).toString(),
+ getSupportedPackageRepositoryAuthTypes(
+ new Plugin({
+ name: PluginNames.PACKAGES_KAPP,
+ version: "",
+ }),
+ ).toString(),
).toBe([].toString());
expect(
getSupportedPackageRepositoryAuthTypes(
- { name: PluginNames.PACKAGES_KAPP, version: "" },
+ new Plugin({ name: PluginNames.PACKAGES_KAPP, version: "" }),
RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_CARVEL_GIT,
).toString(),
).toBe(
[
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_SSH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.SSH,
].toString(),
);
expect(
getSupportedPackageRepositoryAuthTypes(
- { name: PluginNames.PACKAGES_KAPP, version: "" },
+ new Plugin({ name: PluginNames.PACKAGES_KAPP, version: "" }),
RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_CARVEL_HTTP,
).toString(),
- ).toBe(
- [
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- ].toString(),
- );
+ ).toBe([PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH].toString());
expect(
getSupportedPackageRepositoryAuthTypes(
- { name: PluginNames.PACKAGES_KAPP, version: "" },
+ new Plugin({ name: PluginNames.PACKAGES_KAPP, version: "" }),
RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_CARVEL_IMAGE,
).toString(),
).toBe(
[
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BEARER,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BEARER,
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON,
].toString(),
);
expect(
getSupportedPackageRepositoryAuthTypes(
- { name: PluginNames.PACKAGES_KAPP, version: "" },
+ new Plugin({ name: PluginNames.PACKAGES_KAPP, version: "" }),
RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_CARVEL_IMGPKGBUNDLE,
).toString(),
).toBe(
[
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BEARER,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BEARER,
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON,
].toString(),
);
expect(
getSupportedPackageRepositoryAuthTypes(
- { name: PluginNames.PACKAGES_KAPP, version: "" },
+ new Plugin({ name: PluginNames.PACKAGES_KAPP, version: "" }),
RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_CARVEL_INLINE,
).toString(),
).toBe([].toString());
- expect(getSupportedPackageRepositoryAuthTypes({ name: "foo", version: "" }).toString()).toBe(
- [].toString(),
- );
+ expect(
+ getSupportedPackageRepositoryAuthTypes(new Plugin({ name: "foo", version: "" })).toString(),
+ ).toBe([].toString());
});
it("isGlobalNamespace", () => {
diff --git a/dashboard/src/shared/utils.ts b/dashboard/src/shared/utils.ts
index 43d8fc7c13f..793ff0ac9ef 100644
--- a/dashboard/src/shared/utils.ts
+++ b/dashboard/src/shared/utils.ts
@@ -1,13 +1,11 @@
// Copyright 2018-2022 the Kubeapps contributors.
// SPDX-License-Identifier: Apache-2.0
-import { grpc } from "@improbable-eng/grpc-web";
-import {
- InstalledPackageStatus_StatusReason,
- installedPackageStatus_StatusReasonToJSON,
-} from "gen/kubeappsapis/core/packages/v1alpha1/packages";
-import { PackageRepositoryAuth_PackageRepositoryAuthType } from "gen/kubeappsapis/core/packages/v1alpha1/repositories";
-import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins";
+import { Code } from "@bufbuild/connect";
+import { proto3 } from "@bufbuild/protobuf";
+import { InstalledPackageStatus_StatusReason } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
+import { PackageRepositoryAuth_PackageRepositoryAuthType } from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb";
+import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import carvelIcon from "icons/carvel.svg";
import fluxIcon from "icons/flux.svg";
import helmIcon from "icons/helm.svg";
@@ -233,12 +231,12 @@ export function getPluginsSupportingRollback(): string[] {
}
export function getAppStatusLabel(
- statusReason: InstalledPackageStatus_StatusReason = InstalledPackageStatus_StatusReason.STATUS_REASON_UNSPECIFIED,
+ statusReason: InstalledPackageStatus_StatusReason = InstalledPackageStatus_StatusReason.UNSPECIFIED,
): string {
- // The JSON versions of the reasons are forced to follow the standard
- // pattern STATUS_REASON_ by buf.
- const jsonReason = installedPackageStatus_StatusReasonToJSON(statusReason);
- return jsonReason.replace("STATUS_REASON_", "").toLowerCase();
+ const statusReasonName = proto3
+ .getEnumType(InstalledPackageStatus_StatusReason)
+ .findNumber(statusReason)!.name;
+ return statusReasonName.toString().replace("STATUS_REASON_", "").toLowerCase();
}
export function getSupportedPackageRepositoryAuthTypes(
@@ -248,27 +246,27 @@ export function getSupportedPackageRepositoryAuthTypes(
switch (plugin.name) {
case PluginNames.PACKAGES_HELM:
return [
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_AUTHORIZATION_HEADER,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BEARER,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON,
+ PackageRepositoryAuth_PackageRepositoryAuthType.AUTHORIZATION_HEADER,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BEARER,
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON,
];
case PluginNames.PACKAGES_FLUX:
switch (type) {
case RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_HELM:
return [
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_TLS,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.TLS,
];
case RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_OCI:
return [
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON,
];
default:
return [
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_TLS,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.TLS,
];
}
case PluginNames.PACKAGES_KAPP:
@@ -280,27 +278,25 @@ export function getSupportedPackageRepositoryAuthTypes(
// "Secret with auth details. allowed keys: ssh-privatekey, ssh-knownhosts, username, password"
case RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_CARVEL_GIT:
return [
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_SSH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.SSH,
];
// "Secret may include one or more keys: username, password"
case RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_CARVEL_HTTP:
- return [
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- ];
+ return [PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH];
// "Secret may include one or more keys: username, password, token"
case RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_CARVEL_IMAGE:
return [
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BEARER,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BEARER,
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON,
];
// "Secret may include one or more keys: username, password, token"
case RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_CARVEL_IMGPKGBUNDLE:
return [
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_BEARER,
- PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_DOCKER_CONFIG_JSON,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BASIC_AUTH,
+ PackageRepositoryAuth_PackageRepositoryAuthType.BEARER,
+ PackageRepositoryAuth_PackageRepositoryAuthType.DOCKER_CONFIG_JSON,
];
// inline is not supported for write
case RepositoryStorageTypes.PACKAGE_REPOSITORY_STORAGE_CARVEL_INLINE:
@@ -357,11 +353,11 @@ export function getGlobalNamespaceOrNamespace(
// See https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
// See https://github.com/grpc-ecosystem/grpc-gateway/blob/master/runtime/errors.go
export function convertGrpcAuthError(e: any): CustomError | any {
- const msg = e?.metadata?.headersMap?.["grpc-message"].toString();
+ const msg = (e?.metadata?.get("grpc-message") || "").toString();
switch (e?.code) {
- case grpc.Code.Unauthenticated:
+ case Code.Unauthenticated:
return new UnauthorizedNetworkError(msg);
- case grpc.Code.FailedPrecondition:
+ case Code.FailedPrecondition:
// Use `FAILED_PRECONDITION` if the client should not retry until the system state has been explicitly fixed.
//TODO(agamez): this code shouldn't be returned by the API, but it is
if (["credentials", "unauthorized"].some(p => msg?.toLowerCase()?.includes(p))) {
@@ -369,43 +365,41 @@ export function convertGrpcAuthError(e: any): CustomError | any {
} else {
return new BadRequestNetworkError(msg);
}
- case grpc.Code.Internal:
+ case Code.Internal:
//TODO(agamez): this code shouldn't be returned by the API, but it is
if (["credentials", "unauthorized"].some(p => msg?.toLowerCase()?.includes(p))) {
return new UnauthorizedNetworkError(msg);
} else {
return new InternalServerNetworkError(msg);
}
- case grpc.Code.PermissionDenied:
+ case Code.PermissionDenied:
return new ForbiddenNetworkError(msg);
- case grpc.Code.NotFound:
+ case Code.NotFound:
return new NotFoundNetworkError(msg);
- case grpc.Code.AlreadyExists:
+ case Code.AlreadyExists:
return new ConflictNetworkError(msg);
- case grpc.Code.InvalidArgument:
+ case Code.InvalidArgument:
return new BadRequestNetworkError(msg);
- case grpc.Code.DeadlineExceeded:
+ case Code.DeadlineExceeded:
return new GatewayTimeoutNetworkError(msg);
- case grpc.Code.ResourceExhausted:
+ case Code.ResourceExhausted:
return new TooManyRequestsNetworkError(msg);
- case grpc.Code.Aborted:
+ case Code.Aborted:
// Use `ABORTED` if the client should retry at a higher level
return new ConflictNetworkError(msg);
- case grpc.Code.Unimplemented:
+ case Code.Unimplemented:
return new NotImplementedNetworkError(msg);
- case grpc.Code.OutOfRange:
+ case Code.OutOfRange:
return new BadRequestNetworkError(msg);
- case grpc.Code.Unavailable:
+ case Code.Unavailable:
// Use `UNAVAILABLE` if the client can retry just the failing call.
return new ServerUnavailableNetworkError(msg);
- case grpc.Code.DataLoss:
+ case Code.DataLoss:
return new InternalServerNetworkError(msg);
- case grpc.Code.Unknown:
+ case Code.Unknown:
return new InternalServerNetworkError(msg);
- case grpc.Code.Canceled:
+ case Code.Canceled:
return new RequestTimeoutNetworkError(msg);
- case grpc.Code.OK:
- return undefined;
default:
return e;
}
diff --git a/integration/tests/utils/kubeapps-login.js b/integration/tests/utils/kubeapps-login.js
index 102aed05fbf..abcad05e6ff 100644
--- a/integration/tests/utils/kubeapps-login.js
+++ b/integration/tests/utils/kubeapps-login.js
@@ -42,7 +42,6 @@ exports.KubeappsLogin = class KubeappsLogin {
console.log("Logging out of Kubeapps");
await this.page.click(".dropdown.kubeapps-menu .kubeapps-nav-link");
await this.page.click('cds-button:has-text("Log out")');
- await this.page.waitForLoadState("networkidle");
console.log("Logged out of Kubeapps");
}
@@ -51,7 +50,6 @@ exports.KubeappsLogin = class KubeappsLogin {
// Go to Home page
await this.page.goto(utils.getUrl("/"));
- await this.page.waitForLoadState("networkidle");
// Click to Log in with OIDC provider
await this.page.click("text=Login via OIDC Provider");