IBM / vscode-ibmi-projectexplorer

IBM i Project Explorer for VS Code
https://ibm.github.io/vscode-ibmi-projectexplorer/
Apache License 2.0
22 stars 7 forks source link

Code for IBMi - external connection #592

Open cosentino-smeup opened 1 month ago

cosentino-smeup commented 1 month ago

I have some questions about IBMi-bob connections:

SanjulaGanepola commented 1 month ago
  • Where are ibmi-bob connections saved?

@cosentino-smeup Can you clarify what you mean exactly by "IBMi-bob connections"? Since the bob commands are run on the IBM i, it will be using the connection for the SSH session it was invoked in. This applies to using bob from the command line (PASE) or Project Explorer from VS Code.

  • is it possible to create a connection externally to vscode (in a text file, for example) and copy it so that it is recognized by “IBMi-bob”?

Is your goal to have a local text file with your connection and then invoke a build against that connection from the command line? I believe this would require having to write your own script that would read the connection from the text file and then deploy and build the project on the IBM i. The last two steps can be achieved using @ibm/ibmi-ci.

@edmundreinhardt Are you aware of any other ways to do this easily?

cosentino-smeup commented 1 month ago

Sorry, my mistake it was "Code for IMB i" connections. (bad copy and paste due to the last issues I opened)

These connections: ibmi connections

This question is related to this one.

We want our end clients to be able to open PF-SRC members from our product using OpenVSCode using the extension "Code for IBM i". We want this operation to be as much as transparent as possible, because they might not necessary know anything about VS Code and the IBM extension.

Unfortunately, according with @sebjulliand, the solution might not work with OpenVSCode.

With this expectations, I thought I could at least simplify the process by creating a connection with the IMBi during our installation. In fact, we'll provide a container with OpenVSCode and code for IBMi. We have all information we need to create the connection because we use it in our product:

connection settings login-settings

I thought that I could write this information in a text file in a specific folder so that the "Code for IBM i" can recognize it. It's like creating automatically a connection instead of creating it manually.

worksofliam commented 1 month ago

@cosentino-smeup do a search in the Code for IBM I codebase connectDirect which let's other extensions create a connection.

sebjulliand commented 1 month ago

@cosentino-smeup It is possible to add connection they way you'd like to. Code for i connections are stored in the user settings, as JSON. If you open your user settings, you should see something like this: image

"code-for-ibmi.connections" is an array of JSON objects. Each object defines a connection with its name, port, username, ...

cosentino-smeup commented 1 month ago

@cosentino-smeup do a search in the Code for IBM I codebase connectDirect which let's other extensions create a connection.

@worksofliam I tried looking for connectDirect but I didn't find anything specific for my case. Can you address me please to find something specific?

I found this.

sebjulliand commented 1 month ago

This command: https://github.com/codefori/vscode-ibmi/blob/e0e862ea56db64a28161e5c581016e6489645fa9/src/extension.ts#L70

But I don't see how you'd call it unless you write your own extension.

You may want to have a look at this: https://github.com/codefori/vscode-ibmi/blob/e0e862ea56db64a28161e5c581016e6489645fa9/src/sandbox.ts#L10

Code for i can handle a "/connect" URI that allows to connect directly to an IBM i, even saving the connection for further use. The URI is the following:

vscode://halcyontechltd.code-for-ibmi/connect?server=ADDRESS:PORT&user=MYUSER&pass=BASE64ENCODEDPASS&save=true

This will connect to the ADRESS on port PORT with user MYUSER. If pass is set for the password, it must be base64 encoded. If save is true, the connection will be saved in the connection browser.

This may answer your need. What remains to know is whether or not OpenVSCode can accept these vscode:// URL or not.

cosentino-smeup commented 1 month ago

This may answer your need. What remains to know is whether or not OpenVSCode can accept these vscode:// URL or not.

Exactly, "vscode://" would be the answer if only it worked in OpenVSCode.

I opened a issue to openvscode: here and I asked a question in stack overflow: here

But I have the feeling that nobody is going to answer :-(

cosentino-smeup commented 1 month ago

Code for i connections are stored in the user settings, as JSON.

@sebjulliand, unfortunately OpenVSCode persists settings in the browser's indexedDB rather than a settings.json file on the file system.