New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
openBalena settings returning balenaCloud #1029
Comments
Hi, Currently the This way whenever a CLI command is issued, the CLI can find all urls that it needs in order to operate without extra web requests. Unfortunately at this point the only way to retrieve the initially provided api url is by using the Let us know whether that unblocks you for now. Kind regards, |
Hi Thodoris, I see, it's a bit confusing indeed. However, if there's a way to get the Balena instance from the initiated SDK, it's fine for me. I need to get it via the SDK instance, because our application can contain devices from our openBalena server as well as a balenaCloud server. And we've a function that returns the right Balena SDK based on some details of the device. I tried using Thanks in advance! |
@bartversluijs I'm sorry for the late reply. Indeed declare function getSdkInfoForDevice (device: BalenaSdk.Device): { sdk: BalenaSdk.BalenaSDK, api_url: string }; |
Hi @thgreasi, Thanks for thinking with me. I've created my own typing of the Balena SDK which extends the current Balena SDK and included the hostname. This way, I can use the hostname just from the SDK instance. import { BalenaSDK as originalBalenaSDK } from 'balena-sdk';
export interface BalenaSDK extends originalBalenaSDK {
hostname: string;
} I can also add I'll let you (and your team) decide if this issue can be closed or not, because the |
Hi @bartversluijs can you give a code example on how you use that new property? |
Hi @thgreasi, |
Thanks for the extra details @bartversluijs .
I guess that this function goes over all balena sdk instances and checks the hostname property, right? const balenaSdkMap: Record<string, BalenaSDK> = {};
function getBalenaSdkForHostname(hostname: string) {
const sdk = balenaSdkMap[hostname];
if (!sdk) {
sdk = getSdk({ apiUrl: hostname });
balenaSdkMap[hostname] = sdk;
}
return sdk;
} |
Thanks for the suggestion @thgreasi. |
Expected Behavior
I'm using the Balena SDK to communicate with my openBalena server.
I create an SDK instance like this:
I expect the following to happen:
Actual Behavior
The following happens:
Steps to Reproduce the Problem
Specifications
References
The text was updated successfully, but these errors were encountered: