Skip to content

Commit

Permalink
Merge pull request #1466 from jpuzz0/MTV-2013-create-provider-d/s
Browse files Browse the repository at this point in the history
[MTV-2013] Cant create provider on D/S
  • Loading branch information
metalice authored Feb 11, 2025
2 parents 2077a60 + 72462d2 commit 4499c05
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ With a user logged in to existing Kubernetes or Openshift environment with Forkl
``` bash
# Start a local Openshift console server on the background.
# - The console will be available in http://localhost:9000
# - The inventory URL can be set using an enviorment variable,
# - The inventory URL can be set using an environment variable,
# ( default value for INVENTORY_SERVER_HOST is https://localhost:30444 )
# for example:
# export INVENTORY_SERVER_HOST=https://virt-konveyor-forklift.apps.example.com
Expand All @@ -48,7 +48,7 @@ export INVENTORY_SERVER_HOST=https://virt-konveyor-forklift.apps.<your cluster a
export SERVICES_API_SERVER_HOST=https://virt-konveyor-forklift.apps.<your cluster address>
export CONSOLE_IMAGE=quay.io/openshift/origin-console:4.18

# Run the web console locally (uses the enviorment variables we defined above)
# Run the web console locally (uses the environment variables we defined above)
yarn console

# If this is the first time running, yarn build will build the required dependencies
Expand Down
4 changes: 2 additions & 2 deletions ci/configure/openshift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ function setup_bridge_for_bearer_token () {

BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT=$(kubectl config view -o jsonpath="{.clusters[?(@.name==\"$(kubectl config current-context)\")].cluster.server}")
elif oc_available_loggedin; then
echo "Setup for Openshift enviorment"
echo "Setup for Openshift environment"

# If we have oc tool and an Openshift token, assume we are connected to openshift
BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT=${BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT:=$(oc whoami --show-server)}
BRIDGE_K8S_AUTH_BEARER_TOKEN=$(oc whoami --show-token 2>/dev/null)
else
echo "Setup for K8s enviorment"
echo "Setup for K8s environment"

BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT=$(kubectl config view -o jsonpath="{.clusters[?(@.name==\"$(kubectl config current-context)\")].cluster.server}")
BRIDGE_K8S_AUTH_BEARER_TOKEN="abcdef.0123456789abcdef"
Expand Down
2 changes: 1 addition & 1 deletion ci/deploy-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ echo "============================"
if ! [ -x "$(command -v ${CONTAINER_CMD})" ]; then
echo "Error: can't find '${CONTAINER_CMD}' command line utility, exit"
echo ""
echo "you can changed the command line urility using a CONTAINER_CMD enviorment variable"
echo "you can changed the command line urility using a CONTAINER_CMD environment variable"
echo "and try again."
echo "for example: export CONTAINER_CMD=docker"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion packages/common/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# @kubev2v/common

Shared components and urilities that do not relay on forklift plugin contexts or enviorment.
Shared components and urilities that do not relay on forklift plugin contexts or environment.
2 changes: 1 addition & 1 deletion packages/forklift-console-plugin/src/__mocks__/envvars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* `EnvironmentPlugin` definitions
*/

import { ENVIRONMENT_DEFAULTS } from '../../enviorment-defaultss';
import { ENVIRONMENT_DEFAULTS } from '../../environment-defaults';

const environmentDefaults = {
...ENVIRONMENT_DEFAULTS,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { FC, ReactNode } from 'react';
import { useForkliftTranslation } from 'src/utils';

import { FormGroupWithHelpText, TypeaheadSelect, TypeaheadSelectOption } from '@kubev2v/common';
Expand All @@ -15,10 +15,10 @@ interface ProjectNameSelectProps {
options: TypeaheadSelectOption[];
onSelect: (value: string) => void;
isDisabled?: boolean;
popoverHelpContent?: React.ReactNode;
popoverHelpContent?: ReactNode;
}

export const ProjectNameSelect: React.FC<ProjectNameSelectProps> = ({
export const ProjectNameSelect: FC<ProjectNameSelectProps> = ({
value,
options,
isDisabled,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @cspell/spellchecker */

declare module '*.svg' {
const content: string;
export default ReactComponent;
Expand All @@ -16,3 +18,50 @@ declare module '*.json' {
const content: string;
export default content;
}

// Reference: https://github.com/openshift/console/blob/c126b66e62655eec01683b7419a6fbe835bc9ee1/frontend/%40types/console/index.d.ts#L15
declare interface Window {
SERVER_FLAGS: {
copiedCSVsDisabled: boolean;
alertManagerBaseURL: string;
alertmanagerUserWorkloadBaseURL: string;
authDisabled: boolean;
basePath: string;
branding: string;
consoleVersion: string;
customLogoURL: string;
customProductName: string;
documentationBaseURL: string;
kubeAPIServerURL: string;
loadTestFactor: number;
loginErrorURL: string;
loginSuccessURL: string;
loginURL: string;
logoutRedirect: string;
logoutURL: string;
prometheusBaseURL: string;
prometheusTenancyBaseURL: string;
quickStarts: string;
releaseVersion: string;
inactivityTimeout: number;
statuspageID: string;
GOARCH: string;
GOOS: string;
graphqlBaseURL: string;
developerCatalogCategories: string;
perspectives: string;
developerCatalogTypes: string;
userSettingsLocation: string;
addPage: string; // JSON encoded configuration
consolePlugins: string[]; // Console dynamic plugins enabled on the cluster
i18nNamespaces: string[]; // Available i18n namespaces
projectAccessClusterRoles: string;
controlPlaneTopology: string;
telemetry: Record<string, string>;
nodeArchitectures: string[];
nodeOperatingSystems: string[];
hubConsoleURL: string;
k8sMode: string;
capabilities: Record<string, string>[];
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import ProvidersCreateVmMigrationPage from 'src/modules/Providers/views/migrate/
import { startCreate } from 'src/modules/Providers/views/migrate/reducer/actions';
import { useFetchEffects } from 'src/modules/Providers/views/migrate/useFetchEffects';
import { useSaveEffect } from 'src/modules/Providers/views/migrate/useSaveEffect';
import { Namespace } from 'src/utils/constants';
import { useForkliftTranslation } from 'src/utils/i18n';
import { getDefaultNamespace } from 'src/utils/namespaces';

import {
PlanModelRef,
Expand Down Expand Up @@ -34,11 +36,10 @@ export const PlanCreatePage: FC<{ namespace: string }> = ({ namespace }) => {
const history = useHistory();
const createPlanFromPlansList = !(data?.provider !== undefined);
const [activeNamespace, setActiveNamespace] = useActiveNamespace();
const defaultNamespace = process?.env?.DEFAULT_NAMESPACE || 'default';
const defaultNamespace = getDefaultNamespace();
const projectName =
data?.projectName ||
(activeNamespace === '#ALL_NS#' ? 'openshift-mtv' : activeNamespace) ||
defaultNamespace;
(activeNamespace === Namespace.AllProjects ? defaultNamespace : activeNamespace);

const plansListURL = useMemo(() => {
return getResourceUrl({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import React, { useReducer } from 'react';
import { useHistory } from 'react-router';
import { Base64 } from 'js-base64';
import SectionHeading from 'src/components/headers/SectionHeading';
import { Namespace } from 'src/utils/constants';
import { useForkliftTranslation } from 'src/utils/i18n';
import { getDefaultNamespace } from 'src/utils/namespaces';

import { IoK8sApiCoreV1Secret, ProviderModelRef, V1beta1Provider } from '@kubev2v/types';
import { useActiveNamespace } from '@openshift-console/dynamic-plugin-sdk';
Expand Down Expand Up @@ -43,8 +45,9 @@ export const ProvidersCreatePage: React.FC<{
const [isLoading, toggleIsLoading] = useToggle();
const [activeNamespace, setActiveNamespace] = useActiveNamespace();
const [providerNames] = useK8sWatchProviderNames({ namespace });
const defaultNamespace = process?.env?.DEFAULT_NAMESPACE || 'default';
const projectName = activeNamespace === '#ALL_NS#' ? defaultNamespace : activeNamespace;
const defaultNamespace = getDefaultNamespace();
const projectName =
activeNamespace === Namespace.AllProjects ? defaultNamespace : activeNamespace;
const initialNamespace = namespace || projectName || defaultNamespace;

const initialState: ProvidersCreatePageState = {
Expand Down
11 changes: 11 additions & 0 deletions packages/forklift-console-plugin/src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
export const EMPTY_MSG = '-';

export enum Namespace {
AllProjects = '#ALL_NS#',
KonveyorForklift = 'konveyor-forklift',
OpenshiftMtv = 'openshift-mtv',
Default = 'default',
}

export enum ServerBranding {
Okd = 'okd',
}
7 changes: 7 additions & 0 deletions packages/forklift-console-plugin/src/utils/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { ServerBranding } from './constants';

/**
* Determines whether user is upstream based on SERVER_FLAGS branding
* @returns boolean
*/
export const isUpstream = () => window.SERVER_FLAGS?.branding === ServerBranding.Okd;
16 changes: 16 additions & 0 deletions packages/forklift-console-plugin/src/utils/namespaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Namespace } from './constants';
import { isUpstream } from './env';

/**
* When using an upstream build use 'konveyor-forklift', otherwise 'openshift-mtv'.
* @returns string
*/
export const getDefaultNamespace = (): string => {
const isUserUpstream = isUpstream();

if (isUserUpstream) {
return Namespace.KonveyorForklift;
}

return Namespace.OpenshiftMtv;
};
2 changes: 1 addition & 1 deletion packages/forklift-console-plugin/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-serv

import { ConsoleRemotePlugin } from '@openshift-console/dynamic-plugin-sdk-webpack';

import { ENVIRONMENT_DEFAULTS } from './enviorment-defaultss';
import { ENVIRONMENT_DEFAULTS } from './environment-defaults';
import extensions from './plugin-extensions';
import pluginMetadata from './plugin-metadata';

Expand Down

0 comments on commit 4499c05

Please sign in to comment.