mirror of https://github.com/dapr/cli.git
Fix examples and print preview feature warnings (#927)
* Fix examples and print preview feature warnings Signed-off-by: Mukundan Sundararajan <msundar.ms@outlook.com> * small changes to wordings Signed-off-by: Mukundan Sundararajan <msundar.ms@outlook.com>
This commit is contained in:
parent
9fa0cdf229
commit
ce0af7c01c
32
README.md
32
README.md
|
@ -442,7 +442,13 @@ This can be used when upgrading to a newer version of Dapr, as it's recommended
|
||||||
To list all Dapr components on Kubernetes:
|
To list all Dapr components on Kubernetes:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
dapr components --kubernetes
|
dapr components --kubernetes --all-namespaces
|
||||||
|
```
|
||||||
|
|
||||||
|
To list Dapr components in `target-namespace` namespace on Kubernetes:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
dapr components --kubernetes --namespace target-namespace
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use non-default Components Path
|
### Use non-default Components Path
|
||||||
|
@ -459,7 +465,13 @@ dapr run --components-path [custom path]
|
||||||
To list all Dapr configurations on Kubernetes:
|
To list all Dapr configurations on Kubernetes:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
dapr configurations --kubernetes
|
dapr configurations --kubernetes --all-namespaces
|
||||||
|
```
|
||||||
|
|
||||||
|
To list Dapr configurations in `target-namespace` namespace on Kubernetes:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
dapr configurations --kubernetes --namespace target-namespace
|
||||||
```
|
```
|
||||||
|
|
||||||
### Stop
|
### Stop
|
||||||
|
@ -555,22 +567,6 @@ If you want to invoke your app, also use this flag:
|
||||||
$ dapr invoke --app-id nodeapp --unix-domain-socket --method mymethod
|
$ dapr invoke --app-id nodeapp --unix-domain-socket --method mymethod
|
||||||
```
|
```
|
||||||
|
|
||||||
### Enable Unix domain socket
|
|
||||||
|
|
||||||
In order to enable Unix domain socket to connect Dapr API server, use the `--unix-domain-socket` flag:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ dapr run --app-id nodeapp --unix-domain-socket node app.js
|
|
||||||
```
|
|
||||||
|
|
||||||
Dapr will automatically create a Unix domain socket to connect Dapr API server.
|
|
||||||
|
|
||||||
If you want to invoke your app, also use this flag:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ dapr invoke --app-id nodeapp --unix-domain-socket --method mymethod
|
|
||||||
```
|
|
||||||
|
|
||||||
For more details, please run the command and check the examples to apply to your shell.
|
For more details, please run the command and check the examples to apply to your shell.
|
||||||
|
|
||||||
## Reference for the Dapr CLI
|
## Reference for the Dapr CLI
|
||||||
|
|
|
@ -34,15 +34,11 @@ var ComponentsCmd = &cobra.Command{
|
||||||
Short: "List all Dapr components. Supported platforms: Kubernetes",
|
Short: "List all Dapr components. Supported platforms: Kubernetes",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if kubernetesMode {
|
if kubernetesMode {
|
||||||
print.WarningStatusEvent(os.Stdout, "In future releases, this command will only query the \"default\" namespace by default. Please use the -n (namespace) flag, for specific namespace, or -A (all-namespaces) flag for all namespaces.")
|
print.WarningStatusEvent(os.Stdout, "In future releases, this command will only query the \"default\" namespace by default. Please use the --namespace flag for a specific namespace, or the --all-namespaces (-A) flag for all namespaces.")
|
||||||
if allNamespaces {
|
if allNamespaces {
|
||||||
resourceNamespace = meta_v1.NamespaceAll
|
resourceNamespace = meta_v1.NamespaceAll
|
||||||
} else if resourceNamespace == "" {
|
} else if resourceNamespace == "" {
|
||||||
resourceNamespace = meta_v1.NamespaceAll
|
resourceNamespace = meta_v1.NamespaceAll
|
||||||
print.WarningStatusEvent(os.Stdout, "From next release(or after 2 releases), behavior can be changed to query only \"default\" namespace.")
|
|
||||||
}
|
|
||||||
if componentsName != "" {
|
|
||||||
print.WarningStatusEvent(os.Stdout, "From next release(or after 2 releases), behavior can be changed to treat it as \"namespace\".")
|
|
||||||
}
|
}
|
||||||
err := kubernetes.PrintComponents(componentsName, resourceNamespace, componentsOutputFormat)
|
err := kubernetes.PrintComponents(componentsName, resourceNamespace, componentsOutputFormat)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -55,16 +51,16 @@ var ComponentsCmd = &cobra.Command{
|
||||||
kubernetes.CheckForCertExpiry()
|
kubernetes.CheckForCertExpiry()
|
||||||
},
|
},
|
||||||
Example: `
|
Example: `
|
||||||
# List all namespace Dapr components in Kubernetes mode
|
# List Dapr components in all namespaces in Kubernetes mode
|
||||||
dapr components -k
|
dapr components -k
|
||||||
|
|
||||||
# List define namespace Dapr components in Kubernetes mode
|
# List Dapr components in specific namespace in Kubernetes mode
|
||||||
dapr components -k --namespace default
|
dapr components -k --namespace default
|
||||||
|
|
||||||
# Print define name Dapr components in Kubernetes mode
|
# Print specific Dapr component in Kubernetes mode
|
||||||
dapr components -k -n target
|
dapr components -k -n target
|
||||||
|
|
||||||
# List all namespaces Dapr components in Kubernetes mode
|
# List Dapr components in all namespaces in Kubernetes mode
|
||||||
dapr components -k --all-namespaces
|
dapr components -k --all-namespaces
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,15 +34,11 @@ var ConfigurationsCmd = &cobra.Command{
|
||||||
Short: "List all Dapr configurations. Supported platforms: Kubernetes",
|
Short: "List all Dapr configurations. Supported platforms: Kubernetes",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if kubernetesMode {
|
if kubernetesMode {
|
||||||
print.WarningStatusEvent(os.Stdout, "In future releases, this command will only query the \"default\" namespace by default. Please use the -n (namespace) flag, for specific namespace, or -A (all-namespaces) flag for all namespaces.")
|
print.WarningStatusEvent(os.Stdout, "In future releases, this command will only query the \"default\" namespace by default. Please use the --namespace flag for a specific namespace, or the --all-namespaces (-A) flag for all namespaces.")
|
||||||
if allNamespaces {
|
if allNamespaces {
|
||||||
resourceNamespace = meta_v1.NamespaceAll
|
resourceNamespace = meta_v1.NamespaceAll
|
||||||
} else if resourceNamespace == "" {
|
} else if resourceNamespace == "" {
|
||||||
resourceNamespace = meta_v1.NamespaceAll
|
resourceNamespace = meta_v1.NamespaceAll
|
||||||
print.WarningStatusEvent(os.Stdout, "From next release(or after 2 releases), behavior can be changed to query only \"default\" namespace.")
|
|
||||||
}
|
|
||||||
if configurationName != "" {
|
|
||||||
print.WarningStatusEvent(os.Stdout, "From next release(or after 2 releases), behavior can be changed to treat it as \"namespace\".")
|
|
||||||
}
|
}
|
||||||
err := kubernetes.PrintConfigurations(configurationName, resourceNamespace, configurationOutputFormat)
|
err := kubernetes.PrintConfigurations(configurationName, resourceNamespace, configurationOutputFormat)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -55,16 +51,16 @@ var ConfigurationsCmd = &cobra.Command{
|
||||||
kubernetes.CheckForCertExpiry()
|
kubernetes.CheckForCertExpiry()
|
||||||
},
|
},
|
||||||
Example: `
|
Example: `
|
||||||
# List all namespace Dapr configurations in Kubernetes mode
|
# List Dapr configurations in all namespaces in Kubernetes mode
|
||||||
dapr configurations -k
|
dapr configurations -k
|
||||||
|
|
||||||
# List define namespace Dapr configurations in Kubernetes mode
|
# List Dapr configurations in specific namespace in Kubernetes mode
|
||||||
dapr configurations -k --namespace default
|
dapr configurations -k --namespace default
|
||||||
|
|
||||||
# Print define name Dapr configurations in Kubernetes mode
|
# Print specific Dapr configuration in Kubernetes mode
|
||||||
dapr configurations -k -n target
|
dapr configurations -k -n target
|
||||||
|
|
||||||
# List all namespaces Dapr configurations in Kubernetes mode
|
# List Dapr configurations in all namespaces in Kubernetes mode
|
||||||
dapr configurations -k --all-namespaces
|
dapr configurations -k --all-namespaces
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,9 @@ dapr init -k --runtime-version 0.10.0
|
||||||
# Initialize Dapr in slim self-hosted mode
|
# Initialize Dapr in slim self-hosted mode
|
||||||
dapr init -s
|
dapr init -s
|
||||||
|
|
||||||
|
# Initialize Dapr from a directory (installer-bundle installation) (Preview feature)
|
||||||
|
dapr init --from-dir <path-to-directory>
|
||||||
|
|
||||||
# See more at: https://docs.dapr.io/getting-started/
|
# See more at: https://docs.dapr.io/getting-started/
|
||||||
`,
|
`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
@ -100,6 +103,9 @@ dapr init -s
|
||||||
dockerNetwork = viper.GetString("network")
|
dockerNetwork = viper.GetString("network")
|
||||||
imageRepositoryURL = viper.GetString("image-repository")
|
imageRepositoryURL = viper.GetString("image-repository")
|
||||||
}
|
}
|
||||||
|
if fromDir != "" {
|
||||||
|
print.WarningStatusEvent(os.Stdout, "Local bundle installation using from-dir flag is currently a preview feature.")
|
||||||
|
}
|
||||||
err := standalone.Init(runtimeVersion, dashboardVersion, dockerNetwork, slimMode, imageRepositoryURL, fromDir)
|
err := standalone.Init(runtimeVersion, dashboardVersion, dockerNetwork, slimMode, imageRepositoryURL, fromDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
print.FailureStatusEvent(os.Stderr, err.Error())
|
print.FailureStatusEvent(os.Stderr, err.Error())
|
||||||
|
|
|
@ -61,13 +61,13 @@ var ListCmd = &cobra.Command{
|
||||||
# List Dapr instances in self-hosted mode
|
# List Dapr instances in self-hosted mode
|
||||||
dapr list
|
dapr list
|
||||||
|
|
||||||
# List all namespace Dapr instances in Kubernetes mode
|
# List Dapr instances in all namespaces in Kubernetes mode
|
||||||
dapr list -k
|
dapr list -k
|
||||||
|
|
||||||
# List define namespace Dapr instances in Kubernetes mode
|
# List Dapr instances in a specific namespace in Kubernetes mode
|
||||||
dapr list -k --namespace default
|
dapr list -k --namespace default
|
||||||
|
|
||||||
# List all namespaces Dapr instances in Kubernetes mode
|
# List Dapr instances in all namespaces in Kubernetes mode
|
||||||
dapr list -k --all-namespaces
|
dapr list -k --all-namespaces
|
||||||
`,
|
`,
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
@ -78,12 +78,11 @@ dapr list -k --all-namespaces
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if kubernetesMode {
|
if kubernetesMode {
|
||||||
print.WarningStatusEvent(os.Stdout, "In future releases, this command will only query the \"default\" namespace by default. Please use the -n (namespace) flag, for specific namespace, or -A (all-namespaces) flag for all namespaces.")
|
print.WarningStatusEvent(os.Stdout, "In future releases, this command will only query the \"default\" namespace by default. Please use the --namespace flag for a specific namespace, or the --all-namespaces (-A) flag for all namespaces.")
|
||||||
if allNamespaces {
|
if allNamespaces {
|
||||||
resourceNamespace = meta_v1.NamespaceAll
|
resourceNamespace = meta_v1.NamespaceAll
|
||||||
} else if resourceNamespace == "" {
|
} else if resourceNamespace == "" {
|
||||||
resourceNamespace = meta_v1.NamespaceAll
|
resourceNamespace = meta_v1.NamespaceAll
|
||||||
print.WarningStatusEvent(os.Stdout, "From next release(or after 2 releases), behavior can be changed to query only \"default\" namespace.")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
list, err := kubernetes.List(resourceNamespace)
|
list, err := kubernetes.List(resourceNamespace)
|
||||||
|
|
|
@ -151,6 +151,8 @@ func Init(runtimeVersion, dashboardVersion string, dockerNetwork string, slimMod
|
||||||
v1, v2 := parseVersionFile(fromDir)
|
v1, v2 := parseVersionFile(fromDir)
|
||||||
if v1 != "" && v2 != "" {
|
if v1 != "" && v2 != "" {
|
||||||
runtimeVersion, dashboardVersion = v1, v2
|
runtimeVersion, dashboardVersion = v1, v2
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("runtime and dashboard versions cannot be parsed from version file in directory")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -533,7 +533,7 @@ func componentsTestOnUninstall(all bool) func(t *testing.T) {
|
||||||
lines := strings.Split(output, "\n")
|
lines := strings.Split(output, "\n")
|
||||||
|
|
||||||
// An extra empty line is there in output.
|
// An extra empty line is there in output.
|
||||||
require.Equal(t, 4, len(lines), "expected header and warning message of the output to remain")
|
require.Equal(t, 3, len(lines), "expected header and warning message of the output to remain")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,24 +555,24 @@ func componentOutputCheck(t *testing.T, output string, all bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if all {
|
if all {
|
||||||
assert.Equal(t, len(lines), 3, "expected at 0 components and 3 message items")
|
assert.Equal(t, 2, len(lines), "expected at 0 components and 2 output lines")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
lines = strings.Split(output, "\n")[3:] // remove header and warning message.
|
lines = strings.Split(output, "\n")[2:] // remove header and warning message.
|
||||||
|
|
||||||
assert.Equal(t, len(lines), 2, "expect at 2 componets") // default and test namespace components.
|
assert.Equal(t, 2, len(lines), "expected 2 componets") // default and test namespace components.
|
||||||
|
|
||||||
// for fresh cluster only one component yaml has been applied.
|
// for fresh cluster only one component yaml has been applied.
|
||||||
testNsFields := strings.Fields(lines[0])
|
testNsFields := strings.Fields(lines[0])
|
||||||
defaultNsFields := strings.Fields(lines[1])
|
defaultNsFields := strings.Fields(lines[1])
|
||||||
|
|
||||||
// Fields splits on space, so Created time field might be split again.
|
// Fields splits on space, so Created time field might be split again.
|
||||||
defineComponentOutputCheck(t, testNsFields, "test")
|
namespaceComponentOutputCheck(t, testNsFields, "test")
|
||||||
defineComponentOutputCheck(t, defaultNsFields, "default")
|
namespaceComponentOutputCheck(t, defaultNsFields, "default")
|
||||||
}
|
}
|
||||||
|
|
||||||
func defineComponentOutputCheck(t *testing.T, fields []string, namespace string) {
|
func namespaceComponentOutputCheck(t *testing.T, fields []string, namespace string) {
|
||||||
assert.GreaterOrEqual(t, len(fields), 6, "expected at least 6 fields in components output")
|
assert.GreaterOrEqual(t, len(fields), 6, "expected at least 6 fields in components output")
|
||||||
assert.Equal(t, namespace, fields[0], "expected name to match")
|
assert.Equal(t, namespace, fields[0], "expected name to match")
|
||||||
assert.Equal(t, "statestore", fields[1], "expected name to match")
|
assert.Equal(t, "statestore", fields[1], "expected name to match")
|
||||||
|
|
Loading…
Reference in New Issue