From c1a8d16b9eeb0f064064730b05741fbf5099f234 Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 1 Feb 2024 15:36:31 -0600 Subject: [PATCH 1/9] Fix Delete application confirmation message points to the workspace but says environment #7089 (#7095) Signed-off-by: Josh # Description Parse out the environment name from the Workspace.Environment property using the resources library. ## Type of change This pull request fixes a bug in Radius and has an approved issue Fixes: #7089 --------- Signed-off-by: Josh Handel Signed-off-by: Josh Signed-off-by: Josh josh@liveoak.ws Co-authored-by: Shalabh Mohan Shrivastava --- pkg/cli/cmd/app/delete/delete.go | 14 ++++++++++- pkg/cli/cmd/app/delete/delete_test.go | 35 +++++++++++++++++---------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/pkg/cli/cmd/app/delete/delete.go b/pkg/cli/cmd/app/delete/delete.go index a271f5dbc1..6450bcd716 100644 --- a/pkg/cli/cmd/app/delete/delete.go +++ b/pkg/cli/cmd/app/delete/delete.go @@ -29,6 +29,7 @@ import ( "github.com/radius-project/radius/pkg/cli/output" "github.com/radius-project/radius/pkg/cli/prompt" "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/ucp/resources" "github.com/spf13/cobra" ) @@ -82,6 +83,7 @@ type Runner struct { Output output.Interface ApplicationName string + EnvironmentName string Scope string Confirm bool Workspace *workspaces.Workspace @@ -121,6 +123,16 @@ func (r *Runner) Validate(cmd *cobra.Command, args []string) error { return err } + // Lookup the environment name for use in the confirmation prompt + if workspace.Environment != "" { + id, err := resources.ParseResource(workspace.Environment) + if err != nil { + return err + } + + r.EnvironmentName = id.Name() + } + // Throw error if user specifies a Bicep filename or path instead of an application name if strings.HasSuffix(r.ApplicationName, ".bicep") { return clierrors.Message(bicepWarning, r.ApplicationName) @@ -143,7 +155,7 @@ func (r *Runner) Validate(cmd *cobra.Command, args []string) error { func (r *Runner) Run(ctx context.Context) error { // Prompt user to confirm deletion if !r.Confirm { - confirmed, err := prompt.YesOrNoPrompt(fmt.Sprintf(deleteConfirmation, r.ApplicationName, r.Workspace.Name), prompt.ConfirmNo, r.InputPrompter) + confirmed, err := prompt.YesOrNoPrompt(fmt.Sprintf(deleteConfirmation, r.ApplicationName, r.EnvironmentName), prompt.ConfirmNo, r.InputPrompter) if err != nil { return err } diff --git a/pkg/cli/cmd/app/delete/delete_test.go b/pkg/cli/cmd/app/delete/delete_test.go index 8ce34e89cf..a0084092b1 100644 --- a/pkg/cli/cmd/app/delete/delete_test.go +++ b/pkg/cli/cmd/app/delete/delete_test.go @@ -132,8 +132,9 @@ func Test_Show(t *testing.T) { "kind": "kubernetes", "context": "kind-kind", }, - Name: "kind-kind", - Scope: "/planes/radius/local/resourceGroups/test-group", + Name: "kind-kind", + Scope: "/planes/radius/local/resourceGroups/test-group", + Environment: "/planes/radius/local/resourceGroups/default/providers/Applications.Core/environments/default", } outputSink := &output.MockOutput{} runner := &Runner{ @@ -166,13 +167,14 @@ func Test_Show(t *testing.T) { "kind": "kubernetes", "context": "kind-kind", }, - Name: "kind-kind", - Scope: "/planes/radius/local/resourceGroups/test-group", + Name: "kind-kind", + Scope: "/planes/radius/local/resourceGroups/test-group", + Environment: "/planes/radius/local/resourceGroups/default/providers/Applications.Core/environments/default", } promptMock := prompt.NewMockInterface(ctrl) promptMock.EXPECT(). - GetListInput([]string{prompt.ConfirmNo, prompt.ConfirmYes}, fmt.Sprintf(deleteConfirmation, "test-app", workspace.Name)). + GetListInput([]string{prompt.ConfirmNo, prompt.ConfirmYes}, fmt.Sprintf(deleteConfirmation, "test-app", "default")). Return(prompt.ConfirmYes, nil). Times(1) @@ -189,6 +191,7 @@ func Test_Show(t *testing.T) { Workspace: workspace, Output: outputSink, ApplicationName: "test-app", + EnvironmentName: "default", } err := runner.Run(context.Background()) @@ -213,13 +216,14 @@ func Test_Show(t *testing.T) { "kind": "kubernetes", "context": "kind-kind", }, - Name: "kind-kind", - Scope: "/planes/radius/local/resourceGroups/test-group", + Name: "kind-kind", + Scope: "/planes/radius/local/resourceGroups/test-group", + Environment: "/planes/radius/local/resourceGroups/default/providers/Applications.Core/environments/default", } promptMock := prompt.NewMockInterface(ctrl) promptMock.EXPECT(). - GetListInput([]string{prompt.ConfirmNo, prompt.ConfirmYes}, fmt.Sprintf(deleteConfirmation, "test-app", workspace.Name)). + GetListInput([]string{prompt.ConfirmNo, prompt.ConfirmYes}, fmt.Sprintf(deleteConfirmation, "test-app", "default")). Return(prompt.ConfirmNo, nil). Times(1) @@ -229,6 +233,7 @@ func Test_Show(t *testing.T) { Workspace: workspace, Output: outputSink, ApplicationName: "test-app", + EnvironmentName: "default", } err := runner.Run(context.Background()) @@ -255,8 +260,9 @@ func Test_Show(t *testing.T) { "kind": "kubernetes", "context": "kind-kind", }, - Name: "kind-kind", - Scope: "/planes/radius/local/resourceGroups/test-group", + Name: "kind-kind", + Scope: "/planes/radius/local/resourceGroups/test-group", + Environment: "/planes/radius/local/resourceGroups/default/providers/Applications.Core/environments/default", } outputSink := &output.MockOutput{} runner := &Runner{ @@ -264,6 +270,7 @@ func Test_Show(t *testing.T) { Workspace: workspace, Output: outputSink, ApplicationName: "test-app", + EnvironmentName: "default", Confirm: true, } @@ -290,13 +297,14 @@ func Test_Show(t *testing.T) { "kind": "kubernetes", "context": "kind-kind", }, - Name: "kind-kind", - Scope: "/planes/radius/local/resourceGroups/test-group", + Name: "kind-kind", + Scope: "/planes/radius/local/resourceGroups/test-group", + Environment: "/planes/radius/local/resourceGroups/default/providers/Applications.Core/environments/default", } promptMock := prompt.NewMockInterface(ctrl) promptMock.EXPECT(). - GetListInput([]string{prompt.ConfirmNo, prompt.ConfirmYes}, fmt.Sprintf(deleteConfirmation, "test-app", workspace.Name)). + GetListInput([]string{prompt.ConfirmNo, prompt.ConfirmYes}, fmt.Sprintf(deleteConfirmation, "test-app", "default")). Return("", &prompt.ErrExitConsole{}). Times(1) @@ -306,6 +314,7 @@ func Test_Show(t *testing.T) { Output: outputSink, Workspace: workspace, ApplicationName: "test-app", + EnvironmentName: "default", } err := runner.Run(context.Background()) From 2e4d2edc23987271db24a1c1ed1588bc53234f90 Mon Sep 17 00:00:00 2001 From: vinayada1 <28875764+vinayada1@users.noreply.github.com> Date: Thu, 1 Feb 2024 16:42:33 -0800 Subject: [PATCH 2/9] versions.yaml updated for release 0.30 - final release (#7103) # Description versions.yaml updated for release 0.30 - final release ## 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). Fixes: #issue_number --------- Signed-off-by: vinayada1 <28875764+vinayada1@users.noreply.github.com> --- docs/release-notes/v0.30.0.md | 87 +++++++++++++++++++++++++++++++++++ versions.yaml | 4 +- 2 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 docs/release-notes/v0.30.0.md diff --git a/docs/release-notes/v0.30.0.md b/docs/release-notes/v0.30.0.md new file mode 100644 index 0000000000..05ab758f60 --- /dev/null +++ b/docs/release-notes/v0.30.0.md @@ -0,0 +1,87 @@ +## Announcing Radius v0.30.0 + +Today we're happy to announce the release of Radius v0.30.0. Check out the [highlights](#highlights) below, along with the [full changelog](#full-changelog) for more details. + +We would like to extend our thanks to all the [new](#new-contributors) and existing contributors who helped make this release possible! + +## Intro to Radius + +If you're new to Radius, check out our website, [radapp.io](https://radapp.io), for more information. Also visit our [getting started guide](https://docs.radapp.io/getting-started/) to learn how to install Radius and create your first app. + +## Highlights + +### Terraform Recipe enhancements + +We’ve added a bunch of new supported features and scenarios for Terraform Recipes, including sub-module support, Git module source support, and version ranges. We’re actively working on additional features such as private modules and any provider. Stay tuned for updates! Learn more in [our docs](https://docs.radapp.io/guides/recipes/overview/). + +### Radius roadmap + +The Radius roadmap is now published at https://aka.ms/radius-roadmap, where you can keep track of all the major features and improvements we are tracking. Check it out and make sure to upvote and leave feedback on your favorites! + +### Introducing the Radius dashboard + +We’re excited to share a first look at a new experimental feature of Radius: the Radius dashboard! Our new dashboard allows you to interact with Radius environments, applications, and recipes from an easy-to-use graphical interface. Visit the [dashboard repo](https://github.com/radius-project/dashboard) to try it out today. + +## Breaking changes + +None + +## New contributors + +Welcome to our new contributors who have merged their first PR in this release! + +* @IvanJosipovic made their first contribution in https://github.com/radius-project/radius/pull/6996 +* @gpltaylor made their first contribution in https://github.com/radius-project/radius/pull/6974 +* @akshayrohilla made their first contribution in https://github.com/radius-project/radius/pull/7083 + +## Upgrading to Radius v0.30.0 + +During our preview stage, an upgrade to Radius v0.30.0 requires a full reinstallation of the Radius control-plane, rad CLI, and all Radius apps. Stay tuned for an in-place upgrade path in the future. + +1. Delete any environments you have created: + ```bash + rad env delete + ``` +1. Uninstall the previous version of the Radius control-plane: + ```bash + rad uninstall kubernetes + ``` +1. Visit the [Radius installation guide](https://docs.radapp.io/getting-started/install/) to install the latest CLI, or download a binary below +1. Install the latest version of the Radius control-plane: + ```bash + rad install kubernetes + ``` + +## Full changelog + +* Remove copilot4prs by @sk593 in https://github.com/radius-project/radius/pull/6988 +* Create 0.29.0 release by @nithyatsu in https://github.com/radius-project/radius/pull/6992 +* fix: remove duplicate securityContext by @IvanJosipovic in https://github.com/radius-project/radius/pull/6996 +* Get long-haul test cluster working by @ytimocin in https://github.com/radius-project/radius/pull/6936 +* [Add] Adding ignore-not-found to the deletion of certificate in long haul test workflow by @ytimocin in https://github.com/radius-project/radius/pull/6999 +* Improve error message under 401 condition with Azure ACR by @gpltaylor in https://github.com/radius-project/radius/pull/6974 +* Remove skipped test by @kachawla in https://github.com/radius-project/radius/pull/6998 +* Restore AWS S3 tests by @willdavsmith in https://github.com/radius-project/radius/pull/6993 +* Enable CLI container port expose test by @youngbupark in https://github.com/radius-project/radius/pull/7000 +* Enable Bicep recipe unit-test with fake registry server by @youngbupark in https://github.com/radius-project/radius/pull/7021 +* Remove old issues workflow by @AaronCrawfis in https://github.com/radius-project/radius/pull/7020 +* chore: replace issue templates with forms by @lechnerc77 in https://github.com/radius-project/radius/pull/6982 +* Updating the caBundle for the controller webhook by @ytimocin in https://github.com/radius-project/radius/pull/7022 +* Updating the Radius installation step of the long-haul workflow by @ytimocin in https://github.com/radius-project/radius/pull/7008 +* Add Functional Test for Bicep Recipe Context Parameter by @kachawla in https://github.com/radius-project/radius/pull/7041 +* Add event logging for Terraform recipe publishing by @sk593 in https://github.com/radius-project/radius/pull/7028 +* Updating delete confirmation message by @ytimocin in https://github.com/radius-project/radius/pull/7049 +* Avoid docker debian image ratelimitting issue in long running test by @youngbupark in https://github.com/radius-project/radius/pull/7067 +* Make the properties field of tracked resource required by @vinayada1 in https://github.com/radius-project/radius/pull/6889 +* Add check for Terraform submodules by @sk593 in https://github.com/radius-project/radius/pull/7013 +* Support direct route connection in AppGraph by @youngbupark in https://github.com/radius-project/radius/pull/7072 +* Fix connection direction by @youngbupark in https://github.com/radius-project/radius/pull/7076 +* Support routes.*.destination of gateway for App Graph by @youngbupark in https://github.com/radius-project/radius/pull/7079 +* Remove rad app switch reference from the error message by @akshayrohilla in https://github.com/radius-project/radius/pull/7083 +* Fix release race condition by @willdavsmith in https://github.com/radius-project/radius/pull/6995 +* Update versions.yaml for 0.30 rc by @vinayada1 in https://github.com/radius-project/radius/pull/7091 +* Fix syntax error in release.yaml workflow by @willdavsmith in https://github.com/radius-project/radius/pull/7092 +* Re-enable skipped test `Test_RecipeCommands` by @sk593 in https://github.com/radius-project/radius/pull/7080 +* Create RC2 release version by @vinayada1 in https://github.com/radius-project/radius/pull/7093 +* Add error handling in case release branch doesn't exist yet by @willdavsmith in https://github.com/radius-project/radius/pull/7094 +* update versions file for rc3 release by @vinayada1 in https://github.com/radius-project/radius/pull/7096 \ No newline at end of file diff --git a/versions.yaml b/versions.yaml index 95a428b747..0e4a7baad8 100644 --- a/versions.yaml +++ b/versions.yaml @@ -1,9 +1,9 @@ supported: - channel: '0.30' - version: 'v0.30.0-rc3' + version: 'v0.30.0' +deprecated: - channel: '0.29' version: 'v0.29.0' -deprecated: - channel: '0.28' version: 'v0.28.0' - channel: '0.27' From 5b5153ed8286e5513d116d76fd4f366c33ba6359 Mon Sep 17 00:00:00 2001 From: Will Smith Date: Fri, 2 Feb 2024 10:53:45 -0800 Subject: [PATCH 3/9] Run release workflow on push to release branch (#7127) # Description * Fix release.yaml to run release workflow on push to release branch ## Type of change - This pull request fixes a bug in Radius and has an approved issue (issue link required). - This pull request adds or changes features of Radius and has an approved issue (issue link required). - 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). Fixes: #7113 Signed-off-by: willdavsmith --- .github/workflows/release.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7a7e190408..81d438427d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -20,6 +20,7 @@ on: push: branches: - main + - 'release/*' paths: - 'versions.yaml' pull_request: From 189120dc9c8f76de32b53634cbabbdcfc040d394 Mon Sep 17 00:00:00 2001 From: Yetkin Timocin Date: Fri, 2 Feb 2024 15:13:03 -0800 Subject: [PATCH 4/9] Adding GHCR login step to the long running tests (#7130) # Description * Added `Login to GHCR` to the `tests` job. Not sure why this has started failing. We didn't have this step for a long time and it was working fine. We have the login step in the Build job. I would like to discuss further and find out. ~~Any ideas? cc/ @youngbupark @rynowak @AaronCrawfis~~ Discussed with @sk593 and found out that there was a skipped test that got enabled a few days ago. That test required GHCR login which we were missing in the `tests` job of the Long Running workflow. ## 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). Fixes: #7102 Signed-off-by: ytimocin --- .github/workflows/long-running-azure.yaml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/long-running-azure.yaml b/.github/workflows/long-running-azure.yaml index 6090bbbf86..841294cefd 100644 --- a/.github/workflows/long-running-azure.yaml +++ b/.github/workflows/long-running-azure.yaml @@ -45,11 +45,11 @@ on: branches: - main paths: - - '.github/workflows/long-running-azure.yaml' + - ".github/workflows/long-running-azure.yaml" env: # Go version - GOVER: '^1.21' + GOVER: "^1.21" GOPROXY: https://proxy.golang.org # gotestsum version - see: https://github.com/gotestyourself/gotestsum @@ -70,24 +70,24 @@ env: # The region for AWS resources AWS_REGION: us-west-2 # The AWS account ID - AWS_ACCOUNT_ID: '${{ secrets.FUNCTEST_AWS_ACCOUNT_ID }}' + AWS_ACCOUNT_ID: "${{ secrets.FUNCTEST_AWS_ACCOUNT_ID }}" # The valid radius build time window in seconds to rebuild radius. 24 hours = 24 * 60 * 60 = 86400 VALID_RADIUS_BUILD_WINDOW: 86400 # The AKS cluster name - AKS_CLUSTER_NAME: 'radiuse2e00-aks' + AKS_CLUSTER_NAME: "radiuse2e00-aks" # The resource group for AKS_CLUSTER_NAME resource. - AKS_RESOURCE_GROUP: 'radiuse2e00' + AKS_RESOURCE_GROUP: "radiuse2e00" # Server where terraform test modules are deployed - TF_RECIPE_MODULE_SERVER_URL: 'http://tf-module-server.radius-test-tf-module-server.svc.cluster.local' + TF_RECIPE_MODULE_SERVER_URL: "http://tf-module-server.radius-test-tf-module-server.svc.cluster.local" # Radius test environment name - RADIUS_TEST_ENVIRONMENT_NAME: 'kind-radius' + RADIUS_TEST_ENVIRONMENT_NAME: "kind-radius" # The current GitHub action link - ACTION_LINK: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' + ACTION_LINK: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" jobs: build: @@ -333,6 +333,12 @@ jobs: uses: azure/login@v1 with: creds: '{"clientId":"${{ secrets.INTEGRATION_TEST_SP_APP_ID }}","clientSecret":"${{ secrets.INTEGRATION_TEST_SP_PASSWORD }}","subscriptionId":"${{ secrets.INTEGRATION_TEST_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.INTEGRATION_TEST_TENANT_ID }}"}' + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Create azure resource group - ${{ env.AZURE_TEST_RESOURCE_GROUP }} run: | current_time=$(date +%s) From 76f57852a906e67d2cbee6f609a4c6bca153b853 Mon Sep 17 00:00:00 2001 From: Karishma Chawla Date: Mon, 5 Feb 2024 12:14:35 -0800 Subject: [PATCH 5/9] Use unique resource names in test Terraform Recipe (#7108) # Description Trying a fix for https://github.com/radius-project/radius/issues/7060. Resource name uniqueness is tied to resource group right now, potentially causing concurrency issues. ## Type of change - This pull request fixes a bug in Radius and has an approved issue (issue link required). - 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). Fixes: https://github.com/radius-project/radius/issues/7060 Signed-off-by: karishma-chawla <74574173+karishma-chawla@users.noreply.github.com> Co-authored-by: karishma-chawla <74574173+karishma-chawla@users.noreply.github.com> --- .../corerp-resources-terraform-azurestorage.bicep | 1 - .../test-terraform-recipes/azure-storage/main.tf | 10 +++++++--- .../test-terraform-recipes/azure-storage/variables.tf | 4 ---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/test/functional/shared/resources/testdata/corerp-resources-terraform-azurestorage.bicep b/test/functional/shared/resources/testdata/corerp-resources-terraform-azurestorage.bicep index edd8140e00..e560de7606 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-terraform-azurestorage.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-terraform-azurestorage.bicep @@ -27,7 +27,6 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { templateKind: 'terraform' templatePath: '${moduleServer}/azure-storage.zip' parameters: { - name: 'blob${uniqueString(resourceGroup().id)}' resource_group_name: resourceGroup().name location: location } diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/azure-storage/main.tf b/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/azure-storage/main.tf index 7f6e0aeda1..8655f5fa5d 100644 --- a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/azure-storage/main.tf +++ b/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/azure-storage/main.tf @@ -7,8 +7,12 @@ terraform { } } +resource "random_id" "unique_name" { + byte_length = 8 +} + resource "azurerm_storage_account" "test_storage_account" { - name = var.name + name = "acct${random_id.unique_name.hex}" resource_group_name = var.resource_group_name location = var.location account_tier = "Standard" @@ -16,12 +20,12 @@ resource "azurerm_storage_account" "test_storage_account" { } resource "azurerm_storage_container" "test_container" { - name = "test-container" + name = "ctr${random_id.unique_name.hex}" storage_account_name = azurerm_storage_account.test_storage_account.name } resource "azurerm_storage_blob" "test_blob" { - name = "test-blob" + name = "blob${random_id.unique_name.hex}" storage_account_name = azurerm_storage_account.test_storage_account.name storage_container_name = azurerm_storage_container.test_container.name type = "Block" diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/azure-storage/variables.tf b/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/azure-storage/variables.tf index a1e8130e1a..b448fb39f2 100644 --- a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/azure-storage/variables.tf +++ b/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/azure-storage/variables.tf @@ -1,7 +1,3 @@ -variable "name" { - type = string -} - variable "resource_group_name" { type = string } From c708fe27ea707c5befa15c0409f7e2f0e52bb03b Mon Sep 17 00:00:00 2001 From: Karishma Chawla Date: Wed, 7 Feb 2024 17:30:56 -0800 Subject: [PATCH 6/9] Add GH action to close stale PRs (#7143) # Description To declutter the PR queue and ensure that active contributions receive attention, enabling https://github.com/actions/stale github action to automatically close stale PRs after 90 days of inactivity, with a notification period of 7 days. This will provide contributors with a reasonable window to address any outstanding feedback or issues before the PR is automatically closed. We can adjust this timeframe in the future based on the feedback and learnings. We can also consider PRs labeled with certain labels to be excluded from this workflow if we see the need for this in the future: https://github.com/actions/stale?tab=readme-ov-file#exempt-pr-labels. ## Type of change - This pull request adds or changes features of Radius and has an approved issue (issue link required). - 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). Fixes: https://github.com/radius-project/radius/issues/7151 --------- Signed-off-by: Karishma Chawla Signed-off-by: karishma-chawla <74574173+karishma-chawla@users.noreply.github.com> Co-authored-by: karishma-chawla <74574173+karishma-chawla@users.noreply.github.com> --- .github/workflows/stale-prs.yml | 27 +++++++++++++++++++ .../contributing-pull-requests/README.md | 6 ++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/stale-prs.yml diff --git a/.github/workflows/stale-prs.yml b/.github/workflows/stale-prs.yml new file mode 100644 index 0000000000..04eec4cf6e --- /dev/null +++ b/.github/workflows/stale-prs.yml @@ -0,0 +1,27 @@ +# This workflow warns and then closes PRs that have had no activity for 90 days. +# +# For more information, see: +# https://github.com/actions/stale +name: Close stale pull requests + +on: + schedule: + - cron: '0 18 * * *' # Run the workflow every day at 6PM UTC (10AM PST). + +jobs: + stale: + + runs-on: ubuntu-latest + permissions: + pull-requests: write + + steps: + - uses: actions/stale@v5 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-pr-message: 'This pull request has been automatically marked as stale because it has been inactive for 90 days. Remove stale label or comment or this PR will be closed in 7 days.' + stale-pr-label: 'stale' + days-before-pr-stale: 90 # 3 months + days-before-pr-close: 7 + days-before-issue-stale: -1 + days-before-issue-close: -1 diff --git a/docs/contributing/contributing-pull-requests/README.md b/docs/contributing/contributing-pull-requests/README.md index 70fdbf9b2b..ddb8a72446 100644 --- a/docs/contributing/contributing-pull-requests/README.md +++ b/docs/contributing/contributing-pull-requests/README.md @@ -102,4 +102,8 @@ If you are the code reviewer, it's your responsibility to follow up (politely) i We welcome **any contributor or community member** to engage with **any pull request** on our repository. Feel free to make suggestions for improvements and ask questions that are relevant. If you're asking questions for your learning, please make it clear that your questions are "non-blocking" for the pull request. -See the [code reviewing documentation](../contributing-code/contributing-code-reviewing/README.md) for guidance on code reviewing. \ No newline at end of file +See the [code reviewing documentation](../contributing-code/contributing-code-reviewing/README.md) for guidance on code reviewing. + +## Inactive Pull Requests + +Pull requests that have been inactive for 90 days will be marked with a stale label. They will automatically be closed after a subsequent 7 days of inactivity. This timeframe may be adjusted in the future based on project needs. \ No newline at end of file From e261d3a88e5ff3aef43b86fa76597353cde7713c Mon Sep 17 00:00:00 2001 From: Karishma Chawla Date: Wed, 7 Feb 2024 19:40:50 -0800 Subject: [PATCH 7/9] Rename stale PRs workflow filename (#7152) # Description Renaming the stale PRs workflow filename to be more explicit. Feedback from https://github.com/radius-project/radius/pull/7143#discussion_r1482147769 ## 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). Signed-off-by: karishma-chawla <74574173+karishma-chawla@users.noreply.github.com> Co-authored-by: karishma-chawla <74574173+karishma-chawla@users.noreply.github.com> --- .github/workflows/{stale-prs.yml => close-stale-prs.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{stale-prs.yml => close-stale-prs.yml} (100%) diff --git a/.github/workflows/stale-prs.yml b/.github/workflows/close-stale-prs.yml similarity index 100% rename from .github/workflows/stale-prs.yml rename to .github/workflows/close-stale-prs.yml From f26db73588b769a4a9a05330d66329ddaf00519f Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 8 Feb 2024 12:44:36 -0600 Subject: [PATCH 8/9] Update RequireResource to handle duplicate short names and proper fully qualified names (also make life a little better for windows file system contributors) (#7134) # Description Updated clivalidation.RequireResourceType so that it can take either fully qualified names or short names.. and if a short name is used and there are duplicate short names display the list of matching short names. I also added a .gitattributes to the following folders so that their test files would maintain lf line ends instead of crlf line ends when cloned or pulled into a windows filesystem. * pkg/corperp/renderers/containers/testdata * pkg/recipes/terraform/config/testdata * pkg/recipes/terraform/testdata/.terraform/modules ## Type of change This pull request fixes a bug in Radius and has an approved issue Fixes: #7070 This pull request fixes a bug in Radius but its not an approved issue Fixes: #7121 --------- Signed-off-by: Josh --- pkg/cli/clivalidation.go | 14 +++- pkg/cli/clivalidation_test.go | 82 +++++++++++++++++++ pkg/cli/cmd/resource/delete/delete_test.go | 9 ++ pkg/cli/cmd/resource/list/list_test.go | 9 ++ pkg/cli/cmd/resource/show/show_test.go | 9 ++ .../container/testdata/.gitattributes | 4 + .../terraform/config/testdata/.gitattributes | 4 + .../.terraform/modules/.gitattributes | 4 + 8 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 pkg/cli/clivalidation_test.go create mode 100644 pkg/corerp/renderers/container/testdata/.gitattributes create mode 100644 pkg/recipes/terraform/config/testdata/.gitattributes create mode 100644 pkg/recipes/terraform/testdata/.terraform/modules/.gitattributes diff --git a/pkg/cli/clivalidation.go b/pkg/cli/clivalidation.go index 20859c18a6..7cb35ff42e 100644 --- a/pkg/cli/clivalidation.go +++ b/pkg/cli/clivalidation.go @@ -249,7 +249,7 @@ func RequireResource(cmd *cobra.Command, args []string) (resourceType string, re // are present. If either is missing, an error is returned. func RequireResourceTypeAndName(args []string) (string, string, error) { if len(args) < 2 { - return "", "", errors.New("No resource type or name provided") + return "", "", errors.New("no resource type or name provided") } resourceType, err := RequireResourceType(args) if err != nil { @@ -270,13 +270,21 @@ func RequireResourceType(args []string) (string, error) { } resourceTypeName := args[0] supportedTypes := []string{} + foundTypes := []string{} for _, resourceType := range clients.ResourceTypesList { supportedType := strings.Split(resourceType, "/")[1] supportedTypes = append(supportedTypes, supportedType) - if strings.EqualFold(supportedType, resourceTypeName) { - return resourceType, nil + //check to see if the resource type is the correct short or long name. + if strings.EqualFold(supportedType, resourceTypeName) || strings.EqualFold(resourceType, resourceTypeName) { + foundTypes = append(foundTypes, resourceType) } } + if len(foundTypes) == 1 { + return foundTypes[0], nil + } else if len(foundTypes) > 1 { + return "", fmt.Errorf("multiple resource types match '%s'. Please specify the full resource type and try again:\n\n%s\n", + resourceTypeName, strings.Join(foundTypes, "\n")) + } return "", fmt.Errorf("'%s' is not a valid resource type. Available Types are: \n\n%s\n", resourceTypeName, strings.Join(supportedTypes, "\n")) } diff --git a/pkg/cli/clivalidation_test.go b/pkg/cli/clivalidation_test.go new file mode 100644 index 0000000000..9d9983cfa8 --- /dev/null +++ b/pkg/cli/clivalidation_test.go @@ -0,0 +1,82 @@ +/* +Copyright 2024 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cli + +import ( + "errors" + "fmt" + "strings" + "testing" + + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/stretchr/testify/require" +) + +func Test_RequireResourceType(t *testing.T) { + + supportedTypes := []string{} + + for _, resourceType := range clients.ResourceTypesList { + supportedType := strings.Split(resourceType, "/")[1] + supportedTypes = append(supportedTypes, supportedType) + } + + resourceTypesErrorString := strings.Join(supportedTypes, "\n") + + tests := []struct { + name string + args []string + want string + wantErr error + }{ + { + name: "No arguments", + args: []string{}, + want: "", + wantErr: errors.New("no resource type provided"), + }, + { + name: "Supported resource type", + args: []string{"mongoDatabases"}, + want: "Applications.Datastores/mongoDatabases", + wantErr: nil, + }, + { + name: "Multiple resource types", + args: []string{"secretStores"}, + want: "", + wantErr: fmt.Errorf("multiple resource types match 'secretStores'. Please specify the full resource type and try again:\n\nApplications.Dapr/secretStores\nApplications.Core/secretStores\n"), + }, + { + name: "Unsupported resource type", + args: []string{"unsupported"}, + want: "", + wantErr: fmt.Errorf("'unsupported' is not a valid resource type. Available Types are: \n\n" + resourceTypesErrorString + "\n"), + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := RequireResourceType(tt.args) + if len(tt.want) > 0 { + require.Equal(t, tt.want, got) + } else { + require.Equal(t, tt.wantErr, err) + } + }) + } +} diff --git a/pkg/cli/cmd/resource/delete/delete_test.go b/pkg/cli/cmd/resource/delete/delete_test.go index 348c043c7c..b45bb6ed48 100644 --- a/pkg/cli/cmd/resource/delete/delete_test.go +++ b/pkg/cli/cmd/resource/delete/delete_test.go @@ -84,6 +84,15 @@ func Test_Validate(t *testing.T) { Config: configWithWorkspace, }, }, + { + Name: "List Command with ambiguous args", + Input: []string{"secretStores"}, + ExpectedValid: false, + ConfigHolder: framework.ConfigHolder{ + ConfigFilePath: "", + Config: configWithWorkspace, + }, + }, } radcli.SharedValidateValidation(t, NewCommand, testcases) } diff --git a/pkg/cli/cmd/resource/list/list_test.go b/pkg/cli/cmd/resource/list/list_test.go index db272c332f..70ba43a4d2 100644 --- a/pkg/cli/cmd/resource/list/list_test.go +++ b/pkg/cli/cmd/resource/list/list_test.go @@ -95,6 +95,15 @@ func Test_Validate(t *testing.T) { Config: configWithWorkspace, }, }, + { + Name: "List Command with ambiguous args", + Input: []string{"secretStores"}, + ExpectedValid: false, + ConfigHolder: framework.ConfigHolder{ + ConfigFilePath: "", + Config: configWithWorkspace, + }, + }, } radcli.SharedValidateValidation(t, NewCommand, testcases) } diff --git a/pkg/cli/cmd/resource/show/show_test.go b/pkg/cli/cmd/resource/show/show_test.go index 1bf3efd982..912b03d702 100644 --- a/pkg/cli/cmd/resource/show/show_test.go +++ b/pkg/cli/cmd/resource/show/show_test.go @@ -89,6 +89,15 @@ func Test_Validate(t *testing.T) { Config: configWithWorkspace, }, }, + { + Name: "List Command with ambiguous args", + Input: []string{"secretStores"}, + ExpectedValid: false, + ConfigHolder: framework.ConfigHolder{ + ConfigFilePath: "", + Config: configWithWorkspace, + }, + }, } radcli.SharedValidateValidation(t, NewCommand, testcases) } diff --git a/pkg/corerp/renderers/container/testdata/.gitattributes b/pkg/corerp/renderers/container/testdata/.gitattributes new file mode 100644 index 0000000000..eb4a37cc6a --- /dev/null +++ b/pkg/corerp/renderers/container/testdata/.gitattributes @@ -0,0 +1,4 @@ +#test files should use lf line endings +*.tf text eol=lf +*.json text eol=lf +*.yaml text eol=lf \ No newline at end of file diff --git a/pkg/recipes/terraform/config/testdata/.gitattributes b/pkg/recipes/terraform/config/testdata/.gitattributes new file mode 100644 index 0000000000..eb4a37cc6a --- /dev/null +++ b/pkg/recipes/terraform/config/testdata/.gitattributes @@ -0,0 +1,4 @@ +#test files should use lf line endings +*.tf text eol=lf +*.json text eol=lf +*.yaml text eol=lf \ No newline at end of file diff --git a/pkg/recipes/terraform/testdata/.terraform/modules/.gitattributes b/pkg/recipes/terraform/testdata/.terraform/modules/.gitattributes new file mode 100644 index 0000000000..eb4a37cc6a --- /dev/null +++ b/pkg/recipes/terraform/testdata/.terraform/modules/.gitattributes @@ -0,0 +1,4 @@ +#test files should use lf line endings +*.tf text eol=lf +*.json text eol=lf +*.yaml text eol=lf \ No newline at end of file From 647c0c7f34151e248431a9b8c233f2f9200bdc28 Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 9 Feb 2024 19:01:35 -0600 Subject: [PATCH 9/9] Update Namespace.ValidateNamespace to add workspace to arguments (#7154) Signed-off-by: Josh # Description in order for the non current context to be used by ValidateNamespaces so that it can create namespaces in the workspaces kubernetes context we need to pass in the workspace and then use workspace.KuberneteContext() to look up the correct context. ## Type of change This pull request fixes a bug in Radius and has an approved issue (issue link required). Fixes: #5698 --------- Signed-off-by: Josh --- pkg/cli/cmd/env/create/create.go | 2 +- pkg/cli/cmd/env/create/create_test.go | 4 ++-- pkg/cli/cmd/env/namespace/mock_namespace.go | 9 +++++---- pkg/cli/cmd/env/namespace/namespace.go | 13 ++++++++++--- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/pkg/cli/cmd/env/create/create.go b/pkg/cli/cmd/env/create/create.go index c185402c42..f0e38879c5 100644 --- a/pkg/cli/cmd/env/create/create.go +++ b/pkg/cli/cmd/env/create/create.go @@ -141,7 +141,7 @@ func (r *Runner) Validate(cmd *cobra.Command, args []string) error { return err } - err = r.NamespaceInterface.ValidateNamespace(cmd.Context(), r.Namespace) + err = r.NamespaceInterface.ValidateNamespace(cmd.Context(), r.Namespace, *r.Workspace) if err != nil { return err } diff --git a/pkg/cli/cmd/env/create/create_test.go b/pkg/cli/cmd/env/create/create_test.go index 87e9f25e06..3273946df1 100644 --- a/pkg/cli/cmd/env/create/create_test.go +++ b/pkg/cli/cmd/env/create/create_test.go @@ -271,13 +271,13 @@ func createMocksWithInvalidResourceGroup(namespaceClient *namespace.MockInterfac func createValidateNamespaceSuccess(namespaceClient *namespace.MockInterface) { namespaceClient.EXPECT(). - ValidateNamespace(gomock.Any(), "testingenv"). + ValidateNamespace(gomock.Any(), "testingenv", gomock.Any()). Return(nil).Times(1) } func createValidateNamespaceError(namespaceClient *namespace.MockInterface) { namespaceClient.EXPECT(). - ValidateNamespace(gomock.Any(), gomock.Any()). + ValidateNamespace(gomock.Any(), gomock.Any(), gomock.Any()). Return(fmt.Errorf("failed to create namespace")).Times(1) } diff --git a/pkg/cli/cmd/env/namespace/mock_namespace.go b/pkg/cli/cmd/env/namespace/mock_namespace.go index f03b7878f0..756add1801 100644 --- a/pkg/cli/cmd/env/namespace/mock_namespace.go +++ b/pkg/cli/cmd/env/namespace/mock_namespace.go @@ -9,6 +9,7 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" + workspaces "github.com/radius-project/radius/pkg/cli/workspaces" ) // MockInterface is a mock of Interface interface. @@ -35,15 +36,15 @@ func (m *MockInterface) EXPECT() *MockInterfaceMockRecorder { } // ValidateNamespace mocks base method. -func (m *MockInterface) ValidateNamespace(arg0 context.Context, arg1 string) error { +func (m *MockInterface) ValidateNamespace(arg0 context.Context, arg1 string, arg2 workspaces.Workspace) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ValidateNamespace", arg0, arg1) + ret := m.ctrl.Call(m, "ValidateNamespace", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 } // ValidateNamespace indicates an expected call of ValidateNamespace. -func (mr *MockInterfaceMockRecorder) ValidateNamespace(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockInterfaceMockRecorder) ValidateNamespace(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateNamespace", reflect.TypeOf((*MockInterface)(nil).ValidateNamespace), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateNamespace", reflect.TypeOf((*MockInterface)(nil).ValidateNamespace), arg0, arg1, arg2) } diff --git a/pkg/cli/cmd/env/namespace/namespace.go b/pkg/cli/cmd/env/namespace/namespace.go index ac983ef0da..5fb35e43e6 100644 --- a/pkg/cli/cmd/env/namespace/namespace.go +++ b/pkg/cli/cmd/env/namespace/namespace.go @@ -19,12 +19,14 @@ package namespace import ( "context" + "github.com/radius-project/radius/pkg/cli/clierrors" "github.com/radius-project/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/cli/workspaces" ) //go:generate mockgen -destination=./mock_namespace.go -package=namespace -self_package github.com/radius-project/radius/pkg/cli/cmd/env/namespace github.com/radius-project/radius/pkg/cli/cmd/env/namespace Interface type Interface interface { - ValidateNamespace(ctx context.Context, namespace string) error + ValidateNamespace(ctx context.Context, namespace string, workspace workspaces.Workspace) error } type Impl struct { @@ -35,8 +37,13 @@ type Impl struct { // ValidateNamespace creates a Kubernetes client and checks if the given namespace exists. If it does not exist, creates it. // If unsuccessful, returns an error. -func (i *Impl) ValidateNamespace(ctx context.Context, namespace string) error { - client, _, err := kubernetes.NewClientset("") +func (i *Impl) ValidateNamespace(ctx context.Context, namespace string, workspace workspaces.Workspace) error { + // get the current kubernetes context from the workspace + kubernetesContext, hasContext := workspace.KubernetesContext() + if !hasContext { + return clierrors.Message("no kubernetes context found in the current workspace") + } + client, _, err := kubernetes.NewClientset(kubernetesContext) if err != nil { return err }