Skip to content

Commit

Permalink
Fix bug for not setting dev recipe flag through rad init (#5133)
Browse files Browse the repository at this point in the history
# Description

- SkipDevRecipes isn't being set on env when user does rad init
- This change sets the flag on the env
<img width="1084" alt="Screenshot 2023-02-07 at 1 36 22 PM"
src="https://user-images.githubusercontent.com/99223262/217371400-58e826d8-0181-4fd0-ab21-06e8e45f66ec.png">

## Issue reference

<!--
We strive to have all PR being opened based on an issue, where the
problem or feature have been discussed prior to implementation.
-->

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 <[email protected]>
  • Loading branch information
bjoginapally and Bharath Joginapally authored Feb 7, 2023
1 parent fe85dcc commit b6687d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/cli/cmd/radInit/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
}
Expand Down
12 changes: 8 additions & 4 deletions pkg/cli/cmd/radInit/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand All @@ -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)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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().
Expand All @@ -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().
Expand All @@ -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",
Expand Down

0 comments on commit b6687d8

Please sign in to comment.