|
1 | | -# Using VS Code For Development |
| 1 | +# Development Environment Setup |
| 2 | + |
| 3 | +## Using VS Code For Development |
2 | 4 |
|
3 | 5 | [Visual Studio Code](https://code.visualstudio.com/) is a functional free IDE which can be used to develop many projects. Through the use of Docker images it allows developers to develop in containers where build tools can be pre-configured, precluding the need to have a special host to build on with instructions to follow for tool installation. It can be used on Windows hosts using Docker Desktop or on Linux hosts with Docker installed. |
4 | 6 |
|
5 | 7 | ## Setup |
6 | 8 |
|
7 | | -See https://code.visualstudio.com/docs/devcontainers/containers as a reference on setting up your environment. Here is a summary of the steps below with the assumption that a Linux environment is being used. |
| 9 | +This project includes a DevContainer setup which allows for developing in a containerized environment that will spawn run-time depedencies for testing. |
| 10 | + |
| 11 | +> [!NOTE] |
| 12 | +> This setup will recreate a Dev Container docker image for V2X Hub, targeting the `build` stage in the dockerfile in order to include build dependencies. This image will be called **v2xhub-devcontainer** |
8 | 13 |
|
9 | 14 | ### Installation |
10 | 15 |
|
@@ -35,4 +40,102 @@ The configuration comes with 3 configured tasks. These can be run under from th |
35 | 40 | * test: After a successful build you can use this task to run all the build unit tests |
36 | 41 |
|
37 | 42 | > [!NOTE] |
38 | | -> Both **test** and **build** tasks have a duplicate version which includes **coverage** to build the source code and run the unit tests to get code coverage metrics. |
| 43 | +> Both **test** and **build** tasks have a duplicate version which includes **coverage** to build the source code and run the unit tests to get code coverage metrics. |
| 44 | +
|
| 45 | +## DevContainer VSCode Extensions |
| 46 | + |
| 47 | +By default our dev container installs several VSCode extensions helpful for developing and testing V2X Hub code changes. These are documented in the `.devcontainer/devcontainer.json` under **customizations.vscode.extensions** and also listed below: |
| 48 | +- **CPP Tools**, **CPP Tools Extension Pack**, and **CMake Tools** are extensions for C++ and CMake to make editing our source code and build files easier and more intuitive |
| 49 | +- **Sonar Lint** is a code quality and linting tool that provides feedback about best practices and security issues or hotspots |
| 50 | + |
| 51 | + |
| 52 | +### Sonar Lint One-Time Setup |
| 53 | + |
| 54 | +The first time setting up Sonar Lint, there are a couple VSCode prompts to navitigate to allow you to get Sonar Lint feedback. After deploying the DevContainer, you should see on the right hand side a new icon at the bottom representing the SonarLint VSCode extension. |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | +Clicking this icon should bring up a SonarQube Setup page. Under **Connected Mode** there should be a **SonarQube Cloud** menu with a single connection. Clicking this connection should provide a connection page that allows you to generate a token for a SonarQube Cloud connection. This provides some additional features such as a connection to Quality Profiles set on Sonar Cloud. Simply click **Generate Token** which should open a browser and allow you to login to Sonar Cloud with you GitHub account. Doing so will grant the VSCode extension a token to use to connect to Sonar Cloud. |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | +> [!NOTE] |
| 63 | +> Please ensure you save the connection after generating the token. Sometimes the **Save Connection** button is greyed out but simply resetting the organization or connection name should allow you to save the connection. |
| 64 | +
|
| 65 | +Lastly you will need to build the code, using **Ctrl + Shift + B** or the build task. The Sonar Lint VS Code extension requires a compilation database file which is generated during the build to function. |
| 66 | + |
| 67 | +### Confirming Setup was Successful |
| 68 | + |
| 69 | +After compiling once, you should be able to edit a *.cpp file an save it. This should result in code smells reported both in the code editor and in the Sonar Qube Terminal |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | +Using **Ctrl + I** will allow you to generate AI recommended fixes for reported issues where applicable |
| 74 | + |
| 75 | + |
| 76 | +## Configuring DevContainer to Trust Organizational Certificate Authorities / Internal TLS |
| 77 | + |
| 78 | +> [!NOTE] |
| 79 | +> Skip if not required. For developers, developing inside coporate VPN, this step is required to avoid certificate issues. |
| 80 | +
|
| 81 | +If your organization uses private Certificate Authorities (CA), TLS inspection, or a corporate VPN that intercepts HTTPS traffic, the DevContainer must trust your organization’s root and/or intermediate CA certificates. |
| 82 | + |
| 83 | +Without these certificates installed, tools such as curl, nvm, git, or package managers may fail with TLS certificate verification errors. |
| 84 | + |
| 85 | +### Steps |
| 86 | +1. Obtain Required Certificates |
| 87 | +Request from your IT/security team: |
| 88 | + |
| 89 | +The organization’s Root CA certificate |
| 90 | +Any Intermediate CA certificates used for perimeter or TLS inspection |
| 91 | +You do not need the VPN server certificate or any private keys — only public CA certificates. |
| 92 | + |
| 93 | +2. Save Certificates to the Repository |
| 94 | +Place the certificate files (public certs only) in: |
| 95 | + |
| 96 | +.devcontainer/perimeter-certs/ |
| 97 | +Requirements: |
| 98 | + |
| 99 | +Files must be in PEM format |
| 100 | +Use the .crt file extension (required for automatic installation) |
| 101 | +Multiple certificates may be added if needed |
| 102 | +Example: |
| 103 | + |
| 104 | +.devcontainer/perimeter-certs/ |
| 105 | +├── Corp-Root-CA.crt |
| 106 | +├── Corp-Perimeter-CA.crt |
| 107 | +3. Rebuild the DevContainer |
| 108 | +In VS Code: |
| 109 | + |
| 110 | +Dev Containers: Rebuild Container |
| 111 | +During container setup, the DevContainer initialization script will: |
| 112 | + |
| 113 | +Detect any .crt files in .devcontainer/perimeter-certs/ |
| 114 | +Install them into /usr/local/share/ca-certificates/ |
| 115 | +Update the container’s system trust store |
| 116 | +No manual installation steps are required. |
| 117 | + |
| 118 | +Verification (Optional) |
| 119 | +After rebuilding, verify that TLS trust works from DevContainer: |
| 120 | + |
| 121 | +curl -I https://nodejs.org/dist/index.json |
| 122 | +Expected result: |
| 123 | + |
| 124 | +You should see an HTTP/1.1 200 or HTTP/2 200 response |
| 125 | +No certificate verification errors |
| 126 | +If this succeeds, certificate trust is correctly configured. |
| 127 | + |
| 128 | +### Troubleshooting |
| 129 | + |
| 130 | +If you still see certificate errors: |
| 131 | + |
| 132 | +Ensure certificate files use the .crt extension |
| 133 | +Confirm the files contain valid PEM-encoded certificates |
| 134 | +Verify you included both root and intermediate CA certificates (if required) |
| 135 | +Rebuild the container again after changes |
| 136 | +Security Note |
| 137 | +Only public CA certificates should be committed to the repository. |
| 138 | +Never commit private keys. |
| 139 | + |
| 140 | +Proceed |
| 141 | +After certificate trust is configured, continue with V2XHub deployment as usual. |
0 commit comments