diff --git a/src/brokers/broker-pods/PodsList.container.tsx b/src/brokers/broker-pods/PodsList.container.tsx index c2e33f51..f803caaf 100644 --- a/src/brokers/broker-pods/PodsList.container.tsx +++ b/src/brokers/broker-pods/PodsList.container.tsx @@ -3,7 +3,7 @@ import { K8sResourceCommon, useK8sWatchResource, } from '@openshift-console/dynamic-plugin-sdk'; -import { K8sResourceKind } from '../../k8s/types'; +import { K8sResourceCommonWithData } from '../../k8s/types'; import { useTranslation } from '../../i18n/i18n'; import { PodsList } from './components/PodList'; import { @@ -23,7 +23,7 @@ export const PodsContainer: FC = () => { //states const { t } = useTranslation(); const { ns: namespace, name } = useParams<{ ns?: string; name?: string }>(); - const [brokerPods, setBrokerPods] = useState([]); + const [brokerPods, setBrokerPods] = useState([]); const [loading, setLoading] = useState(true); const [pods, loaded, loadError] = useK8sWatchResource({ groupVersionKind: { diff --git a/src/brokers/view-brokers/BrokersList.container.tsx b/src/brokers/view-brokers/BrokersList.container.tsx index af99033d..d9f995d0 100644 --- a/src/brokers/view-brokers/BrokersList.container.tsx +++ b/src/brokers/view-brokers/BrokersList.container.tsx @@ -1,7 +1,7 @@ import { useEffect, useState, FC } from 'react'; import { k8sListItems, k8sDelete } from '@openshift-console/dynamic-plugin-sdk'; import { AMQBrokerModel } from '../../k8s/models'; -import { K8sResourceKind, BrokerCR } from '../../k8s/types'; +import { K8sResourceCommonWithData, BrokerCR } from '../../k8s/types'; import { BrokersList } from './components/BrokersList/BrokersList'; import { PreConfirmDeleteModal } from './components/PreConfirmDeleteModal/PreConfirmDeleteModal'; import { useNavigate, useParams } from 'react-router-dom-v5-compat'; @@ -11,15 +11,16 @@ export const BrokersContainer: FC = () => { const { ns: namespace } = useParams<{ ns?: string }>(); //states - const [brokers, setBrokers] = useState(); + const [brokers, setBrokers] = useState(); const [loading, setLoading] = useState(true); const [loadError, setLoadError] = useState(); const [isModalOpen, setIsModalOpen] = useState(false); - const [selectedBroker, setSelectedBroker] = useState(); + const [selectedBroker, setSelectedBroker] = + useState(); const fetchK8sListItems = () => { setLoading(false); - k8sListItems({ + k8sListItems({ model: AMQBrokerModel, queryParams: { ns: namespace }, }) diff --git a/src/k8s/types.ts b/src/k8s/types.ts index 7b989e35..0162177a 100644 --- a/src/k8s/types.ts +++ b/src/k8s/types.ts @@ -1,5 +1,5 @@ import { ExposeMode } from '../reducers/7.12/reducer'; -import { K8sResourceCommon as K8sResource } from '@openshift-console/dynamic-plugin-sdk'; +import { K8sResourceCommon } from '@openshift-console/dynamic-plugin-sdk'; export enum K8sResourceConditionStatus { True = 'True', @@ -79,7 +79,7 @@ export type ResourceTemplate = { }; }; -export type BrokerCR = K8sResource & { +export type BrokerCR = K8sResourceCommon & { spec?: { ingressDomain?: string; connectors?: Connector[]; @@ -103,7 +103,7 @@ export type BrokerCR = K8sResource & { status?: { [key: string]: any }; }; -export type K8sResourceKind = BrokerCR & { +export type K8sResourceCommonWithData = K8sResourceCommon & { data?: { [key: string]: any }; }; @@ -115,7 +115,7 @@ export enum BrokerConditionTypes { TriggerChannelReady = 'TriggerChannelReady', } -export type IssuerResource = K8sResource & { +export type IssuerResource = K8sResourceCommon & { kind: 'Issuer'; spec?: { ca?: { @@ -124,7 +124,7 @@ export type IssuerResource = K8sResource & { }; }; -export type SecretResource = K8sResource & { +export type SecretResource = K8sResourceCommon & { kind: 'Secret'; data?: { 'ca.crt'?: string; @@ -133,7 +133,7 @@ export type SecretResource = K8sResource & { }; }; -export type Ingress = K8sResource & { +export type Ingress = K8sResourceCommon & { spec: { domain: string; loadBalancer: { diff --git a/src/reducers/7.12/reducer.ts b/src/reducers/7.12/reducer.ts index 30107379..89919145 100644 --- a/src/reducers/7.12/reducer.ts +++ b/src/reducers/7.12/reducer.ts @@ -1,10 +1,5 @@ import { AddBrokerResourceValues as FormState } from './import-types'; -import { - K8sResourceKind, - BrokerCR, - Acceptor, - ResourceTemplate, -} from '../../k8s/types'; +import { BrokerCR, Acceptor, ResourceTemplate } from '../../k8s/types'; import { createContext } from 'react'; import { SelectOptionObject } from '@patternfly/react-core'; import { ConfigType } from '../../shared-components/FormView/BrokerProperties/ConfigurationPage/ConfigurationPage'; @@ -81,7 +76,7 @@ export const newArtemisCRState = (namespace: string): FormState => { }; }; -export const convertYamlToForm = (yamlBroker: K8sResourceKind) => { +export const convertYamlToForm = (yamlBroker: BrokerCR) => { const { metadata } = yamlBroker; const newFormData = { diff --git a/src/shared-components/FormView/BrokerProperties/ConfigurationPage/CertSecretSelector/CertSecretSelector.tsx b/src/shared-components/FormView/BrokerProperties/ConfigurationPage/CertSecretSelector/CertSecretSelector.tsx index 8484ee3a..99698fc9 100644 --- a/src/shared-components/FormView/BrokerProperties/ConfigurationPage/CertSecretSelector/CertSecretSelector.tsx +++ b/src/shared-components/FormView/BrokerProperties/ConfigurationPage/CertSecretSelector/CertSecretSelector.tsx @@ -12,7 +12,7 @@ import { CertModel, SecretModel, } from '../../../../../k8s/models'; -import { K8sResourceKind } from '../../../../../k8s/types'; +import { K8sResourceCommonWithData } from '../../../../../k8s/types'; import { k8sCreate, useK8sWatchResource, @@ -129,8 +129,8 @@ const useCreateSecretOptions = ({ type CreateSecretOptionsPropTypes = { customOptions?: string[]; - certManagerSecrets: K8sResourceKind[]; - legacySecrets: K8sResourceKind[]; + certManagerSecrets: K8sResourceCommonWithData[]; + legacySecrets: K8sResourceCommonWithData[]; configType: ConfigType; configName: string; isCa: boolean; @@ -153,7 +153,9 @@ export const CertSecretSelector: FC = ({ const { cr } = useContext(BrokerCreationFormState); const dispatch = useContext(BrokerCreationFormDispatch); - const [secrets, loaded, _loadError] = useK8sWatchResource({ + const [secrets, loaded, _loadError] = useK8sWatchResource< + K8sResourceCommonWithData[] + >({ isList: true, groupVersionKind: secretGroupVersionKind, namespaced: true, @@ -246,7 +248,7 @@ export const CertSecretSelector: FC = ({ //Cert_annotation_key = "cert-manager.io/issuer-name" //Bundle_annotation_key = "trust.cert-manager.io/hash" - const isCertSecret = (secret: K8sResourceKind): boolean => { + const isCertSecret = (secret: K8sResourceCommonWithData): boolean => { if (!secret.metadata || !secret.metadata.annotations) { return false; } @@ -273,7 +275,7 @@ export const CertSecretSelector: FC = ({ return false; }; - const isLegacySecret = (secret: K8sResourceKind): boolean => { + const isLegacySecret = (secret: K8sResourceCommonWithData): boolean => { return ( !( secret.metadata?.annotations && @@ -287,8 +289,8 @@ export const CertSecretSelector: FC = ({ }; const parseSecrets = (): { - certManagerSecrets: K8sResourceKind[]; - legacySecrets: K8sResourceKind[]; + certManagerSecrets: K8sResourceCommonWithData[]; + legacySecrets: K8sResourceCommonWithData[]; } => { const certSecrets = secrets.filter((x) => { return isCertSecret(x); @@ -319,7 +321,9 @@ export const CertSecretSelector: FC = ({ setIsCertDetailsModalOpen(false); }; - const [certManagerDeployments] = useK8sWatchResource({ + const [certManagerDeployments] = useK8sWatchResource< + K8sResourceCommonWithData[] + >({ isList: true, groupVersionKind: { group: 'apps', @@ -330,7 +334,7 @@ export const CertSecretSelector: FC = ({ namespace: 'cert-manager', }); - const [certIssuers] = useK8sWatchResource({ + const [certIssuers] = useK8sWatchResource({ isList: true, groupVersionKind: { group: 'cert-manager.io', @@ -341,7 +345,7 @@ export const CertSecretSelector: FC = ({ namespace: namespace, }); - const [certs] = useK8sWatchResource({ + const [certs] = useK8sWatchResource({ isList: true, groupVersionKind: { group: 'cert-manager.io', @@ -452,8 +456,8 @@ export const CertSecretSelector: FC = ({ }); }; - const findSecret = (secName: string): K8sResourceKind => { - let result: K8sResourceKind = null; + const findSecret = (secName: string): K8sResourceCommonWithData => { + let result: K8sResourceCommonWithData = null; for (let i = 0; i < secrets.length; i++) { if (secrets[i].metadata.name === secName) { result = secrets[i]; @@ -467,7 +471,7 @@ export const CertSecretSelector: FC = ({ const tlsSecret = findSecret(caGenFromTlsSecret); if (tlsSecret !== null) { const caSecName = 'ca-' + caGenFromTlsSecret; - const caSecret: K8sResourceKind = { + const caSecret: K8sResourceCommonWithData = { apiVersion: 'v1', kind: 'Secret', metadata: {