diff --git a/src/api/backup-restore.ts b/src/api/backup-restore.ts index 1eeecd626..aaef056ba 100644 --- a/src/api/backup-restore.ts +++ b/src/api/backup-restore.ts @@ -13,7 +13,7 @@ import { V1ObjectMeta } from '@kubernetes/client-node' import { CHE_BACKUP_SERVER_CONFIG_KIND_PLURAL, CHE_CLUSTER_API_GROUP, CHE_CLUSTER_API_VERSION } from '../constants' import { KubeHelper } from './kube' -import { V1AwsS3ServerConfig, V1CheBackupServerConfiguration, V1CheClusterBackup, V1RestServerConfig, V1SftpServerConfing } from './typings/backup-restore-crds' +import { V1AwsS3ServerConfig, V1CheBackupServerConfiguration, V1CheClusterBackup, V1RestServerConfig, V1SftpServerConfing } from './types/backup-restore-crds' export type BackupServerType = 'rest' | 'sftp' | 's3' | '' diff --git a/src/api/che.ts b/src/api/che.ts index e59cdd50d..0fd27da5b 100644 --- a/src/api/che.ts +++ b/src/api/che.ts @@ -28,9 +28,9 @@ import { OpenShiftHelper } from '../api/openshift' import { CHE_ROOT_CA_SECRET_NAME, DEFAULT_CA_CERT_FILE_NAME, DEFAULT_CHE_OLM_PACKAGE_NAME, DEFAULT_OPENSHIFT_OPERATORS_NS_NAME, OPERATOR_TEMPLATE_DIR } from '../constants' import { base64Decode, downloadFile } from '../util' import { CheApiClient } from './che-api-client' -import { Devfile } from './devfile' +import { Devfile } from './types/devfile' import { KubeHelper } from './kube' -import { OperatorGroup, Subscription } from './typings/olm' +import { OperatorGroup, Subscription } from './types/olm' export class CheHelper { defaultCheResponseTimeoutMs = 3000 diff --git a/src/api/kube.ts b/src/api/kube.ts index 07fa0fa43..0be80eec6 100644 --- a/src/api/kube.ts +++ b/src/api/kube.ts @@ -23,11 +23,11 @@ import { Writable } from 'stream' import { CHE_CLUSTER_API_GROUP, CHE_CLUSTER_API_VERSION, CHE_CLUSTER_BACKUP_KIND_PLURAL, CHE_CLUSTER_KIND_PLURAL, CHE_CLUSTER_RESTORE_KIND_PLURAL, DEFAULT_K8S_POD_ERROR_RECHECK_TIMEOUT, DEFAULT_K8S_POD_WAIT_TIMEOUT, OLM_STABLE_CHANNEL_NAME } from '../constants' import { base64Encode, getClusterClientCommand, getImageNameAndTag, isKubernetesPlatformFamily, newError, safeLoadFromYamlFile } from '../util' -import { V1CheClusterBackup, V1CheClusterRestore } from './typings/backup-restore-crds' +import { V1CheClusterBackup, V1CheClusterRestore } from './types/backup-restore-crds' -import { V1Certificate } from './typings/cert-manager' -import { CatalogSource, ClusterServiceVersion, ClusterServiceVersionList, InstallPlan, OperatorGroup, PackageManifest, Subscription } from './typings/olm' -import { IdentityProvider, OAuth } from './typings/openshift' +import { V1Certificate } from './types/cert-manager' +import { CatalogSource, ClusterServiceVersion, ClusterServiceVersionList, InstallPlan, OperatorGroup, PackageManifest, Subscription } from './types/olm' +import { IdentityProvider, OAuth } from './types/openshift' import { VersionHelper } from './version' const AWAIT_TIMEOUT_S = 30 @@ -2357,6 +2357,10 @@ export class KubeHelper { } async createCheClusterCertificate(certificate: V1Certificate, version: string): Promise { + if (!certificate.metadata?.namespace) { + throw new Error('Expected namespace in metadata') + } + const customObjectsApi = this.kubeConfig.makeApiClient(CustomObjectsApi) try { diff --git a/src/api/typings/backup-restore-crds.d.ts b/src/api/types/backup-restore-crds.ts similarity index 100% rename from src/api/typings/backup-restore-crds.d.ts rename to src/api/types/backup-restore-crds.ts diff --git a/src/api/typings/cert-manager.d.ts b/src/api/types/cert-manager.ts similarity index 89% rename from src/api/typings/cert-manager.d.ts rename to src/api/types/cert-manager.ts index 4669bf032..cf4710d79 100644 --- a/src/api/typings/cert-manager.d.ts +++ b/src/api/types/cert-manager.ts @@ -10,6 +10,8 @@ * Red Hat, Inc. - initial API and implementation */ +import { V1ObjectMeta } from '@kubernetes/client-node' + export interface V1Certificate { apiVersion: string kind: string @@ -21,7 +23,7 @@ export interface V1CertificateSpec { secretName: string issuerRef: V1CertificateSpecIssuerReference commonName: string - dnsNames: List + dnsNames: string[] } export interface V1CertificateSpecIssuerReference { diff --git a/src/api/devfile.ts b/src/api/types/devfile.ts similarity index 100% rename from src/api/devfile.ts rename to src/api/types/devfile.ts diff --git a/src/api/typings/olm.d.ts b/src/api/types/olm.ts similarity index 100% rename from src/api/typings/olm.d.ts rename to src/api/types/olm.ts diff --git a/src/api/typings/openshift.d.ts b/src/api/types/openshift.ts similarity index 91% rename from src/api/typings/openshift.d.ts rename to src/api/types/openshift.ts index 1fe6a2899..55fdfccfe 100644 --- a/src/api/typings/openshift.d.ts +++ b/src/api/types/openshift.ts @@ -10,6 +10,8 @@ * Red Hat, Inc. - initial API and implementation */ +import { V1ObjectMeta } from '@kubernetes/client-node' + export interface OAuth { apiVersion: string; kind: string; diff --git a/src/commands/devfile/generate.ts b/src/commands/devfile/generate.ts index 9cc2f0932..8789ecb17 100644 --- a/src/commands/devfile/generate.ts +++ b/src/commands/devfile/generate.ts @@ -16,7 +16,7 @@ import { string } from '@oclif/parser/lib/flags' import * as yaml from 'js-yaml' import { ChectlContext } from '../../api/context' -import { Devfile, DevfileCommand, DevfileComponent, DevfileProject, ProjectSource, TheEndpointName } from '../../api/devfile' +import { Devfile, DevfileCommand, DevfileComponent, DevfileProject, ProjectSource, TheEndpointName } from '../../api/types/devfile' import { KubeHelper } from '../../api/kube' import { CHE_TELEMETRY } from '../../common-flags' import { DEFAULT_ANALYTIC_HOOK_NAME } from '../../constants' diff --git a/src/commands/server/backup.ts b/src/commands/server/backup.ts index 722280980..09831e795 100644 --- a/src/commands/server/backup.ts +++ b/src/commands/server/backup.ts @@ -20,7 +20,7 @@ import { ChectlContext } from '../../api/context' import { KubeHelper } from '../../api/kube' import { batch, cheNamespace, CHE_TELEMETRY } from '../../common-flags' import { requestBackup, BackupServerConfig, getBackupServerType } from '../../api/backup-restore' -import { V1CheClusterBackup, V1CheClusterBackupStatus } from '../../api/typings/backup-restore-crds' +import { V1CheClusterBackup, V1CheClusterBackupStatus } from '../../api/types/backup-restore-crds' import { cli } from 'cli-ux' import { ApiTasks } from '../../tasks/platforms/api' import { findWorkingNamespace, getCommandSuccessMessage, notifyCommandCompletedSuccessfully, wrapCommandError } from '../../util' diff --git a/src/commands/server/restore.ts b/src/commands/server/restore.ts index 637359847..2c90717ff 100644 --- a/src/commands/server/restore.ts +++ b/src/commands/server/restore.ts @@ -27,7 +27,7 @@ import { TASK_TITLE_CREATE_CUSTOM_CATALOG_SOURCE_FROM_FILE, TASK_TITLE_DELETE_CU import { OperatorTasks } from '../../tasks/installers/operator' import { checkChectlAndCheVersionCompatibility, downloadTemplates, TASK_TITLE_CREATE_CHE_CLUSTER_CRD, TASK_TITLE_PATCH_CHECLUSTER_CR } from '../../tasks/installers/common-tasks' import { confirmYN, findWorkingNamespace, getCommandSuccessMessage, getEmbeddedTemplatesDirectory, notifyCommandCompletedSuccessfully, wrapCommandError } from '../../util' -import { V1CheBackupServerConfiguration, V1CheClusterBackup, V1CheClusterRestore, V1CheClusterRestoreStatus } from '../../api/typings/backup-restore-crds' +import { V1CheBackupServerConfiguration, V1CheClusterBackup, V1CheClusterRestore, V1CheClusterRestoreStatus } from '../../api/types/backup-restore-crds' import { awsAccessKeyId, awsSecretAccessKey, AWS_ACCESS_KEY_ID_KEY, AWS_SECRET_ACCESS_KEY_KEY, backupRepositoryPassword, backupRepositoryUrl, backupRestServerPassword, backupRestServerUsername, backupServerConfigName, BACKUP_REPOSITORY_PASSWORD_KEY, BACKUP_REPOSITORY_URL_KEY, BACKUP_REST_SERVER_PASSWORD_KEY, BACKUP_REST_SERVER_USERNAME_KEY, BACKUP_SERVER_CONFIG_CR_NAME_KEY, getBackupServerConfiguration, sshKey, sshKeyFile, SSH_KEY_FILE_KEY, SSH_KEY_KEY } from './backup' diff --git a/src/tasks/component-installers/cert-manager.ts b/src/tasks/component-installers/cert-manager.ts index 3099a7ef7..11f9f7d9a 100644 --- a/src/tasks/component-installers/cert-manager.ts +++ b/src/tasks/component-installers/cert-manager.ts @@ -16,7 +16,7 @@ import * as path from 'path' import { CheHelper } from '../../api/che' import { KubeHelper } from '../../api/kube' -import { V1Certificate } from '../../api/typings/cert-manager' +import { V1Certificate } from '../../api/types/cert-manager' import { CA_CERT_GENERATION_JOB_IMAGE, CERT_MANAGER_NAMESPACE_NAME, CHE_RELATED_COMPONENT_LABEL, CHE_ROOT_CA_SECRET_NAME, CHE_TLS_SECRET_NAME } from '../../constants' import { base64Decode } from '../../util' import { getMessageImportCaCertIntoBrowser } from '../installers/common-tasks' diff --git a/src/tasks/installers/olm.ts b/src/tasks/installers/olm.ts index 929f612d6..8309f0ad8 100644 --- a/src/tasks/installers/olm.ts +++ b/src/tasks/installers/olm.ts @@ -18,7 +18,7 @@ import * as path from 'path' import { CheHelper } from '../../api/che' import { KubeHelper } from '../../api/kube' -import { CatalogSource, Subscription } from '../../api/typings/olm' +import { CatalogSource, Subscription } from '../../api/types/olm' import { VersionHelper } from '../../api/version' import { CUSTOM_CATALOG_SOURCE_NAME, CVS_PREFIX, DEFAULT_CHE_NAMESPACE, DEFAULT_CHE_OLM_PACKAGE_NAME, DEFAULT_OLM_KUBERNETES_NAMESPACE, DEFAULT_OPENSHIFT_MARKET_PLACE_NAMESPACE, DEFAULT_OPENSHIFT_OPERATORS_NS_NAME, KUBERNETES_OLM_CATALOG, NEXT_CATALOG_SOURCE_NAME, OLM_NEXT_CHANNEL_NAME, OLM_STABLE_CHANNEL_NAME, OPENSHIFT_OLM_CATALOG, OPERATOR_GROUP_NAME, OLM_STABLE_ALL_NAMESPACES_CHANNEL_NAME, DEFAULT_CHE_OPERATOR_SUBSCRIPTION_NAME } from '../../constants' import { isKubernetesPlatformFamily } from '../../util'