Skip to content

Commit d8422a7

Browse files
committed
review comments
Signed-off-by: Pravin Pushkar <[email protected]>
1 parent bf0e7ff commit d8422a7

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

pkg/standalone/common.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ import (
2222
)
2323

2424
const (
25-
defaultDaprDirName = ".dapr"
26-
defaultDaprBinDirName = "bin"
27-
defaultComponentsDirName = "components"
28-
defaultResourcesDirName = "resources"
29-
defaultConfigFileName = "config.yaml"
25+
DefaultComponentsDirName = "components"
26+
DefaultResourcesDirName = "resources"
27+
28+
defaultDaprDirName = ".dapr"
29+
defaultDaprBinDirName = "bin"
30+
defaultConfigFileName = "config.yaml"
3031
)
3132

3233
func defaultDaprDirPath() string {
@@ -47,11 +48,11 @@ func binaryFilePath(binaryDir string, binaryFilePrefix string) string {
4748
}
4849

4950
func DefaultComponentsDirPath() string {
50-
return path_filepath.Join(defaultDaprDirPath(), defaultComponentsDirName)
51+
return path_filepath.Join(defaultDaprDirPath(), DefaultComponentsDirName)
5152
}
5253

5354
func DefaultResourcesDirPath() string {
54-
return path_filepath.Join(defaultDaprDirPath(), defaultResourcesDirName)
55+
return path_filepath.Join(defaultDaprDirPath(), DefaultResourcesDirName)
5556
}
5657

5758
// DefaultResourcesDirPrecedence returns the path to the resources directory if it exists, or otherwise the components directory.
@@ -72,7 +73,8 @@ func DefaultConfigFilePath() string {
7273
// TODO: Remove this function when `--components-path` flag is removed.
7374
func emptyAndCopyFiles(src, dest string) error {
7475
if _, err := os.Stat(src); err != nil {
75-
return err
76+
// if the src directory does not exist, return nil, because there is nothing to copy from.
77+
return nil
7678
}
7779
files, err := os.ReadDir(dest)
7880
if err != nil {
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// TODO: Remove the test when `--components-path` flag is removed.
17+
// TODO: Remove the test file when `--components-path` flag is removed.
18+
19+
// This file contains tests for the migration of components directory to resources directory.
20+
// It covers the test flow for scenario when user does: (1) dapr uninstall (2) upgrades dapr cli (3) dapr init (4) dapr run.
1821
package standalone_test
1922

2023
import (

tests/e2e/standalone/utils.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/stretchr/testify/assert"
2929
"github.com/stretchr/testify/require"
3030

31+
"github.com/dapr/cli/pkg/standalone"
3132
"github.com/dapr/cli/tests/e2e/common"
3233
)
3334

@@ -139,11 +140,11 @@ func ensureDaprInstallation(t *testing.T) {
139140
require.NoError(t, err, "failed to stat dapr installation")
140141
}
141142

142-
// Slim mode does not have any components by default.
143-
// Install the components required by the tests.
143+
// Slim mode does not have any resources by default.
144+
// Install the resources required by the tests.
144145
if isSlimMode() {
145-
err = createSlimComponents(filepath.Join(daprPath, "resources"))
146-
require.NoError(t, err, "failed to create components")
146+
err = createSlimComponents(filepath.Join(daprPath, standalone.DefaultResourcesDirName))
147+
require.NoError(t, err, "failed to create resources directory for slim mode")
147148
}
148149
}
149150

0 commit comments

Comments
 (0)