Skip to content

Commit

Permalink
Merge branch 'main' into kachawla/functional-test
Browse files Browse the repository at this point in the history
  • Loading branch information
kachawla authored Jan 6, 2024
2 parents 3dd3c73 + ea4b521 commit 4962f1b
Show file tree
Hide file tree
Showing 41 changed files with 529 additions and 1,206 deletions.
32 changes: 28 additions & 4 deletions .devcontainer/contributor/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,50 @@
{
"name": "Radius - Contributor",
// For details see https://github.com/radius-project/radius/tree/main/docs/contributing/contributing-code/contributing-code-prerequisites
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/go:1": {},
//Git and GitHub Setup
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
//Programming languages
"ghcr.io/devcontainers/features/go:1": {},
"ghcr.io/guiyomh/features/gotestsum:0.1.1": {},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers-contrib/features/typescript:2": {},
"ghcr.io/devcontainers/features/python:1": {},
//Container and K8s
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {
"minikube": "none"
},
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest",
"moby": true
}
},
//Tools
"ghcr.io/eitsupi/devcontainer-features/jq-likes:2": {},
"ghcr.io/mpriscella/features/kind:1": {},
"ghcr.io/dhoeric/features/stern:1": {},
//Dapr
"ghcr.io/dapr/cli/dapr-cli:0": {}
},
"customizations": {
"vscode": {
"extensions": [
"redhat.vscode-yaml",
"golang.go",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-azuretools.rad-vscode-bicep",
"ms-kubernetes-tools.vscode-kubernetes-tools"
"ms-kubernetes-tools.vscode-kubernetes-tools",
"ms-azuretools.vscode-dapr",
"ms-vscode.makefile-tools"
]
}
}
},
// Prerequisite for Code Generation, see https://github.com/radius-project/radius/tree/main/docs/contributing/contributing-code/contributing-code-prerequisites#code-generation
// Adding workspace as safe directory to avoid permission issues
"postCreateCommand": "git config --global --add safe.directory /workspaces/radius && cd typespec && npm ci && npm install -g autorest && npm install -g oav && go install sigs.k8s.io/controller-tools/cmd/[email protected] && go install github.com/golang/mock/[email protected]",
"hostRequirements": {
"memory": "8gb"
},
}
8 changes: 0 additions & 8 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,3 @@ Please update the following to link the associated issue. This is required for s
-->

Fixes: #issue_number

## Auto-generated summary

<!--
GitHub Copilot for docs will auto-generate a summary of the PR
-->

copilot:all
5 changes: 5 additions & 0 deletions .github/workflows/devcontainer-feature-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ jobs:
generate-docs: "false"
# disable validation due to used preview feature
disable-schema-validation: "true"
# We handle tagging ourselves
disable-repo-tagging: "true"
# We don't want to include the repo name, being consistent without
# examples at https://containers.dev/collections
features-namespace: "radius-project/devcontainer-features"

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 0 additions & 2 deletions deploy/Chart/templates/rp/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ spec:
mountPath: {{ .Values.global.rootCA.mountPath }}
readOnly: true
{{- end }}
securityContext:
allowPrivilegeEscalation: false
{{- if .Values.rp.resources }}
resources:{{ toYaml .Values.rp.resources | nindent 10 }}
{{- end }}
Expand Down
4 changes: 2 additions & 2 deletions deploy/Chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ global:
secretName: "root-ca-cert"
volumeName: "root-ca-vol"
mountPath: "/tmp/sslcerts"
# SSL_CERT_DIRS is used to override the default root CA location.
# SSL_CERT_DIR is used to override the default root CA location.
# Dotnet runtime and Go use this environment variable to load the root CA.
sslCertDirEnvVar: "SSL_CERT_DIRS"
sslCertDirEnvVar: "SSL_CERT_DIR"

prometheus:
enabled: true
Expand Down
6 changes: 3 additions & 3 deletions deploy/devcontainer-feature/src/radcli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This will install the latest stable release of the `rad` CLI.

```json
"features": {
"ghcr.io/devcontainers/radius/radiuscli:latest": {
"ghcr.io/radius-project/devcontainer-features/radcli:latest": {
"version": "latest"
}
}
Expand All @@ -20,7 +20,7 @@ This will install the edge (unstable) release of the `rad` CLI.

```json
"features": {
"ghcr.io/devcontainers/radius/radiuscli:latest": {
"ghcr.io/radius-project/devcontainer-features/radcli:latest": {
"version": "edge"
}
}
Expand All @@ -32,7 +32,7 @@ This will install version 0.28.0 of the `rad` CLI.

```json
"features": {
"ghcr.io/devcontainers/radius/radiuscli:latest": {
"ghcr.io/radius-project/devcontainer-features/radcli:latest": {
"version": "0.28.0"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,56 @@

We support developing on macOS, Linux and Windows with [WSL](https://docs.microsoft.com/windows/wsl/install).

## Package managers

On our supported OSes using a package manager to install these dependencies is a much easier way to keep them updated.

- For macOS, this likely means you should be using [Homebrew](https://brew.sh/).
- On Linux, use your distribution's package manager.

## Required installs

This is the list of core dependencies to install for the most common tasks. In general we expect all contributors to have all of these tools present:
We recommend the usage of either GitHub Codespaces or dev containers to setup your development environment. Here are the links that provide more details:

- [Git](https://git-scm.com/downloads)
- [Getting started - GitHub Codespaces](../contributing-code-prerequisites/README.md#github-codespaces)
- [Getting started - Dev Containers](../contributing-code-prerequisites/README.md#vs-code-and-dev-container)

- Make

**Linux**: Install the `build-essential` package:
```bash
sudo apt-get install build-essential
```
**Mac**:
Using Xcode:
```bash
xcode-select --install
```
Using Homebrew:
```bash
brew install make
```
However, you can also install all tools locally. This is the list of core dependencies to install for the most common tasks. In general we expect all contributors to have all of these tools present:

- [Git](https://git-scm.com/downloads)
- [Go](https://golang.org/doc/install)
- [Node.js](https://nodejs.org/en/)
- [Python](https://www.python.org/downloads/)
- [Golangci-lint](https://golangci-lint.run/usage/install/#local-installation)
- [jq](https://jqlang.github.io/jq/download/)
- Make

### Install make

## Package managers
On our supported OSes using a package manager to install these dependencies is a much easier way to keep them updated.
- For macOS, this likely means you should be using [Homebrew](https://brew.sh/).
- On Linux, use your distro's package manager.
For `make` we advice the following installation steps depending on you OS.

#### Linux

Install the `build-essential` package:

```bash
sudo apt-get install build-essential
```

#### Mac

Using Xcode:

```bash
xcode-select --install
```

Using Homebrew:

```bash
brew install make
```

## Next step

- [Install development tools](first-commit-01-development-tools.md)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Editor

This guide covers basic development tasks for Go in Visual Studio Code. The experience with VS Code is high-quality and approachable for newcomers.
This guide covers basic development tasks for Go in Visual Studio Code (VS Code). The experience with VS Code is high-quality and approachable for newcomers.

Alternatively, you can choose whichever editor you are most comfortable for working on Go code. Feel free to skip this section if you want to make another choice.

Expand All @@ -15,6 +15,8 @@ Alternatively, you can choose whichever editor you are most comfortable for work
- [Visual Studio Code](https://code.visualstudio.com/)
- [Go extension](https://marketplace.visualstudio.com/items?itemName=golang.go)

> 📝 **Tip** - If your are using GitHub Codespaces or Dev Containers, the Go extension is already installed for you. You find more details on these options in the [Repository Prerequisites](../contributing-code-prerequisites/README.md).
Install both of these and then follow the steps in the *Quick Start* for the Go extension.

The extension will walk you through an automated install of some additional tools that match your installed version of Go.
Expand All @@ -23,16 +25,16 @@ The extension will walk you through an automated install of some additional tool

At this point you should be able to open any of the Go files in the repo and see syntax highlighting working.

**Launching VSCode**
## Launching VS Code

The best way to launch VS Code for Go is to do *File* -> *Open Folder* on the repository.
The best way to launch VS Code for Go is to do *File* -> *Open Folder* on the repository.

You can easily do this from the command shell with `code .`, which opens the current directory as a folder in VS Code.


## Next step

- [Build Radius](first-commit-02-building.md)

## Related links

- [Go in Visual Studio Code](https://code.visualstudio.com/docs/languages/go)
- [Go in Visual Studio Code](https://code.visualstudio.com/docs/languages/go)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,76 @@

## Debugging your changes

### Creating debug settings
The following sections describe the debugging in Visual Studio Code (VS Code). If you are using another editor you can skip the following sections.

You can debug your changes right from VS Code. It requires a small amount of set up for Go.
>📝 **Tip** The first time you debug on **macOS** with a given version of Go you will be prompted to enter your password. It is normal for this to take 1-2 minutes for the prompt to appear the first time.
First, open the [**Run View**](https://code.visualstudio.com/docs/editor/debugging#_run-view) in VS Code. You can do this either by clicking the icon or using the keyboard shortcut `shift+command+D` (`shift+control+d`) on Windows.
## Predefined debug configurations

<img width="300px" src="run-view.png" alt="Selecting the run view">
You can debug your changes right from VS Code. The repository has a `.vscode` directory which contains several launch configurations containing debugging configurations. We describe the configurations in the following sections.

At the top of the new pane you should see something like the following:
### Debugging rad CLI

<img width="400px" src="options-in-run-view.png" alt="Opens in the run view"><br />
This section describes the configuration named **"Debug rad CLI"**. This is a basic Go debugger configuration that is set up to launch the `rad` CLI. To try it out, set a breakpoint in `main.go`. Set the breakpoint by clicking in the *gutter* to the left of the line numbers in you editor. Place the breakpoint on the new line you added in `main.go`.

Click on `create a launch.json file`.
<img src="img/main-with-breakpoint.png" alt="Placing a breakpoint in main.go" width="600" height="auto">

The debugger will stop the program prior to crossing over your breakpoint. Execute the following steps to launch the CLI in the debugger:

This will open the file `.vscode/launch.json` in the editor. This is where VS Code stores information about different debugging configurations.
- Open the debug pane.

Replace the contents with the following text:
<img src="img/vscode-debug-pane.png" alt="VS Code debug pane" width="600" height="auto">

```bash
{
"version": "0.2.0",
"configurations": [
{
"name": "rad CLI",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/cmd/rad/main.go",
"cwd": "${workspaceFolder}",
- Select the **"Debug rad CLI"** entry from the drop down list.

// If you need to specify command line arguments
// for the CLI they go here as a JSON array of strings
"args": []
}
]
}
```
<img src="img/vscode-debug-config-selection.png" alt="VS Code debug configuration selection" width="600" height="auto">

> This is a basic Go debugger configuration that is set up to launch the `rad` CLI. You can create definitions for any set of debug settings you want to keep handy.
- Click the icon with the green triangle to launch the debugging session.

### Running with the debugger
<img src="img/vscode-debug-start.png" alt="VS Code start selected debug configuration" width="600" height="auto">

To try it out, first you should set a breakpoint in `main.go`. The debugger will stop the program prior to crossing over your breakpoint.
Before the debugging will start the project is build in the background. This might take some time. After the build is completed the program will start and the breakpoint should be hit.

Set a breakpoint by clicking in the *gutter* to the left of the line numbers in you editor. Place the breakpoint on the new line you added in `main.go`.
<img src="img/main-breakpoint-hit.png" alt="Hitting a breakpoint in main.go" width="600" height="auto">

<img width="600px" src="main-with-breakpoint.png" alt="Placing a breakpoint">
You can play around with the various debugger features, like stepping into code. When you're done, hit the red square *stop* icon in the debugger tools to end the debugging session.

> 📝 **Tip** - You can create definitions for any set of debug settings you want to keep handy.
### Debug rad CLI - prompt for args

This section describes the configuration named **"Debug rad CLI (prompt for args)"**. In contrast to the previous generic one this one uses the specific `rad CLI` commands to kick of the debugger.

Let us test this setup by checking debugging the `rad version` command. The file is located at `cmd/rad/cmd/version.go`. Set a breakpoint at the beginning of the function `writeVersionString`:

<img src="img/version-with-breakpoint.png" alt="Placing a breakpoint in version.go" width="600" height="auto">

The debugger will stop the program prior to crossing over your breakpoint. Execute the following steps to launch the CLI command in the debugger:

Now you can launch the CLI in the debugger. Press `F5` to launch the debugger. Alternatively, you can click the icon with the green triangle in the *run view* to launch.
- Open the debug pane.

After some time the program will start and the breakpoint should be hit.
<img src="img/vscode-debug-pane.png" alt="VS Code debug pane" width="600" height="auto">

>**macOS permissions** <br>
The first time you debug on macOS with a given version of Go you will be prompted to enter your password. It is normal for this to take 1-2 minutes for the prompt to appear the first time.
- Select the **"Debug rad CLI (prompt for args)"** entry from the drop down list.

<img width="600px" src="main-breakpoint-hit.png" alt="Hitting a breakpoint">
<img src="img/vscode-debug-config-selection-with-args.png" alt="VS Code debug configuration selection with arguments" width="600" height="auto">

- Click the icon with the green triangle to launch the debugging session.

<img src="img/vscode-debug-start-version-with-args.png" alt="VS Code start selected debug configuration with arguments" width="600" height="auto">

- The system will open up the command palette. Enter the command you want to debug i.e. `version` and confirm.

<img src="img/vscode-debug-prompt-cmd.png" alt="VS Code debug command prompt" width="600" height="auto">

Before the debugging will start the project is build in the background. This might take some time. After the build is completed the program will start and the breakpoint should be hit.

<img src="img/version-breakpoint-hit.png" alt="Hitting a breakpoint in version.go" width="600" height="auto">

You can play around with the various debugger features, like stepping into code. When you're done, hit the red square *stop* icon in the debugger tools to end the debugging session.

## Next step

- [Run tests](../first-commit-05-running-tests/index.md)

## Related Links
Expand Down
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 4962f1b

Please sign in to comment.