Skip to content

Commit

Permalink
Removing useDevRecipes property and skip-dev-recipes flag (#5528)
Browse files Browse the repository at this point in the history
# Description
This PR:
1. Removal of `useDevRecipes` property from the environment resource
2. Removal of `skip-dev-recipes` flag from `rad init` and a few other
commands

This is the follow-up PR after
#5526.

## Issue reference
Fixes: #5460 

## Checklist

Please make sure you've completed the relevant tasks for this PR, out of
the following list:

* [x] Code compiles correctly
* [x] Adds necessary unit tests for change
* [ ] Adds necessary E2E tests for change
* [x] Unit tests passing
* [x] Extended the documentation / Created issue for it
  • Loading branch information
ytimocin authored May 21, 2023
1 parent 7bcd7e9 commit c8c6e00
Show file tree
Hide file tree
Showing 38 changed files with 632 additions and 1,250 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@
* **providers**: [Providers](#providers): Cloud providers configuration
* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the resource at the time the operation was called.
* **recipes**: [EnvironmentPropertiesRecipes](#environmentpropertiesrecipes): Specifies Recipes linked to the Environment.
* **useDevRecipes**: bool: Flag to use radius owned recipes.

## EnvironmentExtension
* **Discriminator**: kind
Expand Down
2 changes: 0 additions & 2 deletions pkg/cli/cmd/env/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ func (r *Runner) Run(ctx context.Context) error {
}

envProperties := &corerp.EnvironmentProperties{
// Setting this to false to make sure that we only install the recipes with rad init --dev flag.
UseDevRecipes: to.Ptr(false),
Compute: &corerp.KubernetesCompute{
Namespace: to.Ptr(r.Namespace),
},
Expand Down
73 changes: 66 additions & 7 deletions pkg/cli/cmd/env/create/create_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// // ------------------------------------------------------------
// // Copyright (c) Microsoft Corporation.
// // Licensed under the MIT License.
// // ------------------------------------------------------------
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------

package create

import (
"context"
"errors"
"fmt"
"testing"

Expand Down Expand Up @@ -120,14 +121,13 @@ func Test_Validate(t *testing.T) {
radcli.SharedValidateValidation(t, NewCommand, testcases)
}

func Test_Run_Success(t *testing.T) {
t.Run("Run env create tests", func(t *testing.T) {
func Test_Run(t *testing.T) {
t.Run("Success", func(t *testing.T) {
ctrl := gomock.NewController(t)
appManagementClient := clients.NewMockApplicationsManagementClient(ctrl)

namespaceClient := namespace.NewMockInterface(ctrl)
testEnvProperties := &corerp.EnvironmentProperties{
UseDevRecipes: to.Ptr(false),
Compute: &corerp.KubernetesCompute{
Namespace: to.Ptr("default"),
},
Expand Down Expand Up @@ -158,8 +158,67 @@ func Test_Run_Success(t *testing.T) {
ConfigFileInterface: configFileInterface,
}

expectedOutput := []any{
output.LogOutput{
Format: "Creating Environment...",
},
output.LogOutput{
Format: "Successfully created environment %q in resource group %q",
Params: []interface{}{
"default",
"default",
},
},
}

err := runner.Run(context.Background())
require.NoError(t, err)
require.Equal(t, expectedOutput, outputSink.Writes)
})

t.Run("Failure", func(t *testing.T) {
ctrl := gomock.NewController(t)
appManagementClient := clients.NewMockApplicationsManagementClient(ctrl)

namespaceClient := namespace.NewMockInterface(ctrl)
testEnvProperties := &corerp.EnvironmentProperties{
Compute: &corerp.KubernetesCompute{
Namespace: to.Ptr("default"),
},
}

expectedError := errors.New("failed to create the environment")

appManagementClient.EXPECT().
CreateEnvironment(context.Background(), "default", v1.LocationGlobal, testEnvProperties).
Return(false, expectedError).
Times(1)

configFileInterface := framework.NewMockConfigFileInterface(ctrl)
outputSink := &output.MockOutput{}
workspace := &workspaces.Workspace{
Connection: map[string]any{
"kind": "kubernetes",
"context": "kind-kind",
},
Name: "defaultWorkspace",
}

runner := &Runner{
ConnectionFactory: &connections.MockFactory{ApplicationsManagementClient: appManagementClient},
ConfigHolder: &framework.ConfigHolder{ConfigFilePath: "filePath"},
Output: outputSink,
Workspace: workspace,
EnvironmentName: "default",
UCPResourceGroup: "default",
Namespace: "default",
NamespaceInterface: namespaceClient,
ConfigFileInterface: configFileInterface,
}

err := runner.Run(context.Background())
require.Error(t, err)
require.Equal(t, expectedError, err)
})
}

Expand Down
1 change: 1 addition & 0 deletions pkg/cli/cmd/env/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ func (r *Runner) Run(ctx context.Context) error {
if r.noFlagsSet {
return nil
}

client, err := r.ConnectionFactory.CreateApplicationsManagementClient(ctx, *r.Workspace)
if err != nil {
return err
Expand Down
Loading

0 comments on commit c8c6e00

Please sign in to comment.