Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { useClusterWizardContext } from '../clusterWizard/ClusterWizardContext';
import DeleteCustomManifestModal from './manifestsConfiguration/DeleteCustomManifestModal';
import { ClustersService } from '../../services';
import { ClustersAPI } from '../../services/apis';
import { useLocation } from 'react-router-dom-v5-compat';

const Label = () => {
return (
Expand All @@ -38,18 +37,6 @@ const CustomManifestCheckbox = ({ clusterId, isDisabled }: CustomManifestCheckbo
const fieldId = getFieldId(name, 'input');
const clusterWizardContext = useClusterWizardContext();
const [isDeleteCustomManifestsOpen, setDeleteCustomManifestsOpen] = React.useState(false);
const location = useLocation();

React.useEffect(() => {
const searchParams = new URLSearchParams(location.search);
const isAssistedMigration = searchParams.get('source') === 'assisted_migration';

if (isAssistedMigration) {
setValue(true);
clusterWizardContext.setCustomManifestsStep(true);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [location]);

const cleanCustomManifests = React.useCallback(async () => {
const { data: manifests } = await ClustersAPI.getManifests(clusterId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,16 @@ const ClusterDetails = ({ cluster, infraEnv }: ClusterDetailsProps) => {
try {
const searchParams = new URLSearchParams(location.search);
const isAssistedMigration = searchParams.get('source') === 'assisted_migration';
//For Assisted Migration we need to LVMs operator
if (isAssistedMigration) {
params.olmOperators = [{ name: 'lvm' }];
}
const cluster = await ClustersService.create(params, isAssistedMigration);
navigate(`../${cluster.id}`, { state: ClusterWizardFlowStateNew });
await UISettingService.update(cluster.id, { addCustomManifests });
//TO-DO: Assisted-Migration. Provisional code. Needs to be removed when MTV integration be finished
//For Assisted Migration we need to enable virtualization bundle
if (isAssistedMigration) {
await ClustersService.createClusterManifestsForAssistedMigration(cluster.id);
await UISettingService.update(cluster.id, { bundlesSelected: ['virtualization'] });
}
} catch (e) {
handleApiError(e, () =>
Expand Down
156 changes: 0 additions & 156 deletions libs/ui-lib/lib/ocm/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,159 +39,3 @@ export const ocmPermissionsToAIPermissions = (
}
return permissions;
};

//TO-DO: Assisted-Migration. Provisional code. Needs to be removed when MTV integration be finished
export const yamlContentAssistedMigration1 = `apiVersion: v1
kind: Namespace
metadata:
name: openshift-gitops-operator
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: openshift-gitops-operator
namespace: openshift-gitops-operator
spec:
upgradeStrategy: Default
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: openshift-gitops-operator
namespace: openshift-gitops-operator
spec:
channel: latest
installPlanApproval: Automatic
name: openshift-gitops-operator
source: redhat-operators
sourceNamespace: openshift-marketplace
`;

export const yamlContentAssistedMigration2 = `apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: namespace-manager
rules:
- apiGroups: [""]
resources: ["namespaces"]
verbs: ["get", "create", "update", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: namespace-manager-binding
subjects:
- kind: ServiceAccount
name: openshift-gitops-argocd-application-controller
namespace: openshift-gitops
roleRef:
kind: ClusterRole
name: namespace-manager
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: persistentvolumeclaim-manager
namespace: openshift-image-registry
rules:
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "create", "update", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: persistentvolumeclaim-manager-binding
namespace: openshift-image-registry
subjects:
- kind: ServiceAccount
name: openshift-gitops-argocd-application-controller
namespace: openshift-gitops
roleRef:
kind: Role
name: persistentvolumeclaim-manager
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: job-manager
rules:
- apiGroups: ["batch"]
resources: ["jobs"]
verbs: ["get", "create", "update", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: job-manager-binding
subjects:
- kind: ServiceAccount
name: openshift-gitops-argocd-application-controller
namespace: openshift-gitops
roleRef:
kind: ClusterRole
name: job-manager
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: argocd-application-controller
rules:
- apiGroups: [""]
resources: ["serviceaccounts", "services", "secrets"]
verbs: ["create", "get", "list", "update", "delete", "patch"]
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["create", "get", "list", "update", "delete", "patch"]
- apiGroups: ["route.openshift.io"]
resources: ["routes"]
verbs: ["create", "get", "list", "update", "delete", "patch"]
- apiGroups: ["image.openshift.io"]
resources: ["imagestreams"]
verbs: ["create", "get", "list", "update", "delete", "patch"]
- apiGroups: ["build.openshift.io"]
resources: ["buildconfigs"]
verbs: ["create", "get", "list", "update", "delete", "patch"]

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: argocd-application-controller-binding
subjects:
- kind: ServiceAccount
name: openshift-gitops-argocd-application-controller
namespace: openshift-gitops
roleRef:
kind: ClusterRole
name: argocd-application-controller
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: argocd-secrets-role
namespace: openshift-mtv
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["create", "get", "list", "update", "delete", "patch"]

---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: argocd-secrets-rolebinding
namespace: openshift-mtv
subjects:
- kind: ServiceAccount
name: openshift-gitops-argocd-application-controller
namespace: openshift-gitops
roleRef:
kind: Role
name: argocd-secrets-role
apiGroup: rbac.authorization.k8s.io
`;
29 changes: 0 additions & 29 deletions libs/ui-lib/lib/ocm/services/ClustersService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import {
AI_UI_TAG,
} from '../../common/config/constants';
import { isInOcm } from '../../common/api/axiosClient';
import { yamlContentAssistedMigration1, yamlContentAssistedMigration2 } from '../config';
import jsYaml from 'js-yaml';

const ClustersService = {
findHost(hosts: Cluster['hosts'] = [], hostId: Host['id']) {
Expand Down Expand Up @@ -167,32 +165,5 @@ const ClustersService = {
this.getUpdateManifestParams(existingManifest, updatedManifest),
);
},

//TO-DO: Assisted-Migration. Provisional code. Needs to be removed when MTV integration be finished
async createClusterManifestsForAssistedMigration(clusterId: Cluster['id']) {
const manifests: CustomManifestValues[] = [];

const parsedYaml1 = jsYaml.dump(yamlContentAssistedMigration1);
manifests.push({
folder: 'openshift',
filename: '0gitops.yaml',
manifestYaml: parsedYaml1,
created: true,
});

const parsedYaml2 = jsYaml.dump(yamlContentAssistedMigration2);
manifests.push({
folder: 'openshift',
filename: '1rolebindings.yaml',
manifestYaml: parsedYaml2,
created: true,
});

const promises = manifests.map((manifest) => {
return ClustersAPI.createCustomManifest(clusterId, this.transformFormViewManifest(manifest));
});
return Promise.all(promises);
},
};

export default ClustersService;
Loading