diff --git a/dashboard/package.json b/dashboard/package.json index 65027d7b289..a1c904ae786 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -139,7 +139,7 @@ "!src/**/*.d.ts" ], "transformIgnorePatterns": [ - "node_modules/(?!@cds|@clr|@lit|axios|bail|ccount|cds|character-entities|comma-separated-tokens|decode-named-character-reference|escape-string-regexp|hast-util-whitespace|is-plain-obj|lit|lodash-es|markdown-table|mdast-util-definitions|mdast-util-find-and-replace|mdast-util-from-markdown|mdast-util-gfm-autolink-literal|mdast-util-gfm|mdast-util-to-hast|mdast-util-to-markdown|mdast-util-to-string|micromark-core-commonmark|monaco-editor|react-monaco-editor|micromark|parse-entities|property-information|ramda|react-markdown|react-syntax-highlighter|remark-breaks|remark-gfm|remark-parse|remark-rehype|space-separated-tokens|swagger-client|swagger-ui-react|trim-lines|trough|unified|unist-builder|unist-util-generated|unist-util-is|unist-util-position|unist-util-stringify-position|unist-util-visit-parents|unist-util-visit|util-find-and-replace|vfile-message|vfile|.*css)" + "node_modules/(?!@cds|@clr|@lit|@bufbuild|axios|bail|ccount|cds|character-entities|comma-separated-tokens|decode-named-character-reference|escape-string-regexp|hast-util-whitespace|is-plain-obj|lit|lodash-es|markdown-table|mdast-util-definitions|mdast-util-find-and-replace|mdast-util-from-markdown|mdast-util-gfm-autolink-literal|mdast-util-gfm|mdast-util-to-hast|mdast-util-to-markdown|mdast-util-to-string|micromark-core-commonmark|monaco-editor|react-monaco-editor|micromark|parse-entities|property-information|ramda|react-markdown|react-syntax-highlighter|remark-breaks|remark-gfm|remark-parse|remark-rehype|space-separated-tokens|swagger-client|swagger-ui-react|trim-lines|trough|unified|unist-builder|unist-util-generated|unist-util-is|unist-util-position|unist-util-stringify-position|unist-util-visit-parents|unist-util-visit|util-find-and-replace|vfile-message|vfile|.*css)" ] }, "browserslist": { diff --git a/dashboard/src/actions/availablepackages.test.tsx b/dashboard/src/actions/availablepackages.test.tsx index de7f4265d84..92e4501f09c 100644 --- a/dashboard/src/actions/availablepackages.test.tsx +++ b/dashboard/src/actions/availablepackages.test.tsx @@ -9,8 +9,9 @@ import { GetAvailablePackageDetailResponse, GetAvailablePackageSummariesResponse, GetAvailablePackageVersionsResponse, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; -import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins"; + PackageAppVersion, +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; +import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb"; import configureMockStore from "redux-mock-store"; import thunk from "redux-thunk"; import PackagesService from "shared/PackagesService"; @@ -29,21 +30,21 @@ const defaultPaginationToken = "defaultPaginationToken"; const defaultSize = 0; const plugin = { name: "my.plugin", version: "0.0.1" } as Plugin; -const defaultAvailablePackageSummary: AvailablePackageSummary = { +const defaultAvailablePackageSummary = 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: plugin, - }, -}; + }), +}); -const defaultAvailablePackageDetail: AvailablePackageDetail = { +const defaultAvailablePackageDetail = new AvailablePackageDetail({ name: "foo", categories: [""], displayName: "foo", @@ -67,7 +68,7 @@ const defaultAvailablePackageDetail: AvailablePackageDetail = { pkgVersion: "1.2.3", appVersion: "4.5.6", }, -}; +}); beforeEach(() => { store = mockStore({ @@ -97,11 +98,11 @@ const nextPageToken = "nextPageToken"; const fetchAvailablePackageSummariesTestCases: IfetchAvailablePackageSummariesTestCase[] = [ { name: "fetches packages with query", - response: { + response: new GetAvailablePackageSummariesResponse({ availablePackageSummaries: [defaultAvailablePackageSummary], nextPageToken, categories: ["foo"], - }, + }), requestedRepos: "", requestedPageToken: currentPageToken, requestedQuery: "foo", @@ -126,11 +127,11 @@ const fetchAvailablePackageSummariesTestCases: IfetchAvailablePackageSummariesTe }, { name: "fetches packages from a repo (first page)", - response: { + response: new GetAvailablePackageSummariesResponse({ availablePackageSummaries: [defaultAvailablePackageSummary], nextPageToken, categories: ["foo"], - }, + }), requestedRepos: repos, requestedPageToken: "", expectedActions: [ @@ -151,11 +152,11 @@ const fetchAvailablePackageSummariesTestCases: IfetchAvailablePackageSummariesTe }, { name: "fetches packages from a repo (middle page)", - response: { + response: new GetAvailablePackageSummariesResponse({ availablePackageSummaries: [defaultAvailablePackageSummary], nextPageToken, categories: ["foo"], - }, + }), requestedRepos: repos, requestedPageToken: currentPageToken, expectedActions: [ @@ -179,11 +180,11 @@ const fetchAvailablePackageSummariesTestCases: IfetchAvailablePackageSummariesTe }, { name: "fetches packages from a repo (last page)", - response: { + response: new GetAvailablePackageSummariesResponse({ availablePackageSummaries: [defaultAvailablePackageSummary], nextPageToken: "", categories: ["foo"], - }, + }), requestedRepos: repos, requestedPageToken: currentPageToken, expectedActions: [ @@ -207,11 +208,11 @@ const fetchAvailablePackageSummariesTestCases: IfetchAvailablePackageSummariesTe }, { name: "fetches packages from a repo (already processed page)", - response: { + response: new GetAvailablePackageSummariesResponse({ availablePackageSummaries: [defaultAvailablePackageSummary], nextPageToken, categories: ["foo"], - }, + }), requestedRepos: repos, requestedPageToken: currentPageToken, expectedActions: [ @@ -235,11 +236,11 @@ const fetchAvailablePackageSummariesTestCases: IfetchAvailablePackageSummariesTe }, { name: "fetches packages from a repo (off-limits page)", - response: { + response: new GetAvailablePackageSummariesResponse({ availablePackageSummaries: [defaultAvailablePackageSummary], nextPageToken: "3", categories: ["foo"], - }, + }), requestedRepos: repos, requestedPageToken: "next-page-token", expectedActions: [ @@ -380,9 +381,9 @@ describe("fetchAvailablePackageSummaries", () => { describe("fetchAvailablePackageVersions", () => { const packageAppVersions = [{ pkgVersion: "1.2.3", appVersion: "4.5.6" }]; - const availableVersionsResponse: GetAvailablePackageVersionsResponse = { + const availableVersionsResponse = new GetAvailablePackageVersionsResponse({ packageAppVersions, - }; + }); let mockGetAvailablePackageVersions: jest.Mock; beforeEach(() => { mockGetAvailablePackageVersions = jest @@ -422,9 +423,9 @@ describe("fetchAvailablePackageVersions", () => { describe("fetchAndSelectAvailablePackageDetail", () => { let mockGetAvailablePackageDetail: jest.Mock; beforeEach(() => { - const response: GetAvailablePackageDetailResponse = { + const response = new GetAvailablePackageDetailResponse({ availablePackageDetail: defaultAvailablePackageDetail, - }; + }); mockGetAvailablePackageDetail = jest.fn().mockImplementation(() => Promise.resolve(response)); jest .spyOn(PackagesService, "getAvailablePackageDetail") diff --git a/dashboard/src/actions/availablepackages.ts b/dashboard/src/actions/availablepackages.ts index ee7bac65eb7..5835da51c32 100644 --- a/dashboard/src/actions/availablepackages.ts +++ b/dashboard/src/actions/availablepackages.ts @@ -5,7 +5,7 @@ import { AvailablePackageDetail, AvailablePackageReference, GetAvailablePackageVersionsResponse, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { ThunkAction } from "redux-thunk"; import { ActionType, deprecated } from "typesafe-actions"; import PackagesService from "../shared/PackagesService"; diff --git a/dashboard/src/actions/installedpackages.test.tsx b/dashboard/src/actions/installedpackages.test.tsx index 66cefb77cd8..2e4bd545be8 100644 --- a/dashboard/src/actions/installedpackages.test.tsx +++ b/dashboard/src/actions/installedpackages.test.tsx @@ -3,6 +3,7 @@ import { AvailablePackageDetail, + Context, GetInstalledPackageSummariesResponse, InstalledPackageDetail, InstalledPackageReference, @@ -11,8 +12,8 @@ import { InstalledPackageSummary, ReconciliationOptions, 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 { InstalledPackage } from "shared/InstalledPackage"; import { getStore, initialState } from "shared/specs/mountWrapper"; import { IStoreState, PluginNames, UnprocessableEntityError, UpgradeError } from "shared/types"; @@ -40,16 +41,16 @@ beforeEach(() => { }); describe("fetches installed packages", () => { - const validInstalledPackageSummary: InstalledPackageSummary = { - installedPackageRef: { - context: { cluster: "second-cluster", namespace: "my-ns" }, + const validInstalledPackageSummary = new InstalledPackageSummary({ + installedPackageRef: new InstalledPackageReference({ + context: new Context({ cluster: "second-cluster", namespace: "my-ns" }), identifier: "some-name", - }, + }), iconUrl: "", name: "foo", pkgDisplayName: "foo", shortDescription: "some description", - }; + }); let requestInstalledPackageListMock: jest.Mock; const installedPackageSummaries: InstalledPackageSummary[] = [validInstalledPackageSummary]; beforeEach(() => { @@ -333,16 +334,16 @@ describe("rollbackInstalledPackage", () => { ); it("success and re-request apps info", async () => { - const installedPackageDetail = { + const installedPackageDetail = new InstalledPackageDetail({ availablePackageRef: { context: { cluster: "default", namespace: "my-ns" }, identifier: "test", plugin: { name: PluginNames.PACKAGES_HELM, version: "0.0.1" } as Plugin, }, currentVersion: { appVersion: "4.5.6", pkgVersion: "1.2.3" }, - } as InstalledPackageDetail; + }); - const availablePackageDetail = { name: "test" } as AvailablePackageDetail; + const availablePackageDetail = new AvailablePackageDetail({ name: "test" }); InstalledPackage.RollbackInstalledPackage = jest.fn().mockImplementationOnce(() => true); InstalledPackage.GetInstalledPackageDetail = jest.fn().mockReturnValue({ @@ -352,7 +353,7 @@ describe("rollbackInstalledPackage", () => { expect(res).toBe(true); const selectCMD = actions.installedpackages.selectInstalledPackage( - installedPackageDetail as any, + installedPackageDetail, availablePackageDetail, ); const res2 = await store.dispatch(selectCMD); @@ -410,7 +411,7 @@ describe("getInstalledPkgStatus", () => { plugin: { name: "bad-plugin", version: "0.0.1" } as Plugin, } as InstalledPackageReference; const status = { - reason: InstalledPackageStatus_StatusReason.STATUS_REASON_INSTALLED, + reason: InstalledPackageStatus_StatusReason.INSTALLED, } as InstalledPackageStatus; const installedPackageDetail = { status } as InstalledPackageDetail; InstalledPackage.GetInstalledPackageDetail = jest.fn().mockReturnValue({ diff --git a/dashboard/src/actions/installedpackages.ts b/dashboard/src/actions/installedpackages.ts index 8d6cb0b0629..83902616899 100644 --- a/dashboard/src/actions/installedpackages.ts +++ b/dashboard/src/actions/installedpackages.ts @@ -11,7 +11,7 @@ import { InstalledPackageSummary, ReconciliationOptions, VersionReference, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { ThunkAction } from "redux-thunk"; import PackagesService from "shared/PackagesService"; import { diff --git a/dashboard/src/actions/kube.test.tsx b/dashboard/src/actions/kube.test.tsx index 0791538e122..ce4b52f364e 100644 --- a/dashboard/src/actions/kube.test.tsx +++ b/dashboard/src/actions/kube.test.tsx @@ -4,8 +4,8 @@ import { InstalledPackageReference, ResourceRef as APIResourceRef, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; -import { GetResourcesResponse } from "gen/kubeappsapis/plugins/resources/v1alpha1/resources"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; +import { GetResourcesResponse } from "gen/kubeappsapis/plugins/resources/v1alpha1/resources_pb"; import configureMockStore from "redux-mock-store"; import thunk from "redux-thunk"; import { Kube } from "shared/Kube"; diff --git a/dashboard/src/actions/kube.tsx b/dashboard/src/actions/kube.tsx index dce053a2c63..c3299b25913 100644 --- a/dashboard/src/actions/kube.tsx +++ b/dashboard/src/actions/kube.tsx @@ -9,8 +9,8 @@ import { ActionType, deprecated } from "typesafe-actions"; import { ResourceRef as APIResourceRef, InstalledPackageReference, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; -import { GetResourcesResponse } from "gen/kubeappsapis/plugins/resources/v1alpha1/resources"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; +import { GetResourcesResponse } from "gen/kubeappsapis/plugins/resources/v1alpha1/resources_pb"; import actions from "actions"; import { debounce } from "lodash"; diff --git a/dashboard/src/actions/repos.test.tsx b/dashboard/src/actions/repos.test.tsx index 48a917b992d..69a60bd9aff 100644 --- a/dashboard/src/actions/repos.test.tsx +++ b/dashboard/src/actions/repos.test.tsx @@ -5,21 +5,31 @@ import { AvailablePackageReference, Context, InstalledPackageDetail, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { AddPackageRepositoryResponse, DeletePackageRepositoryResponse, + DockerCredentials, GetPackageRepositoryDetailResponse, GetPackageRepositorySummariesResponse, + OpaqueCredentials, PackageRepositoriesPermissions, PackageRepositoryAuth_PackageRepositoryAuthType, PackageRepositoryDetail, PackageRepositoryReference, PackageRepositorySummary, + SecretKeyReference, + SshCredentials, + TlsCertKey, 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"; + UsernamePassword, +} from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb"; +import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb"; +import { + HelmPackageRepositoryCustomDetail, + ImagesPullSecret, + RepositoryFilterRule, +} from "gen/kubeappsapis/plugins/helm/packages/v1alpha1/helm_pb"; import context from "jest-plugin-context"; import configureMockStore from "redux-mock-store"; import thunk from "redux-thunk"; @@ -135,23 +145,25 @@ interface ITestCase { } const pkgRepoFormData = { + isUserManaged: false, plugin: plugin, authHeader: "", - authMethod: - PackageRepositoryAuth_PackageRepositoryAuthType.PACKAGE_REPOSITORY_AUTH_TYPE_UNSPECIFIED, - basicAuth: { + authMethod: PackageRepositoryAuth_PackageRepositoryAuthType.UNSPECIFIED, + basicAuth: new UsernamePassword({ password: "", username: "", - }, + }), customCA: "", - customDetail: { + customDetail: new HelmPackageRepositoryCustomDetail({ imagesPullSecret: { - secretRef: "repo-1", - credentials: { server: "", username: "", password: "", email: "" }, + dockerRegistryCredentialOneOf: { + case: "secretRef", + value: "repo-1", + }, }, ociRepositories: [], performValidation: false, - filterRules: [], + filterRule: new RepositoryFilterRule(), tolerations: [], nodeSelector: {}, securityContext: { @@ -163,14 +175,14 @@ const pkgRepoFormData = { httpsProxy: "", noProxy: "", }, - } as HelmPackageRepositoryCustomDetail, + }), description: "", - dockerRegCreds: { + dockerRegCreds: new DockerCredentials({ password: "", username: "", email: "", server: "", - }, + }), interval: "", name: "", passCredentials: false, @@ -179,17 +191,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: "my-namespace", isNamespaceScoped: true, } as IPkgRepoFormData; @@ -606,10 +618,12 @@ describe("addRepo", () => { ...pkgRepoFormData, customDetail: { ...pkgRepoFormData.customDetail, - imagesPullSecret: { - secretRef: "repo-1", - credentials: { server: "", username: "", password: "", email: "" }, - }, + imagesPullSecret: new ImagesPullSecret({ + dockerRegistryCredentialOneOf: { + case: "secretRef", + value: "repo-1", + }, + }), }, }), ); @@ -619,8 +633,10 @@ describe("addRepo", () => { customDetail: { ...pkgRepoFormData.customDetail, imagesPullSecret: { - secretRef: "repo-1", - credentials: { server: "", username: "", password: "", email: "" }, + dockerRegistryCredentialOneOf: { + case: "secretRef", + value: "repo-1", + }, }, }, }); @@ -642,12 +658,15 @@ describe("addRepo", () => { describe("updateRepo", () => { it("updates a repo with an auth header", async () => { - const pkgRepoDetail = { + const pkgRepoDetail = new PackageRepositoryDetail({ ...packageRepositoryDetail, auth: { - header: "foo", + packageRepoAuthOneOf: { + case: "header", + value: "foo", + }, }, - } as PackageRepositoryDetail; + }); PackageRepositoriesService.updatePackageRepository = jest.fn().mockReturnValue({ packageRepoRef: pkgRepoDetail.packageRepoRef, @@ -680,14 +699,19 @@ describe("updateRepo", () => { }); it("updates a repo with an customCA", async () => { - const pkgRepoDetail = { + const pkgRepoDetail = new PackageRepositoryDetail({ ...packageRepositoryDetail, tlsConfig: { - secretRef: { name: "pkgrepo-repo-abc", key: "data" }, - certAuthority: "", + packageRepoTlsConfigOneOf: { + case: "secretRef", + value: new SecretKeyReference({ + name: "pkgrepo-repo-abc", + key: "data", + }), + }, insecureSkipVerify: false, }, - } as PackageRepositoryDetail; + }); PackageRepositoriesService.updatePackageRepository = jest.fn().mockReturnValue({ packageRepoRef: packageRepositoryDetail.packageRepoRef, } as UpdatePackageRepositoryResponse); @@ -843,7 +867,7 @@ describe("findPackageInRepo", () => { it("fetches repos permissions", async () => { const permissions = [ - { + new PackageRepositoriesPermissions({ plugin: plugin, global: { create: true, @@ -857,7 +881,7 @@ describe("findPackageInRepo", () => { list: true, update: true, }, - }, + }), ] as PackageRepositoriesPermissions[]; PackageRepositoriesService.getRepositoriesPermissions = jest.fn().mockReturnValue(permissions); diff --git a/dashboard/src/actions/repos.ts b/dashboard/src/actions/repos.ts index 11922e789e1..6e447d7880b 100644 --- a/dashboard/src/actions/repos.ts +++ b/dashboard/src/actions/repos.ts @@ -5,13 +5,13 @@ import { AvailablePackageReference, Context, InstalledPackageDetail, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { PackageRepositoriesPermissions, PackageRepositoryDetail, PackageRepositoryReference, PackageRepositorySummary, -} from "gen/kubeappsapis/core/packages/v1alpha1/repositories"; +} from "gen/kubeappsapis/core/packages/v1alpha1/repositories_pb"; import { uniqBy } from "lodash"; import { ThunkAction } from "redux-thunk"; import { PackageRepositoriesService } from "shared/PackageRepositoriesService"; @@ -85,10 +85,12 @@ export const fetchRepoSummaries = ( } = getState(); try { dispatch(requestRepoSummaries(namespace)); - const repos = await PackageRepositoriesService.getPackageRepositorySummaries({ - cluster: namespace ? currentCluster : kubeappsCluster, - namespace: namespace, - }); + const repos = await PackageRepositoriesService.getPackageRepositorySummaries( + new Context({ + cluster: namespace ? currentCluster : kubeappsCluster, + namespace: namespace, + }), + ); if (!listGlobal || [helmGlobalNamespace, carvelGlobalNamespace].includes(namespace)) { dispatch(receiveRepoSummaries(repos.packageRepositorySummaries)); } else { @@ -98,10 +100,12 @@ export const fetchRepoSummaries = ( let totalRepos = repos.packageRepositorySummaries; dispatch(requestRepoSummaries("")); // Global repos are only related to the Kubeapps cluster - const globalRepos = await PackageRepositoriesService.getPackageRepositorySummaries({ - cluster: kubeappsCluster, - namespace: "", - }); + const globalRepos = await PackageRepositoriesService.getPackageRepositorySummaries( + new Context({ + cluster: kubeappsCluster, + namespace: "", + }), + ); // Avoid adding duplicated repos: if two repos have the same uid, filter out totalRepos = uniqBy( totalRepos.concat(globalRepos.packageRepositorySummaries), @@ -267,11 +271,13 @@ export const findPackageInRepo = ( // Check if we have enough data to retrieve the package manually (instead of using its own availablePackageRef) if (app?.availablePackageRef?.identifier && app?.availablePackageRef?.plugin) { const getPackageRepositoryDetailResponse = - await PackageRepositoriesService.getPackageRepositoryDetail({ - identifier: repoName, - context: { cluster, namespace: repoNamespace }, - plugin: app.availablePackageRef.plugin, - }); + await PackageRepositoriesService.getPackageRepositoryDetail( + new PackageRepositoryReference({ + identifier: repoName, + context: new Context({ cluster, namespace: repoNamespace }), + plugin: app.availablePackageRef.plugin, + }), + ); try { await PackagesService.getAvailablePackageVersions({ context: { cluster: cluster, namespace: repoNamespace }, @@ -342,7 +348,7 @@ export const fetchReposPermissions = ( export const convertPkgRepoDetailToSummary = ( repoDetail: PackageRepositoryDetail, ): PackageRepositorySummary => { - const repoSummary: PackageRepositorySummary = { + const repoSummary = new PackageRepositorySummary({ description: repoDetail.description, name: repoDetail.name, type: repoDetail.type, @@ -351,6 +357,6 @@ export const convertPkgRepoDetailToSummary = ( requiresAuth: !!repoDetail.auth, packageRepoRef: repoDetail.packageRepoRef, status: repoDetail.status, - }; + }); return repoSummary; }; diff --git a/dashboard/src/components/AppList/AppList.test.tsx b/dashboard/src/components/AppList/AppList.test.tsx index bfe4d500bfb..9671144546f 100644 --- a/dashboard/src/components/AppList/AppList.test.tsx +++ b/dashboard/src/components/AppList/AppList.test.tsx @@ -13,8 +13,8 @@ import { InstalledPackageSummary, 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 context from "jest-plugin-context"; import qs from "qs"; import React from "react"; @@ -227,15 +227,14 @@ context("when apps available", () => { state.apps.listOverview = [ { name: "foo", - installedPackageRef: { + installedPackageRef: new InstalledPackageReference({ identifier: "bar/foo", - pkgVersion: "1.0.0", context: { cluster: "", namespace: "foobar" } as Context, plugin: { name: "my.plugin", version: "0.0.1" } as Plugin, - } as InstalledPackageReference, + }), status: { ready: true, - reason: InstalledPackageStatus_StatusReason.STATUS_REASON_INSTALLED, + reason: InstalledPackageStatus_StatusReason.INSTALLED, userReason: "deployed", } as InstalledPackageStatus, latestMatchingVersion: { appVersion: "0.1.0", pkgVersion: "1.0.0" } as PackageAppVersion, @@ -260,15 +259,14 @@ context("when apps available", () => { state.apps.listOverview = [ { name: "foo", - installedPackageRef: { + installedPackageRef: new InstalledPackageReference({ identifier: "foo/bar", - pkgVersion: "1.0.0", context: { cluster: "", namespace: "fooNs" } as Context, plugin: { name: "my.plugin", version: "0.0.1" } as Plugin, - } as InstalledPackageReference, + }), status: { ready: true, - reason: InstalledPackageStatus_StatusReason.STATUS_REASON_INSTALLED, + reason: InstalledPackageStatus_StatusReason.INSTALLED, userReason: "deployed", } as InstalledPackageStatus, latestMatchingVersion: { appVersion: "0.1.0", pkgVersion: "1.0.0" } as PackageAppVersion, @@ -278,15 +276,14 @@ context("when apps available", () => { } as InstalledPackageSummary, { name: "bar", - installedPackageRef: { + installedPackageRef: new InstalledPackageReference({ identifier: "foobar/bar", - pkgVersion: "1.0.0", context: { cluster: "", namespace: "fooNs" } as Context, plugin: { name: "my.plugin", version: "0.0.1" } as Plugin, - } as InstalledPackageReference, + }), status: { ready: true, - reason: InstalledPackageStatus_StatusReason.STATUS_REASON_INSTALLED, + reason: InstalledPackageStatus_StatusReason.INSTALLED, userReason: "deployed", } as InstalledPackageStatus, latestMatchingVersion: { appVersion: "0.1.0", pkgVersion: "1.0.0" } as PackageAppVersion, @@ -311,15 +308,14 @@ context("when apps available", () => { state.apps.listOverview = [ { name: "foo", - installedPackageRef: { + installedPackageRef: new InstalledPackageReference({ identifier: "foo/bar", - pkgVersion: "1.0.0", context: { cluster: "", namespace: "fooNs" } as Context, plugin: { name: "my.plugin", version: "0.0.1" } as Plugin, - } as InstalledPackageReference, + }), status: { ready: true, - reason: InstalledPackageStatus_StatusReason.STATUS_REASON_INSTALLED, + reason: InstalledPackageStatus_StatusReason.INSTALLED, userReason: "deployed", } as InstalledPackageStatus, latestMatchingVersion: { appVersion: "0.1.0", pkgVersion: "1.0.0" } as PackageAppVersion, @@ -329,15 +325,14 @@ context("when apps available", () => { } as InstalledPackageSummary, { name: "bar", - installedPackageRef: { + installedPackageRef: new InstalledPackageReference({ identifier: "foobar/bar", - pkgVersion: "1.0.0", context: { cluster: "", namespace: "fooNs" } as Context, plugin: { name: "my.plugin", version: "0.0.1" } as Plugin, - } as InstalledPackageReference, + }), status: { ready: true, - reason: InstalledPackageStatus_StatusReason.STATUS_REASON_INSTALLED, + reason: InstalledPackageStatus_StatusReason.INSTALLED, userReason: "deployed", } as InstalledPackageStatus, latestMatchingVersion: { appVersion: "0.1.0", pkgVersion: "1.0.0" } as PackageAppVersion, @@ -347,15 +342,14 @@ context("when apps available", () => { } as InstalledPackageSummary, { name: "bar", - installedPackageRef: { + installedPackageRef: new InstalledPackageReference({ identifier: "foobar/bar", - pkgVersion: "1.0.0", context: { cluster: "", namespace: "barNs" } as Context, plugin: { name: "my.plugin", version: "0.0.1" } as Plugin, - } as InstalledPackageReference, + }), status: { ready: true, - reason: InstalledPackageStatus_StatusReason.STATUS_REASON_INSTALLED, + reason: InstalledPackageStatus_StatusReason.INSTALLED, userReason: "deployed", } as InstalledPackageStatus, latestMatchingVersion: { appVersion: "0.1.0", pkgVersion: "1.0.0" } as PackageAppVersion, diff --git a/dashboard/src/components/AppList/AppListGrid.tsx b/dashboard/src/components/AppList/AppListGrid.tsx index 88d7be92e58..3cdadb13dc2 100644 --- a/dashboard/src/components/AppList/AppListGrid.tsx +++ b/dashboard/src/components/AppList/AppListGrid.tsx @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import Row from "components/js/Row"; -import { InstalledPackageSummary } from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +import { InstalledPackageSummary } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { Link } from "react-router-dom"; import { IClusterServiceVersion, IResource } from "../../shared/types"; import * as url from "../../shared/url"; diff --git a/dashboard/src/components/AppList/AppListItem.test.tsx b/dashboard/src/components/AppList/AppListItem.test.tsx index 13497163430..1257dab4c91 100644 --- a/dashboard/src/components/AppList/AppListItem.test.tsx +++ b/dashboard/src/components/AppList/AppListItem.test.tsx @@ -11,8 +11,8 @@ import { InstalledPackageSummary, 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 { defaultStore, mountWrapper } from "shared/specs/mountWrapper"; import { app } from "shared/url"; import InfoCard from "../InfoCard/InfoCard"; @@ -22,15 +22,14 @@ const defaultProps = { app: { name: "foo", pkgDisplayName: "foo", - installedPackageRef: { + installedPackageRef: new InstalledPackageReference({ identifier: "foo", - pkgVersion: "1.0.0", context: { cluster: "default", namespace: "package-namespace" } as Context, plugin: { name: "my.plugin", version: "0.0.1" } as Plugin, - } as InstalledPackageReference, + }), status: { ready: true, - reason: InstalledPackageStatus_StatusReason.STATUS_REASON_INSTALLED, + reason: InstalledPackageStatus_StatusReason.INSTALLED, userReason: "deployed", } as InstalledPackageStatus, latestMatchingVersion: { appVersion: "10.0.0", pkgVersion: "1.0.0" } as PackageAppVersion, diff --git a/dashboard/src/components/AppList/AppListItem.tsx b/dashboard/src/components/AppList/AppListItem.tsx index caa2d78b8f5..1ad56a8ae89 100644 --- a/dashboard/src/components/AppList/AppListItem.tsx +++ b/dashboard/src/components/AppList/AppListItem.tsx @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import Tooltip from "components/js/Tooltip"; -import { InstalledPackageSummary } from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +import { InstalledPackageSummary } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { getAppStatusLabel, getPluginIcon, getPluginName } from "shared/utils"; import placeholder from "icons/placeholder.svg"; import * as url from "../../shared/url"; diff --git a/dashboard/src/components/AppUpgrade/AppUpgrade.test.tsx b/dashboard/src/components/AppUpgrade/AppUpgrade.test.tsx index 768471ae523..cae0242eb46 100644 --- a/dashboard/src/components/AppUpgrade/AppUpgrade.test.tsx +++ b/dashboard/src/components/AppUpgrade/AppUpgrade.test.tsx @@ -13,12 +13,12 @@ import { InstalledPackageStatus_StatusReason, PackageAppVersion, VersionReference, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} 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 * as ReactRedux from "react-redux"; import * as ReactRouter from "react-router"; import { MemoryRouter, Route } from "react-router-dom"; @@ -57,19 +57,18 @@ const installedPackage1 = { 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; diff --git a/dashboard/src/components/AppUpgrade/AppUpgrade.tsx b/dashboard/src/components/AppUpgrade/AppUpgrade.tsx index 4af6f8fe248..01bcd4cd350 100644 --- a/dashboard/src/components/AppUpgrade/AppUpgrade.tsx +++ b/dashboard/src/components/AppUpgrade/AppUpgrade.tsx @@ -3,8 +3,8 @@ import actions from "actions"; import Alert from "components/js/Alert"; -import { InstalledPackageReference } from "gen/kubeappsapis/core/packages/v1alpha1/packages"; -import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins"; +import { InstalledPackageReference } 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/AppView/AccessURLTable/AccessURLTable.test.tsx b/dashboard/src/components/AppView/AccessURLTable/AccessURLTable.test.tsx index 231e060710c..b4ff5c50286 100644 --- a/dashboard/src/components/AppView/AccessURLTable/AccessURLTable.test.tsx +++ b/dashboard/src/components/AppView/AccessURLTable/AccessURLTable.test.tsx @@ -4,7 +4,7 @@ import LoadingWrapper from "components/LoadingWrapper/LoadingWrapper"; import context from "jest-plugin-context"; 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 { defaultStore, getStore, mountWrapper } from "shared/specs/mountWrapper"; import { IIngressSpec, IResource, IServiceSpec, IServiceStatus } from "shared/types"; import AccessURLTable from "./AccessURLTable"; diff --git a/dashboard/src/components/AppView/AccessURLTable/AccessURLTable.tsx b/dashboard/src/components/AppView/AccessURLTable/AccessURLTable.tsx index d49828a5ad6..8f77db5e242 100644 --- a/dashboard/src/components/AppView/AccessURLTable/AccessURLTable.tsx +++ b/dashboard/src/components/AppView/AccessURLTable/AccessURLTable.tsx @@ -5,7 +5,7 @@ import Table from "components/js/Table"; import Tooltip from "components/js/Tooltip"; import { get } from "lodash"; import { useSelector } from "react-redux"; -import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { IK8sList, IKubeItem, IResource, IServiceSpec, IStoreState } from "shared/types"; import LoadingWrapper from "../../../components/LoadingWrapper/LoadingWrapper"; import isSomeResourceLoading from "../helpers"; diff --git a/dashboard/src/components/AppView/AppControls/DeleteButton/DeleteButton.test.tsx b/dashboard/src/components/AppView/AppControls/DeleteButton/DeleteButton.test.tsx index 776500dca89..15aa0ee27da 100644 --- a/dashboard/src/components/AppView/AppControls/DeleteButton/DeleteButton.test.tsx +++ b/dashboard/src/components/AppView/AppControls/DeleteButton/DeleteButton.test.tsx @@ -9,7 +9,7 @@ import { InstalledPackageReference, InstalledPackageStatus, InstalledPackageStatus_StatusReason, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { act } from "react-dom/test-utils"; import * as ReactRedux from "react-redux"; import { Tooltip as ReactTooltip } from "react-tooltip"; @@ -81,7 +81,7 @@ it("should render an enabled button and tooltip if when passing a pending status ...defaultProps, releaseStatus: { ready: false, - reason: InstalledPackageStatus_StatusReason.STATUS_REASON_PENDING, + reason: InstalledPackageStatus_StatusReason.PENDING, userReason: "Pending", } as InstalledPackageStatus, }; @@ -96,7 +96,7 @@ it("should render a deactivated button if when passing a uninstalled status", as ...defaultProps, releaseStatus: { ready: false, - reason: InstalledPackageStatus_StatusReason.STATUS_REASON_UNINSTALLED, + reason: InstalledPackageStatus_StatusReason.UNINSTALLED, userReason: "Uninstalling", } as InstalledPackageStatus, }; diff --git a/dashboard/src/components/AppView/AppControls/DeleteButton/DeleteButton.tsx b/dashboard/src/components/AppView/AppControls/DeleteButton/DeleteButton.tsx index bb90be79369..7477ed2cea6 100644 --- a/dashboard/src/components/AppView/AppControls/DeleteButton/DeleteButton.tsx +++ b/dashboard/src/components/AppView/AppControls/DeleteButton/DeleteButton.tsx @@ -9,7 +9,7 @@ import { InstalledPackageReference, InstalledPackageStatus, InstalledPackageStatus_StatusReason, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import { Action } from "redux"; @@ -62,7 +62,7 @@ export default function DeleteButton({ releaseStatus={releaseStatus} id="delete-button" disabled={disabled} - statusesToDeactivate={[InstalledPackageStatus_StatusReason.STATUS_REASON_UNINSTALLED]} + statusesToDeactivate={[InstalledPackageStatus_StatusReason.UNINSTALLED]} > Delete diff --git a/dashboard/src/components/AppView/AppControls/RollbackButton/RollbackButton.test.tsx b/dashboard/src/components/AppView/AppControls/RollbackButton/RollbackButton.test.tsx index 7033d895abf..6e127c29db2 100644 --- a/dashboard/src/components/AppView/AppControls/RollbackButton/RollbackButton.test.tsx +++ b/dashboard/src/components/AppView/AppControls/RollbackButton/RollbackButton.test.tsx @@ -9,8 +9,8 @@ import { InstalledPackageReference, InstalledPackageStatus, InstalledPackageStatus_StatusReason, -} 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 { act } from "react-dom/test-utils"; import * as ReactRedux from "react-redux"; import { Tooltip as ReactTooltip } from "react-tooltip"; @@ -88,7 +88,7 @@ it("should render a deactivated button if when passing an in-progress status", a ...defaultProps, releaseStatus: { ready: false, - reason: InstalledPackageStatus_StatusReason.STATUS_REASON_PENDING, + reason: InstalledPackageStatus_StatusReason.PENDING, userReason: "Pending", } as InstalledPackageStatus, }; diff --git a/dashboard/src/components/AppView/AppControls/RollbackButton/RollbackButton.tsx b/dashboard/src/components/AppView/AppControls/RollbackButton/RollbackButton.tsx index 5f1e63a0355..5565e332c9f 100644 --- a/dashboard/src/components/AppView/AppControls/RollbackButton/RollbackButton.tsx +++ b/dashboard/src/components/AppView/AppControls/RollbackButton/RollbackButton.tsx @@ -6,7 +6,7 @@ import actions from "actions"; import { InstalledPackageReference, InstalledPackageStatus, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import { Action } from "redux"; diff --git a/dashboard/src/components/AppView/AppControls/StatusAwareButton/StatusAwareButton.test.tsx b/dashboard/src/components/AppView/AppControls/StatusAwareButton/StatusAwareButton.test.tsx index 6ab668545ca..093188ea8b5 100644 --- a/dashboard/src/components/AppView/AppControls/StatusAwareButton/StatusAwareButton.test.tsx +++ b/dashboard/src/components/AppView/AppControls/StatusAwareButton/StatusAwareButton.test.tsx @@ -5,7 +5,7 @@ import { CdsButton } from "@cds/react/button"; import { InstalledPackageStatus, InstalledPackageStatus_StatusReason, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { Tooltip as ReactTooltip } from "react-tooltip"; import { defaultStore, mountWrapper } from "shared/specs/mountWrapper"; import StatusAwareButton, { IStatusAwareButtonProps } from "./StatusAwareButton"; @@ -15,18 +15,18 @@ type TProps = IStatusAwareButtonProps & { tooltip?: string; }; -it("tests the disabled flag and tooltip for each release with default and custom status condition", async () => { +describe("tests the disabled flag and tooltip for each release with default and custom status condition", () => { // this should cover all conditions const testsProps: TProps[] = [ { - code: InstalledPackageStatus_StatusReason.STATUS_REASON_PENDING, + code: InstalledPackageStatus_StatusReason.PENDING, disabled: true, tooltip: "The application is pending installation.", id: "", releaseStatus: {} as InstalledPackageStatus, }, { - code: InstalledPackageStatus_StatusReason.STATUS_REASON_UNINSTALLED, + code: InstalledPackageStatus_StatusReason.UNINSTALLED, disabled: true, tooltip: "The application is being deleted.", id: "", @@ -47,65 +47,65 @@ it("tests the disabled flag and tooltip for each release with default and custom releaseStatus: {} as InstalledPackageStatus, }, { - code: InstalledPackageStatus_StatusReason.STATUS_REASON_UNINSTALLED, + code: InstalledPackageStatus_StatusReason.UNINSTALLED, disabled: true, tooltip: "test tooltip for uninstalled", id: "", releaseStatus: {} as InstalledPackageStatus, - statusesToDeactivate: [InstalledPackageStatus_StatusReason.STATUS_REASON_UNINSTALLED], + statusesToDeactivate: [InstalledPackageStatus_StatusReason.UNINSTALLED], statusesToDeactivateTooltips: { - [InstalledPackageStatus_StatusReason.STATUS_REASON_UNINSTALLED]: - "test tooltip for uninstalled", + [InstalledPackageStatus_StatusReason.UNINSTALLED]: "test tooltip for uninstalled", }, }, { - code: InstalledPackageStatus_StatusReason.STATUS_REASON_PENDING, + code: InstalledPackageStatus_StatusReason.PENDING, disabled: false, id: "", releaseStatus: {} as InstalledPackageStatus, - statusesToDeactivate: [InstalledPackageStatus_StatusReason.STATUS_REASON_UNINSTALLED], + statusesToDeactivate: [InstalledPackageStatus_StatusReason.UNINSTALLED], statusesToDeactivateTooltips: { - [InstalledPackageStatus_StatusReason.STATUS_REASON_UNINSTALLED]: - "test tooltip for uninstalled", + [InstalledPackageStatus_StatusReason.UNINSTALLED]: "test tooltip for uninstalled", }, }, ]; for (const testProps of testsProps) { - let releaseStatus; - switch (testProps.code) { - case null: - releaseStatus = null; - break; - case undefined: - releaseStatus = undefined; - break; - default: - releaseStatus = { - reason: testProps.code, - } as InstalledPackageStatus; - } - const wrapper = mountWrapper( - defaultStore, - , - ); + it(`shows tooltip when code is ${testProps.code} and tooltip "${testProps.tooltip}"`, async () => { + let releaseStatus; + switch (testProps.code) { + case null: + releaseStatus = null; + break; + case undefined: + releaseStatus = undefined; + break; + default: + releaseStatus = { + reason: testProps.code, + } as InstalledPackageStatus; + } + const wrapper = mountWrapper( + defaultStore, + , + ); - // test disabled flag - expect(wrapper.find(CdsButton).prop("disabled")).toBe(testProps.disabled); + // test disabled flag + expect(wrapper.find(CdsButton).prop("disabled")).toBe(testProps.disabled); - // test tooltip - const tooltipUI = wrapper.find(ReactTooltip); - if (testProps.tooltip) { - expect(tooltipUI).toExist(); - expect(tooltipUI).toIncludeText(testProps.tooltip); - } else { - expect(tooltipUI.exists()).toBeFalsy(); - } + // test tooltip + const tooltipUI = wrapper.find(ReactTooltip); + if (testProps.tooltip) { + expect(tooltipUI).toExist(); + expect(tooltipUI).toIncludeText(testProps.tooltip); + } else { + expect(tooltipUI.exists()).toBeFalsy(); + } + }); } }); diff --git a/dashboard/src/components/AppView/AppControls/StatusAwareButton/StatusAwareButton.tsx b/dashboard/src/components/AppView/AppControls/StatusAwareButton/StatusAwareButton.tsx index 0759c1b28b3..1ebc623c758 100644 --- a/dashboard/src/components/AppView/AppControls/StatusAwareButton/StatusAwareButton.tsx +++ b/dashboard/src/components/AppView/AppControls/StatusAwareButton/StatusAwareButton.tsx @@ -5,7 +5,7 @@ import { CdsButton } from "@cds/react/button"; import { InstalledPackageStatus, InstalledPackageStatus_StatusReason, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { Tooltip } from "react-tooltip"; export interface IStatusAwareButtonProps { @@ -27,14 +27,12 @@ export default function StatusAwareButton(pro } = props; const defaultStatusesToDeactivate = [ - InstalledPackageStatus_StatusReason.STATUS_REASON_UNINSTALLED, - InstalledPackageStatus_StatusReason.STATUS_REASON_PENDING, + InstalledPackageStatus_StatusReason.UNINSTALLED, + InstalledPackageStatus_StatusReason.PENDING, ]; const defaultStatusesToDeactivateTooltips = { - [InstalledPackageStatus_StatusReason.STATUS_REASON_UNINSTALLED]: - "The application is being deleted.", - [InstalledPackageStatus_StatusReason.STATUS_REASON_PENDING]: - "The application is pending installation.", + [InstalledPackageStatus_StatusReason.UNINSTALLED]: "The application is being deleted.", + [InstalledPackageStatus_StatusReason.PENDING]: "The application is pending installation.", }; // allow buttons to override the default statuses to deactivate diff --git a/dashboard/src/components/AppView/AppControls/UpgradeButton/UpgradeButton.test.tsx b/dashboard/src/components/AppView/AppControls/UpgradeButton/UpgradeButton.test.tsx index fb837bee76c..cdef800a4d9 100644 --- a/dashboard/src/components/AppView/AppControls/UpgradeButton/UpgradeButton.test.tsx +++ b/dashboard/src/components/AppView/AppControls/UpgradeButton/UpgradeButton.test.tsx @@ -7,7 +7,7 @@ import { InstalledPackageReference, InstalledPackageStatus, InstalledPackageStatus_StatusReason, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import * as ReactRedux from "react-redux"; import { Tooltip as ReactTooltip } from "react-tooltip"; import { defaultStore, mountWrapper } from "shared/specs/mountWrapper"; @@ -43,7 +43,7 @@ it("should render a deactivated button if when passing an in-progress status", a ...defaultProps, releaseStatus: { ready: false, - reason: InstalledPackageStatus_StatusReason.STATUS_REASON_PENDING, + reason: InstalledPackageStatus_StatusReason.PENDING, userReason: "Pending", } as InstalledPackageStatus, }; diff --git a/dashboard/src/components/AppView/AppControls/UpgradeButton/UpgradeButton.tsx b/dashboard/src/components/AppView/AppControls/UpgradeButton/UpgradeButton.tsx index d6a126aafc4..af6a634e8dc 100644 --- a/dashboard/src/components/AppView/AppControls/UpgradeButton/UpgradeButton.tsx +++ b/dashboard/src/components/AppView/AppControls/UpgradeButton/UpgradeButton.tsx @@ -5,7 +5,7 @@ import { CdsIcon } from "@cds/react/icon"; import { InstalledPackageReference, InstalledPackageStatus, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { Link } from "react-router-dom"; import * as url from "../../../../shared/url"; import StatusAwareButton from "../StatusAwareButton/StatusAwareButton"; diff --git a/dashboard/src/components/AppView/AppSecrets/AppSecrets.test.tsx b/dashboard/src/components/AppView/AppSecrets/AppSecrets.test.tsx index f6a499ca757..8089b1197e3 100644 --- a/dashboard/src/components/AppView/AppSecrets/AppSecrets.test.tsx +++ b/dashboard/src/components/AppView/AppSecrets/AppSecrets.test.tsx @@ -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 { defaultStore, getStore, initialState, mountWrapper } from "shared/specs/mountWrapper"; import { ISecret, IStoreState } from "shared/types"; import SecretItemDatum from "../ResourceTable/ResourceItem/SecretItem/SecretItemDatum"; diff --git a/dashboard/src/components/AppView/AppSecrets/AppSecrets.tsx b/dashboard/src/components/AppView/AppSecrets/AppSecrets.tsx index 057fe11733d..973c518a290 100644 --- a/dashboard/src/components/AppView/AppSecrets/AppSecrets.tsx +++ b/dashboard/src/components/AppView/AppSecrets/AppSecrets.tsx @@ -4,7 +4,7 @@ import LoadingWrapper from "components/LoadingWrapper"; import { isEmpty } from "lodash"; import { useSelector } from "react-redux"; -import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { ISecret, IStoreState } from "shared/types"; import SecretItemDatum from "../ResourceTable/ResourceItem/SecretItem/SecretItemDatum"; import "./AppSecrets.css"; diff --git a/dashboard/src/components/AppView/AppView.test.tsx b/dashboard/src/components/AppView/AppView.test.tsx index 62d6a4bd630..231101cbe52 100644 --- a/dashboard/src/components/AppView/AppView.test.tsx +++ b/dashboard/src/components/AppView/AppView.test.tsx @@ -20,8 +20,8 @@ import { PackageAppVersion, ResourceRef, 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 { act } from "react-dom/test-utils"; import { MemoryRouter, Route } from "react-router-dom"; import { IConfigState } from "reducers/config"; @@ -29,6 +29,7 @@ import { InstalledPackage } from "shared/InstalledPackage"; import PackagesService from "shared/PackagesService"; import { getStore, mountWrapper } from "shared/specs/mountWrapper"; import { + CustomInstalledPackageDetail, DeleteError, FetchError, IInstalledPackageState, @@ -55,7 +56,7 @@ const routeParams = { const routePathParam = `/c/${routeParams.cluster}/ns/${routeParams.namespace}/apps/${routeParams.plugin.name}/${routeParams.plugin.version}/${routeParams.releaseName}`; const routePath = "/c/:cluster/ns/:namespace/apps/:pluginName/:pluginVersion/:releaseName"; -const installedPackage = { +const installedPackage = new InstalledPackageDetail({ name: "test", postInstallationNotes: "test", valuesApplied: "test", @@ -65,24 +66,23 @@ const installedPackage = { context: { cluster: "", namespace: "chart-namespace" } as Context, } as AvailablePackageReference, currentVersion: { appVersion: "10.0.0", pkgVersion: "1.0.0" } as PackageAppVersion, - installedPackageRef: { + installedPackageRef: new InstalledPackageReference({ identifier: "apache/1", - pkgVersion: "1.0.0", context: { cluster: "", namespace: "package-namespace" } 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 InstalledPackageDetail; +}); -const availablePackageDetail = { +const availablePackageDetail = new AvailablePackageDetail({ displayName: "my-cool-package-1", availablePackageRef: { identifier: "apache/1", @@ -90,47 +90,45 @@ const availablePackageDetail = { context: { cluster: "", namespace: "chart-namespace" } as Context, } as AvailablePackageReference, version: { appVersion: "4.5.6", pkgVersion: "1.2.3" }, -} as AvailablePackageDetail; +}); const resourceRefs = { - configMap: { apiVersion: "v1", kind: "ConfigMap", name: "cm-one" } as ResourceRef, - deployment: { + configMap: new ResourceRef({ apiVersion: "v1", kind: "ConfigMap", name: "cm-one" }), + deployment: new ResourceRef({ apiVersion: "apps/v1", kind: "Deployment", name: "deployment-one", - } as ResourceRef, - service: { apiVersion: "v1", kind: "Service", name: "svc-one" } as ResourceRef, - ingress: { + }), + service: new ResourceRef({ apiVersion: "v1", kind: "Service", name: "svc-one" }), + ingress: new ResourceRef({ apiVersion: "extensions/v1", kind: "Ingress", name: "ingress-one", - } as ResourceRef, - secret: { + }), + secret: new ResourceRef({ apiVersion: "v1", kind: "Secret", name: "secret-one", - } as ResourceRef, - daemonset: { + }), + daemonset: new ResourceRef({ apiVersion: "apps/v1", kind: "DaemonSet", name: "daemonset-one", - } as ResourceRef, - statefulset: { + }), + statefulset: new ResourceRef({ apiVersion: "apps/v1", kind: "StatefulSet", name: "statefulset-one", - } as ResourceRef, + }), }; const validState = { apps: { isFetching: false, items: [installedPackage], - selected: { + selected: new CustomInstalledPackageDetail(1, { ...installedPackage, - resourceRefs: [resourceRefs.configMap] as ResourceRef[], - revision: 1, - }, + }), } as IInstalledPackageState, }; @@ -138,7 +136,7 @@ beforeEach(() => { InstalledPackage.GetInstalledPackageResourceRefs = jest .fn() .mockReturnValue( - Promise.resolve({ resourceRefs: [] } as GetInstalledPackageResourceRefsResponse), + Promise.resolve(new GetInstalledPackageResourceRefsResponse({ resourceRefs: [] })), ); InstalledPackage.GetInstalledPackageDetail = jest.fn().mockReturnValue( Promise.resolve({ diff --git a/dashboard/src/components/AppView/AppView.tsx b/dashboard/src/components/AppView/AppView.tsx index 6c9b6c418ea..0f99482df81 100644 --- a/dashboard/src/components/AppView/AppView.tsx +++ b/dashboard/src/components/AppView/AppView.tsx @@ -13,8 +13,8 @@ import { push } from "connected-react-router"; import { InstalledPackageReference, ResourceRef, -} 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 placeholder from "icons/placeholder.svg"; import { useEffect, useMemo, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; diff --git a/dashboard/src/components/AppView/CustomAppView/CustomAppView.test.tsx b/dashboard/src/components/AppView/CustomAppView/CustomAppView.test.tsx index cdce521e6f1..7aee4aea770 100644 --- a/dashboard/src/components/AppView/CustomAppView/CustomAppView.test.tsx +++ b/dashboard/src/components/AppView/CustomAppView/CustomAppView.test.tsx @@ -4,8 +4,8 @@ import { InstalledPackageDetail, AvailablePackageDetail, - ResourceRef, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; +import ResourceRef from "shared/ResourceRef"; import { getStore, initialState, mountWrapper } from "shared/specs/mountWrapper"; import { IStoreState } from "shared/types"; import CustomAppView from "."; @@ -25,15 +25,12 @@ const defaultProps = { resourceRefs: { ingresses: [] as ResourceRef[], deployments: [ - { - cluster: "default", + new ResourceRef("default", "deployments", true, "demo-namespace", { apiVersion: "apps/v1", kind: "Deployment", - plural: "deployments", - namespaced: true, name: "ssh-server-example", namespace: "demo-namespace", - } as ResourceRef, + }), ] as ResourceRef[], statefulsets: [] as ResourceRef[], daemonsets: [] as ResourceRef[], diff --git a/dashboard/src/components/AppView/CustomAppView/CustomAppView.tsx b/dashboard/src/components/AppView/CustomAppView/CustomAppView.tsx index 522a02dc31f..f586164bce6 100644 --- a/dashboard/src/components/AppView/CustomAppView/CustomAppView.tsx +++ b/dashboard/src/components/AppView/CustomAppView/CustomAppView.tsx @@ -6,7 +6,7 @@ import { push } from "connected-react-router"; import { AvailablePackageDetail, InstalledPackageDetail, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { useCallback, useMemo } from "react"; import { useDispatch, useSelector } from "react-redux"; import { CustomComponent } from "RemoteComponent"; diff --git a/dashboard/src/components/AppView/PackageInfo/PackageInfo.test.tsx b/dashboard/src/components/AppView/PackageInfo/PackageInfo.test.tsx index 5e196e091a9..cfedcc30e0b 100644 --- a/dashboard/src/components/AppView/PackageInfo/PackageInfo.test.tsx +++ b/dashboard/src/components/AppView/PackageInfo/PackageInfo.test.tsx @@ -13,8 +13,8 @@ import { PackageAppVersion, ReconciliationOptions, 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 context from "jest-plugin-context"; import { defaultStore, mountWrapper } from "shared/specs/mountWrapper"; import PackageInfo from "./PackageInfo"; @@ -30,18 +30,17 @@ const defaultProps = { 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: "apache/1", - pkgVersion: "1.0.0", context: { cluster: "", namespace: "package-namespace" } 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, status: { ready: true, - reason: InstalledPackageStatus_StatusReason.STATUS_REASON_INSTALLED, + reason: InstalledPackageStatus_StatusReason.INSTALLED, userReason: "deployed", } as InstalledPackageStatus, } as InstalledPackageDetail, @@ -59,10 +58,13 @@ it("renders an app item", () => { context("PackageUpdateInfo: when information about updates is available", () => { it("renders an up to date message if there are no updates", () => { - const appWithoutUpdates = { + const appWithoutUpdates = new InstalledPackageDetail({ ...defaultProps.installedPackageDetail, - updateInfo: { upToDate: true }, - } as InstalledPackageDetail; + latestVersion: { + pkgVersion: "1.0.0", + appVersion: "10.0.0", + }, + }); const wrapper = mountWrapper( defaultStore, , diff --git a/dashboard/src/components/AppView/PackageInfo/PackageInfo.tsx b/dashboard/src/components/AppView/PackageInfo/PackageInfo.tsx index cc4b10cdfc7..b9e7db7554c 100644 --- a/dashboard/src/components/AppView/PackageInfo/PackageInfo.tsx +++ b/dashboard/src/components/AppView/PackageInfo/PackageInfo.tsx @@ -5,7 +5,7 @@ import { AvailablePackageDetail, InstalledPackageDetail, InstalledPackageStatus_StatusReason, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import PackageUpdateInfo from "./PackageUpdateInfo"; import { getAppStatusLabel } from "shared/utils"; @@ -25,7 +25,7 @@ function PackageInfo({ installedPackageDetail, availablePackageDetail }: IPackag Status: {getAppStatusLabel(installedPackageDetail.status.reason)} {installedPackageDetail.status.reason !== - InstalledPackageStatus_StatusReason.STATUS_REASON_INSTALLED && ( + InstalledPackageStatus_StatusReason.INSTALLED && (
{installedPackageDetail.status.userReason}
)} diff --git a/dashboard/src/components/AppView/PackageInfo/PackageUpdateInfo.tsx b/dashboard/src/components/AppView/PackageInfo/PackageUpdateInfo.tsx index c43cdcf7b1f..9c0f9250007 100644 --- a/dashboard/src/components/AppView/PackageInfo/PackageUpdateInfo.tsx +++ b/dashboard/src/components/AppView/PackageInfo/PackageUpdateInfo.tsx @@ -3,7 +3,7 @@ import { CdsIcon } from "@cds/react/icon"; 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 { Link } from "react-router-dom"; import { app as appURL } from "shared/url"; interface IPackageUpdateInfoProps { diff --git a/dashboard/src/components/AppView/ResourceTable/ResourceTable.test.tsx b/dashboard/src/components/AppView/ResourceTable/ResourceTable.test.tsx index 9c73f632a2d..ffe873eaee1 100644 --- a/dashboard/src/components/AppView/ResourceTable/ResourceTable.test.tsx +++ b/dashboard/src/components/AppView/ResourceTable/ResourceTable.test.tsx @@ -3,7 +3,7 @@ import Table from "components/js/Table"; import LoadingWrapper from "components/LoadingWrapper/LoadingWrapper"; -import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { keyForResourceRef } from "shared/ResourceRef"; import { getStore, initialState, mountWrapper } from "shared/specs/mountWrapper"; import { IResource, IStoreState } from "shared/types"; diff --git a/dashboard/src/components/AppView/ResourceTable/ResourceTable.tsx b/dashboard/src/components/AppView/ResourceTable/ResourceTable.tsx index 40d0a933d22..13384e4de83 100644 --- a/dashboard/src/components/AppView/ResourceTable/ResourceTable.tsx +++ b/dashboard/src/components/AppView/ResourceTable/ResourceTable.tsx @@ -6,7 +6,7 @@ import Table from "components/js/Table"; import LoadingWrapper from "components/LoadingWrapper/LoadingWrapper"; import { useMemo } from "react"; import { useSelector } from "react-redux"; -import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { IKubeItem, IResource, ISecret, IStoreState } from "shared/types"; import { DaemonSetColumns } from "./ResourceData/DaemonSet"; import { DeploymentColumns } from "./ResourceData/Deployment"; diff --git a/dashboard/src/components/AppView/ResourceTabs/ResourceTabs.test.tsx b/dashboard/src/components/AppView/ResourceTabs/ResourceTabs.test.tsx index a6229548ca9..7ec21749c36 100644 --- a/dashboard/src/components/AppView/ResourceTabs/ResourceTabs.test.tsx +++ b/dashboard/src/components/AppView/ResourceTabs/ResourceTabs.test.tsx @@ -3,7 +3,7 @@ import Tabs from "components/Tabs"; import { shallow } from "enzyme"; -import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import ResourceTabs from "./ResourceTabs"; const sampleResourceRef = { diff --git a/dashboard/src/components/AppView/ResourceTabs/ResourceTabs.tsx b/dashboard/src/components/AppView/ResourceTabs/ResourceTabs.tsx index 05847e28c5d..2b1841536cc 100644 --- a/dashboard/src/components/AppView/ResourceTabs/ResourceTabs.tsx +++ b/dashboard/src/components/AppView/ResourceTabs/ResourceTabs.tsx @@ -3,7 +3,7 @@ import Tabs from "components/Tabs"; import ResourceTable from "components/AppView/ResourceTable"; -import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +import { ResourceRef } from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; interface IAppViewResourceRefs { deployments: ResourceRef[]; diff --git a/dashboard/src/components/ApplicationStatus/ApplicationStatus.test.tsx b/dashboard/src/components/ApplicationStatus/ApplicationStatus.test.tsx index b5db246584e..31a146e6a18 100644 --- a/dashboard/src/components/ApplicationStatus/ApplicationStatus.test.tsx +++ b/dashboard/src/components/ApplicationStatus/ApplicationStatus.test.tsx @@ -6,7 +6,7 @@ import { InstalledPackageDetail, InstalledPackageStatus, InstalledPackageStatus_StatusReason, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { has } from "lodash"; import { IK8sList, IKubeItem, IResource } from "shared/types"; import ApplicationStatus from "./ApplicationStatus"; @@ -41,7 +41,7 @@ it("renders a deleting status", () => { { status: { ready: false, - reason: InstalledPackageStatus_StatusReason.STATUS_REASON_UNINSTALLED, + reason: InstalledPackageStatus_StatusReason.UNINSTALLED, userReason: "Deleted", } as InstalledPackageStatus, } as InstalledPackageDetail @@ -65,7 +65,7 @@ it("renders a failed status", () => { { status: { ready: false, - reason: InstalledPackageStatus_StatusReason.STATUS_REASON_FAILED, + reason: InstalledPackageStatus_StatusReason.FAILED, userReason: "Failed", } as InstalledPackageStatus, } as InstalledPackageDetail @@ -94,7 +94,7 @@ describe("isFetching", () => { deployed: false, totalPods: 0, readyPods: 0, - infoReason: InstalledPackageStatus_StatusReason.STATUS_REASON_PENDING, + infoReason: InstalledPackageStatus_StatusReason.PENDING, }, { title: "shows a deploying status if there is a non deployed deployment", @@ -117,7 +117,7 @@ describe("isFetching", () => { deployed: false, totalPods: 1, readyPods: 0, - infoReason: InstalledPackageStatus_StatusReason.STATUS_REASON_PENDING, + infoReason: InstalledPackageStatus_StatusReason.PENDING, }, { title: "shows a deploying status if there is a non deployed statefulset", @@ -140,7 +140,7 @@ describe("isFetching", () => { deployed: false, totalPods: 1, readyPods: 0, - infoReason: InstalledPackageStatus_StatusReason.STATUS_REASON_PENDING, + infoReason: InstalledPackageStatus_StatusReason.PENDING, }, { title: "shows a deploying status if there is a non deployed daemonset", @@ -161,7 +161,7 @@ describe("isFetching", () => { deployed: false, totalPods: 1, readyPods: 0, - infoReason: InstalledPackageStatus_StatusReason.STATUS_REASON_PENDING, + infoReason: InstalledPackageStatus_StatusReason.PENDING, }, { title: "shows a deployed status if it has a daemonset, deployment and statefulset deployed", @@ -208,7 +208,7 @@ describe("isFetching", () => { deployed: true, totalPods: 3, readyPods: 3, - infoReason: InstalledPackageStatus_StatusReason.STATUS_REASON_INSTALLED, + infoReason: InstalledPackageStatus_StatusReason.INSTALLED, }, { title: @@ -256,7 +256,7 @@ describe("isFetching", () => { deployed: true, totalPods: 3, readyPods: 2, - infoReason: InstalledPackageStatus_StatusReason.STATUS_REASON_PENDING, + infoReason: InstalledPackageStatus_StatusReason.PENDING, }, { title: @@ -316,7 +316,7 @@ describe("isFetching", () => { deployed: true, totalPods: 3, readyPods: 2, - infoReason: InstalledPackageStatus_StatusReason.STATUS_REASON_PENDING, + infoReason: InstalledPackageStatus_StatusReason.PENDING, }, ]; tests.forEach(t => { diff --git a/dashboard/src/components/ApplicationStatus/ApplicationStatus.tsx b/dashboard/src/components/ApplicationStatus/ApplicationStatus.tsx index 04e78926735..25c38cdef99 100644 --- a/dashboard/src/components/ApplicationStatus/ApplicationStatus.tsx +++ b/dashboard/src/components/ApplicationStatus/ApplicationStatus.tsx @@ -8,7 +8,7 @@ import { InstalledPackageDetail, InstalledPackageStatus, InstalledPackageStatus_StatusReason, -} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; +} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb"; import { flatten, get } from "lodash"; import { useEffect, useState } from "react"; import { PieChart } from "react-minimal-pie-chart"; @@ -46,12 +46,11 @@ function flattenItemList(items: Array ); } - if (info?.status?.reason === InstalledPackageStatus_StatusReason.STATUS_REASON_UNINSTALLED) { + if (info?.status?.reason === InstalledPackageStatus_StatusReason.UNINSTALLED) { return (
@@ -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) {