Skip to content

Commit

Permalink
Remove "Bind Service" feature due to the deprecation of the Service B…
Browse files Browse the repository at this point in the history
…inding Operator #4682

Issue: #4682

Signed-off-by: Victor Rubezhny <[email protected]>
  • Loading branch information
vrubezhny committed Dec 4, 2024
1 parent 74731b6 commit 820b302
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 654 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ jobs:
if: (success() || failure()) && runner.os == 'Linux'
name: Start cluster
with:
version: v0.11.1
version: v0.20.0

- name: Configure cluster
if: (success() || failure()) && runner.os == 'Linux'
run: |
curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.19.1/install.sh | bash -s v0.19.1
kubectl create -f https://operatorhub.io/install/service-binding-operator.yaml
kubectl create -f https://operatorhub.io/install/stable/cloud-native-postgresql.yaml
kubectl create -f https://operatorhub.io/install/cloudnative-pg.yaml
nb=0
echo -n "Waiting for operator to show up "
while [ "$nb" != "2" ]
Expand Down
1 change: 0 additions & 1 deletion build/esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const webviews = [
'feedback',
'serverless-function',
'serverless-manage-repository',
'add-service-binding',
'openshift-terminal',
];

Expand Down
14 changes: 0 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,6 @@
"title": "Start Dev (manually trigger rebuild)",
"category": "OpenShift"
},
{
"command": "openshift.component.binding.add",
"title": "Bind Service",
"category": "OpenShift"
},
{
"command": "openshift.component.exitDevMode",
"title": "Stop Dev",
Expand Down Expand Up @@ -1371,10 +1366,6 @@
"command": "openshift.component.openInBrowser",
"when": "false"
},
{
"command": "openshift.component.binding.add",
"when": "false"
},
{
"command": "openshift.Serverless.openFunction",
"when": "false"
Expand Down Expand Up @@ -1839,11 +1830,6 @@
"when": "view == openshiftComponentsView && viewItem =~ /openshift\\.component.*\\.dep-nrn.*/ || viewItem =~ /openshift\\.component.*\\.dep-run.*/",
"group": "c2@1"
},
{
"command": "openshift.component.binding.add",
"when": "view == openshiftComponentsView && viewItem =~ /openshift\\.component.*\\.dev-nrn.*/",
"group": "c2@2"
},
{
"command": "openshift.component.showDevTerminal",
"when": "view == openshiftComponentsView && viewItem =~ /openshift\\.component.*\\.dev-run.*/",
Expand Down
6 changes: 5 additions & 1 deletion src/helm/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export type HelmRelease = {
*/
export async function getHelmReleases(): Promise<HelmRelease[]> {
const res = await CliChannel.getInstance().executeTool(HelmCommands.listHelmReleases(), undefined, false);
return JSON.parse(res.stdout) as HelmRelease[];
try {
return JSON.parse(res.stdout) as HelmRelease[];
} catch {
return [];
}
}

/**
Expand Down
9 changes: 6 additions & 3 deletions src/oc/ocWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,12 @@ export class Oc {

public async getAllKubernetesObjects(namespace?: string, executionContext?: ExecutionContext): Promise<KubernetesObject[]> {
const result = await CliChannel.getInstance().executeTool(
Oc.getKubernetesObjectCommand('all', namespace),
undefined, true, executionContext);
return JSON.parse(result.stdout).items;
Oc.getKubernetesObjectCommand('all', namespace), undefined, true, executionContext);
try {
return JSON.parse(result.stdout).items;
} catch {
return [];
}
}

/**
Expand Down
60 changes: 0 additions & 60 deletions src/odo/odoWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/

import { KubernetesObject } from '@kubernetes/client-node';
import { Uri, WorkspaceFolder, workspace } from 'vscode';
import { CommandOption, CommandText } from '../base/command';
import * as cliInstance from '../cli';
Expand All @@ -12,7 +11,6 @@ import { ChildProcessUtil, CliExitData } from '../util/childProcessUtil';
import { VsCommandError } from '../vscommand';
import { Command } from './command';
import { ComponentDescription } from './componentTypeDescription';
import { BindableService } from './odoTypes';

/**
* Wraps the `odo` cli tool.
Expand Down Expand Up @@ -189,62 +187,4 @@ export class Odo {
componentPath,
);
}

/**
* Bind a component to a bindable service by modifying the devfile
*
* Resolves when the binding it created.
*
* @param contextPath the path to the component
* @param serviceNamespace the namespace the the service is in
* @param serviceName the name of the service to bind to
* @param bindingName the name of the service binding
*/
public async addBinding(
contextPath: string,
serviceNamespace: string,
serviceName: string,
bindingName: string,
) {
await this.execute(
new CommandText('odo', 'add binding', [
new CommandOption('--service-namespace', serviceNamespace, false),
new CommandOption('--service', serviceName, false),
new CommandOption('--name', bindingName, false),
]),
contextPath,
true,
);
}

/**
* Returns a list of all the bindable services on the cluster.
*
* @returns a list of all the bindable services on the cluster
*/
public async getBindableServices(): Promise<KubernetesObject[]> {
const data: CliExitData = await this.execute(
new CommandText('odo', 'list service', [new CommandOption('-o json')]),
);
let responseObj;
try {
responseObj = JSON.parse(data.stdout);
} catch {
throw new Error(JSON.parse(data.stderr).message);
}
if (!responseObj.bindableServices) {
return [];
}
return (responseObj.bindableServices as BindableService[]) //
.map((obj) => {
return {
kind: obj.kind,
apiVersion: obj.apiVersion,
metadata: {
namespace: obj.namespace,
name: obj.name,
},
} as KubernetesObject;
});
}
}
71 changes: 0 additions & 71 deletions src/openshift/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ import { Command } from '../odo/command';
import { CommandProvider } from '../odo/componentTypeDescription';
import { Odo } from '../odo/odoWrapper';
import { ComponentWorkspaceFolder } from '../odo/workspace';
import sendTelemetry from '../telemetry';
import { ChildProcessUtil, CliExitData } from '../util/childProcessUtil';
import { Progress } from '../util/progress';
import * as fs from '../util/utils';
import { vsCommand, VsCommandError } from '../vscommand';
import AddServiceBindingViewLoader, { ServiceBindingFormResponse } from '../webview/add-service-binding/addServiceBindingViewLoader';
import CreateComponentLoader from '../webview/create-component/createComponentLoader';
import { OpenShiftTerminalApi, OpenShiftTerminalManager } from '../webview/openshift-terminal/openShiftTerminal';
import OpenShiftItem, { clusterRequired, projectRequired } from './openshiftItem';
Expand Down Expand Up @@ -241,75 +239,6 @@ export class Component extends OpenShiftItem {
return false;
}

@vsCommand('openshift.component.binding.add')
static async addBinding(component: ComponentWorkspaceFolder) {

const services = await Progress.execFunctionWithProgress('Looking for bindable services', (progress) => {
return Odo.Instance.getBindableServices();
});

if (!services || services.length === 0) {
void window.showErrorMessage('No bindable services are available', 'Open Service Catalog in OpenShift Console')
.then((result) => {
if (result === 'Open Service Catalog in OpenShift Console') {
void commands.executeCommand('openshift.open.operatorBackedServiceCatalog')
}
});
return;
}

void sendTelemetry('startAddBindingWizard');

let formResponse: ServiceBindingFormResponse = undefined;
try {
formResponse = await new Promise<ServiceBindingFormResponse>(
(resolve, reject) => {
void AddServiceBindingViewLoader.loadView(
component.contextPath,
services.map(
(service) => `${service.metadata.namespace}/${service.metadata.name}`,
),
(panel) => {
panel.onDidDispose((_e) => {
reject(new Error('The \'Add Service Binding\' wizard was closed'));
});
return async (eventData) => {
if (eventData.action === 'addServiceBinding') {
resolve(eventData.params);
await panel.dispose();
}
};
},
).then(view => {
if (!view) {
// the view was already created
reject(undefined as Error);
}
});
},
);
} catch {
// The form was closed without submitting,
// or the form already exists for this component.
// stop the command.
return;
}

const selectedServiceObject = services.filter(
(service) =>
`${service.metadata.namespace}/${service.metadata.name}` === formResponse.selectedService,
)[0];

void sendTelemetry('finishAddBindingWizard');

await Odo.Instance.addBinding(
component.contextPath,
selectedServiceObject.metadata.namespace,
selectedServiceObject.metadata.name,
formResponse.bindingName,
);
}

@vsCommand('openshift.component.dev')
@clusterRequired()
@projectRequired()
Expand Down
107 changes: 0 additions & 107 deletions src/webview/add-service-binding/addServiceBindingViewLoader.ts

This file was deleted.

Loading

0 comments on commit 820b302

Please sign in to comment.