From b6687d81a9a245cdd0959e09f57ee722d05f573e Mon Sep 17 00:00:00 2001 From: Bharath <99223262+bjoginapally@users.noreply.github.com> Date: Tue, 7 Feb 2023 14:24:42 -0800 Subject: [PATCH] Fix bug for not setting dev recipe flag through rad init (#5133) # Description - SkipDevRecipes isn't being set on env when user does rad init - This change sets the flag on the env Screenshot 2023-02-07 at 1 36 22 PM ## Issue reference Fixes: #5130 ## Checklist Please make sure you've completed the relevant tasks for this PR, out of the following list: * [x] Code compiles correctly * [ ] Adds necessary unit tests for change * [ ] Adds necessary E2E tests for change * [x] Unit tests passing * [ ] Extended the documentation / Created issue for it --------- Co-authored-by: Bharath Joginapally --- pkg/cli/cmd/radInit/init.go | 2 +- pkg/cli/cmd/radInit/init_test.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/cli/cmd/radInit/init.go b/pkg/cli/cmd/radInit/init.go index b174e6b03f..5abb00f47d 100644 --- a/pkg/cli/cmd/radInit/init.go +++ b/pkg/cli/cmd/radInit/init.go @@ -375,7 +375,7 @@ func (r *Runner) Run(ctx context.Context) error { } r.Output.LogInfo("Configuring Cloud providers") - isEnvCreated, err := client.CreateEnvironment(ctx, r.EnvName, v1.LocationGlobal, r.Namespace, "kubernetes", "", map[string]*corerp.EnvironmentRecipeProperties{}, &providers, false) + isEnvCreated, err := client.CreateEnvironment(ctx, r.EnvName, v1.LocationGlobal, r.Namespace, "kubernetes", "", map[string]*corerp.EnvironmentRecipeProperties{}, &providers, !r.SkipDevRecipes) if err != nil || !isEnvCreated { return &cli.FriendlyError{Message: "Failed to create radius environment"} } diff --git a/pkg/cli/cmd/radInit/init_test.go b/pkg/cli/cmd/radInit/init_test.go index 2c84f00e11..33069faebd 100644 --- a/pkg/cli/cmd/radInit/init_test.go +++ b/pkg/cli/cmd/radInit/init_test.go @@ -427,7 +427,7 @@ func Test_Validate(t *testing.T) { radcli.SharedValidateValidation(t, NewCommand, testcases) } -func Test_Run_InstallAndCreateEnvironment_WithAzureProvider(t *testing.T) { +func Test_Run_InstallAndCreateEnvironment_WithAzureProvider_WithRecipes(t *testing.T) { ctrl := gomock.NewController(t) configFileInterface := framework.NewMockConfigFileInterface(ctrl) configFileInterface.EXPECT(). @@ -441,8 +441,9 @@ func Test_Run_InstallAndCreateEnvironment_WithAzureProvider(t *testing.T) { appManagementClient.EXPECT(). CreateUCPGroup(context.Background(), "deployments", "local", "default", gomock.Any()). Return(true, nil).Times(1) + skipRecipes := false appManagementClient.EXPECT(). - CreateEnvironment(context.Background(), "default", v1.LocationGlobal, "defaultNamespace", "kubernetes", gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). + CreateEnvironment(context.Background(), "default", v1.LocationGlobal, "defaultNamespace", "kubernetes", gomock.Any(), gomock.Any(), gomock.Any(), !skipRecipes). Return(true, nil).Times(1) credentialManagementClient := cli_credential.NewMockCredentialManagementClient(ctrl) @@ -476,6 +477,7 @@ func Test_Run_InstallAndCreateEnvironment_WithAzureProvider(t *testing.T) { Namespace: "defaultNamespace", RadiusInstalled: true, // We're testing the reinstall case Reinstall: true, + SkipDevRecipes: skipRecipes, AzureCloudProvider: &azure.Provider{ SubscriptionID: "test-subscription", ResourceGroup: "test-rg", @@ -552,7 +554,7 @@ func Test_Run_InstallAndCreateEnvironment_WithAWSProvider(t *testing.T) { require.NoError(t, err) } -func Test_Run_InstallAndCreateEnvironment_WithoutAzureProvider(t *testing.T) { +func Test_Run_InstallAndCreateEnvironment_WithoutAzureProvider_WithSkipRecipes(t *testing.T) { ctrl := gomock.NewController(t) configFileInterface := framework.NewMockConfigFileInterface(ctrl) configFileInterface.EXPECT(). @@ -566,8 +568,9 @@ func Test_Run_InstallAndCreateEnvironment_WithoutAzureProvider(t *testing.T) { appManagementClient.EXPECT(). CreateUCPGroup(context.Background(), "deployments", "local", "default", gomock.Any()). Return(true, nil).Times(1) + skipRecipes := true appManagementClient.EXPECT(). - CreateEnvironment(context.Background(), "default", v1.LocationGlobal, "defaultNamespace", "kubernetes", gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). + CreateEnvironment(context.Background(), "default", v1.LocationGlobal, "defaultNamespace", "kubernetes", gomock.Any(), gomock.Any(), gomock.Any(), !skipRecipes). Return(true, nil).Times(1) configFileInterface.EXPECT(). @@ -589,6 +592,7 @@ func Test_Run_InstallAndCreateEnvironment_WithoutAzureProvider(t *testing.T) { Output: outputSink, Workspace: &workspaces.Workspace{Name: "defaultWorkspace"}, KubeContext: "kind-kind", + SkipDevRecipes: skipRecipes, RadiusInstalled: false, Namespace: "defaultNamespace", EnvName: "default",