-
Notifications
You must be signed in to change notification settings - Fork 24
Development Environment
Our team prefers to use Visual Studio Code for our IDE as it is one of the most versatile, configurable and free editors out there. Here's a list of extensions that are recommended for the development experience with the toolkit.
Copy and paste these ids into the extensions search in VSCode and Install:
- ms-azuretools.vscode-docker (for working with Docker) https://code.visualstudio.com/docs/containers/overview
- angular.ng-template (for working with our Sample-Web-UI)
- streetsidesoftware.code-spell-checker (For ensuring we catch mispelled (<--see what I did there) things in our code0
- dbaeumer.vscode-eslint (For highlight, and enforcing our coding style -- we use standardjs rules https://standardjs.com/#why-should-i-use-javascript-standard-style)
- github.vscode-pull-request-github (This helps make code reviews a little easier)
- eamodio.gitlens (Helps to see who did what, you know, to work with the right people when things break :D )
- golang.go ( For go development -- make sure you install all the go related tools! ) https://code.visualstudio.com/docs/languages/go
- orta.vscode-jest ( Helps for running our Jest based tests)
- ms-vsliveshare.vsliveshare (We use liveshare for peer programming. For those real sticky situations, the ones were it takes 30 minutes to get to where it breaks again and you need a second pair of eyes)
- equinusocio.vsc-material-theme (To make the editor look good)
- pkief.material-icon-theme (To make the icons look good too)
- adamhartford.vscode-base64 (For converting text back and forth to base64 since we do that a lot)
- redhat.vscode-yaml ('Cuz YAML whitespace can be a pain)
One thing we encourage is HOTKEYS! https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf The most important ones:
- Ctrl+Shift+P to bring up the command pallet and search for what you want to do. Turn on code coverage? Toggle the minimap? Convert a word to uppercase? launch a docker compose file? You can do it all from this pallet menu!
- Ctrl+P to open a file if you know the name. Don't go hunting for files in the explorer!!!
Everything we do is here on Github. Git support is built into VSCode, check out https://code.visualstudio.com/docs/editor/versioncontrol to learn how to use VSCode's version control features. Sometimes though, you'll have to leverage the git-cli directly, and in that case you can use the integrated terminal: https://code.visualstudio.com/docs/editor/integrated-terminal.
To learn more about debugging in VSCode. Check out: https://code.visualstudio.com/docs/editor/debugging
The core microservices of RPS and MPS both require a database (PostgreSQL) and a secret provider (Vault). The easiest way to run these dependencies is with Docker. Using the docker-compose file in open-amt-cloud-toolkit, and ensuring the .env file has been updated with a proper database username/password and vault token you can run these dependencies with
docker-compose up -d db vault
. While Kong is used as the API Gateway for our Getting Started/Production flows, when in development, Kong is essentially not used when running the services natively. This has a couple implications, that the services are not served over https
(since Kong serves the cert) and that the paths for each service need to leverage the port. For example, instead of https://[ipaddress]/mps
to access MPS apis, you would use http://[ipaddress]:3000
. Check the logs/config for which port each service is listening on.
Once the dependencies are up, check to make sure your .mpsrc
and .rpsrc
have the correct database connection string and vault token that matches what you configured for db and vault. These files are used in development as default values and .env files can overwrite them. Make sure your .mpsrc
files are configured per the docs located here: https://open-amt-cloud-toolkit.github.io/docs/2.1/GetStarted/setup/#set-environment-variables (the ones with the MPS_
prefix).
Here is a sample launch.json
file for MPS that goes in a .vscode folder at the root of each project. This is from a Windows machine, Linux may require the paths to be changed:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"name": "vscode-jest-tests",
"request": "launch",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": [
"<<filename>>.test.ts"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"env": {
"MPS_LOG_LEVEL": "silly"
},
"skipFiles": [
"<node_internals>/**"
],
"outputCapture": "std",
"program": "${workspaceFolder}\\dist\\index.js",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
]
}
]
}
It will be similar for RPS, just need to update the ENV var to be RPS instead of MPS
Heres's a launch.json
that can be used for RPC-go. You'll need to launch VSCode as an administrator to be able to debug RPC as it talks to hardware:
{
"version": "0.2.0",
"configurations": [
{
"name": "Run",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd",
"args": [
"amtinfo",
"-bld"
]
}
]
}
With the additions of local features in RPC-Go, the ability to remote into a variety of AMT machines to test & debug code is critical. OpenSSH server should be running on all of your AMT devices that you use for development.
For Ubuntu devices use the following to install and run OpenSSH server:
- Open the terminal application for Ubuntu desktop
- Type command:
sudo apt-get install openssh-server
- Enable the ssh service by typing:
sudo systemctl enable ssh --now
For Windows 11 devices use the following to install and run OpenSSH server:
- Open up Settings panel (Windows key, type settings).
- In the search bar above Home, type: Optional features.
- On the "Add an optional features" line click "View features".
- In the "Find an available optional feature" search bar, type "OpenSSH".
- Select OpenSSH Server and click Next, then click install.
- It will take a few minutes for OpenSSH Server to install.
- Open up Task Manager and click on Services.
- Find ssh-agent in the list (it's alphabetical) and right click, open services.
- Find OpenSSH Authentication Agent. Right click -> Properties. Set Startup Type to automatic.
- Find OpenSSH SSH Server (should be next in the list). Right click -> Properties. Set Startup Type to automatic.
- Open VS Code on your development machine (not the AMT machine)
- ctrl-shift-p to open the command pallet
- type "Remote-SSH" and select Remote-SSH: OpenSSH Configuration File.
- Select the config file you want to update. I use the one stored in my Users folder "C:\Users\your username\.ssh\config"
- Add the specific machine you want to use for remote development. This is what my config file looks like for the 3 machines I remote dev on:
Host 192.168.0.38
HostName 192.168.0.38
User snuc
Host 192.168.0.82
HostName 192.168.0.82
User RBHE_MCP
Host 192.168.0.75
HostName 192.168.0.75
User hec-mcp
Open VS Code and make sure you have the Remote Development extension installed. It should look like this:
In VS Code you should have this icon in the bottom left corner of the window:
Click the icon and you'll see drop down menu at the top of the VS Code window. Select "Connect to Host". You'll see a list of devices that should match what you configured in the previous section. Mine looks like this:
Select the device you want to remote connect to. You'll be prompted for the password associated with the user you put in the config file. You may have to put the password in twice, that is normal.
You are now remotely connected to the device's terminal and can enter commands just like you would on your local machine. The top of VS Code should look something like this when you are connected:
and the bottom left corner of VS Code should look like this:
If you have Git installed on the remote machine (required) then you can use all the git commands you would normally use on your local dev machine. You are now remote developing and there is no longer a need to use a slow remote desktop session!