Skip to content

Commit

Permalink
Make main() code consistent (#8034)
Browse files Browse the repository at this point in the history
# Description

This change updates each entry point of our microservices to the
following in a more consistent way.

- Use cobra for argument parsing and help.
- Accept the configuration file using `--config-file` as a commandline
option.
- Use a consistent pattern for choosing the ports used for various
purposes.

The port changes only affect local development. In Kuberentes each pod
can choose its own listening port without conflict.


## Type of change

- This pull request is a minor refactor, code cleanup, test improvement,
or other maintenance task and doesn't change the functionality of Radius
(issue link optional).


## Contributor checklist
Please verify that the PR meets the following requirements, where
applicable:

- [ ] An overview of proposed schema changes is included in a linked
GitHub issue.
- [ ] A design document PR is created in the [design-notes
repository](https://github.com/radius-project/design-notes/), if new
APIs are being introduced.
- [ ] If applicable, design document has been reviewed and approved by
Radius maintainers/approvers.
- [ ] A PR for the [samples
repository](https://github.com/radius-project/samples) is created, if
existing samples are affected by the changes in this PR.
- [ ] A PR for the [documentation
repository](https://github.com/radius-project/docs) is created, if the
changes in this PR affect the documentation or any user facing updates
are made.
- [ ] A PR for the [recipes
repository](https://github.com/radius-project/recipes) is created, if
existing recipes are affected by the changes in this PR.

Signed-off-by: Ryan Nowak <[email protected]>
  • Loading branch information
rynowak authored Nov 6, 2024
1 parent 59672f4 commit 1394f69
Show file tree
Hide file tree
Showing 10 changed files with 373 additions and 322 deletions.
271 changes: 138 additions & 133 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,134 +1,139 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug rad CLI",
"type": "go",
"request": "launch",
"mode": "auto",
"preLaunchTask": "Build Radius (all)",
"program": "${workspaceFolder}/cmd/rad/main.go",
"cwd": "${workspaceFolder}",
"args": [],
},
{
"name": "Debug rad CLI (prompt for args)",
"type": "go",
"request": "launch",
"mode": "debug",
"preLaunchTask": "Build Radius (all)",
"program": "${workspaceFolder}/cmd/rad",
"args": "${input:cliArgs}",
"console": "integratedTerminal",
},
{
"name": "Launch Applications RP",
"type": "go",
"request": "launch",
"mode": "auto",
"preLaunchTask": "Build Radius (all)",
"program": "${workspaceFolder}/cmd/applications-rp/main.go",
"args": [
"--config-file",
"${workspaceFolder}/cmd/applications-rp/radius-self-hosted.yaml",
],
"env": {
"RADIUS_ENV": "self-hosted"
}
},{
"name": "Launch Dynamic RP",
"type": "go",
"request": "launch",
"mode": "auto",
"preLaunchTask": "Build Radius (all)",
"program": "${workspaceFolder}/cmd/dynamic-rp/main.go",
},
{
"name": "Launch UCP",
"type": "go",
"request": "launch",
"mode": "auto",
"preLaunchTask": "Build Radius (all)",
"program": "${workspaceFolder}/cmd/ucpd/main.go",
"cwd": "${workspaceFolder}",
"env": {
"BASE_PATH": "/apis/api.ucp.dev/v1alpha3",
"PORT": "9000",
"UCP_CONFIG": "${workspaceFolder}/cmd/ucpd/ucp-self-hosted-dev.yaml"
}
},
{
"name": "Launch Controller",
"type": "go",
"request": "launch",
"mode": "auto",
"preLaunchTask": "Build Radius (all)",
"program": "${workspaceFolder}/cmd/controller/main.go",
"cwd": "${workspaceFolder}",
"args": [
"--config-file",
"${workspaceFolder}/cmd/controller/controller-self-hosted.yaml",
"--cert-dir",
""
],
"env": {
"RADIUS_ENV": "self-hosted"
}
},
{
"name": "Launch Deployment Engine",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "Build Deployment Engine",
"program": "${workspaceFolder}/../deployment-engine/src/DeploymentEngine/bin/Debug/net6.0/arm-de.dll",
"args": [],
"cwd": "${workspaceFolder}/../deployment-engine/src/DeploymentEngine",
"stopAtEntry": false,
"env": {
"ASPNETCORE_URLS": "http://localhost:5017",
"ASPNETCORE_ENVIRONMENT": "Development",
"KUBERNETESBICEPEXTENSIBILITYURL": "http://localhost:5017/api",
"RADIUSBACKENDURI": "http://localhost:9000",
},
},
{
"name": "Debug Bicep generator integration tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/hack/bicep-types-radius/src/autorest.bicep/node_modules/.bin/jest",
"--runInBand",
"--no-cache"
],
"cwd": "${workspaceFolder}/hack/bicep-types-radius/src/autorest.bicep/src",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"sourceMaps": true
},
],
"compounds": [
{
"name": "Launch Control Plane (all)",
"configurations": [
"Launch UCP",
"Launch Dynamic RP",
"Launch Applications RP",
"Launch Controller",
"Launch Deployment Engine",
],
"stopAll": true
}
],
"inputs": [
{
"id": "cliArgs",
"type": "promptString",
"description": "Args for launching Radius cli. Use --cwd to set the working directory.",
"default": "init --full"
}
]
}
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug rad CLI",
"type": "go",
"request": "launch",
"mode": "auto",
"preLaunchTask": "Build Radius (all)",
"program": "${workspaceFolder}/cmd/rad/main.go",
"cwd": "${workspaceFolder}",
"args": []
},
{
"name": "Debug rad CLI (prompt for args)",
"type": "go",
"request": "launch",
"mode": "debug",
"preLaunchTask": "Build Radius (all)",
"program": "${workspaceFolder}/cmd/rad",
"args": "${input:cliArgs}",
"console": "integratedTerminal"
},
{
"name": "Launch Applications RP",
"type": "go",
"request": "launch",
"mode": "auto",
"preLaunchTask": "Build Radius (all)",
"program": "${workspaceFolder}/cmd/applications-rp/main.go",
"args": [
"--config-file",
"${workspaceFolder}/cmd/applications-rp/radius-self-hosted.yaml"
],
"env": {
"RADIUS_ENV": "self-hosted"
}
},
{
"name": "Launch Dynamic RP",
"type": "go",
"request": "launch",
"mode": "auto",
"preLaunchTask": "Build Radius (all)",
"program": "${workspaceFolder}/cmd/dynamic-rp/main.go",
},
{
"name": "Launch UCP",
"type": "go",
"request": "launch",
"mode": "auto",
"preLaunchTask": "Build Radius (all)",
"program": "${workspaceFolder}/cmd/ucpd/main.go",
"cwd": "${workspaceFolder}",
"args": [
"--config-file",
"${workspaceFolder}/cmd/ucpd/ucp-dev.yaml"
],
"env": {
"BASE_PATH": "/apis/api.ucp.dev/v1alpha3",
"PORT": "9000",
"UCP_CONFIG": "${workspaceFolder}/cmd/ucpd/ucp-self-hosted-dev.yaml"
}
},
{
"name": "Launch Controller",
"type": "go",
"request": "launch",
"mode": "auto",
"preLaunchTask": "Build Radius (all)",
"program": "${workspaceFolder}/cmd/controller/main.go",
"cwd": "${workspaceFolder}",
"args": [
"--config-file",
"${workspaceFolder}/cmd/controller/controller-self-hosted.yaml",
"--cert-dir",
""
],
"env": {
"RADIUS_ENV": "self-hosted"
}
},
{
"name": "Launch Deployment Engine",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "Build Deployment Engine",
"program": "${workspaceFolder}/../deployment-engine/src/DeploymentEngine/bin/Debug/net6.0/arm-de.dll",
"args": [],
"cwd": "${workspaceFolder}/../deployment-engine/src/DeploymentEngine",
"stopAtEntry": false,
"env": {
"ASPNETCORE_URLS": "http://localhost:5017",
"ASPNETCORE_ENVIRONMENT": "Development",
"KUBERNETESBICEPEXTENSIBILITYURL": "http://localhost:5017/api",
"RADIUSBACKENDURI": "http://localhost:9000"
}
},
{
"name": "Debug Bicep generator integration tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/hack/bicep-types-radius/src/autorest.bicep/node_modules/.bin/jest",
"--runInBand",
"--no-cache"
],
"cwd": "${workspaceFolder}/hack/bicep-types-radius/src/autorest.bicep/src",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"sourceMaps": true
}
],
"compounds": [
{
"name": "Launch Control Plane (all)",
"configurations": [
"Launch UCP",
"Launch Applications RP",
"Launch Dynamic RP",
"Launch Controller",
"Launch Deployment Engine"
],
"stopAll": true
}
],
"inputs": [
{
"id": "cliArgs",
"type": "promptString",
"description": "Args for launching Radius cli. Use --cwd to set the working directory.",
"default": "init --full"
}
]
}
Loading

0 comments on commit 1394f69

Please sign in to comment.