mirror of
https://github.com/kubevela/kubevela.git
synced 2026-05-01 15:07:14 +00:00
* [#929] Modification to comand vela show WORKLOAD_TYPE or TRAIT * update the describetion of --web * [#929] update --web describtion * update the doc of check-ref-doc.md
This commit is contained in:
@@ -11,14 +11,14 @@ Actually, as a important part of its "extensibility" design, KubeVela will alway
|
||||
Thus, as an end user, the only thing you need to do is:
|
||||
|
||||
```console
|
||||
$ vela show WORKLOAD_TYPE or TRAIT
|
||||
$ vela show WORKLOAD_TYPE or TRAIT --web
|
||||
```
|
||||
|
||||
This command will automatically open the reference documentation for given workload type or trait in your default browser.
|
||||
|
||||
### For Workload Types
|
||||
|
||||
Let's take `$ vela show webservice` as example. The detailed schema documentation for `Web Service` workload type will show up immediately as below:
|
||||
Let's take `$ vela show webservice --web` as example. The detailed schema documentation for `Web Service` workload type will show up immediately as below:
|
||||
|
||||

|
||||
|
||||
@@ -26,7 +26,7 @@ Note that there's in the section named `Specification`, it even provides you wit
|
||||
|
||||
### For Traits
|
||||
|
||||
Similarly, we can also do `$ vela show autoscale`:
|
||||
Similarly, we can also do `$ vela show autoscale --web`:
|
||||
|
||||

|
||||
|
||||
@@ -58,7 +58,7 @@ services:
|
||||
This reference doc feature also works for terminal-only case. For example:
|
||||
|
||||
```shell
|
||||
$ vela show webservice --no-website
|
||||
$ vela show webservice
|
||||
# Properties
|
||||
+-------+----------------------------------------------------------------------------------+---------------+----------+---------+
|
||||
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
|
||||
|
||||
@@ -38,7 +38,7 @@ const (
|
||||
Port = ":18081"
|
||||
)
|
||||
|
||||
var noWebSite bool
|
||||
var webSite bool
|
||||
|
||||
// NewAppShowCommand shows the reference doc for a workload type or trait
|
||||
func NewAppShowCommand(c types.Args, ioStreams cmdutil.IOStreams) *cobra.Command {
|
||||
@@ -56,16 +56,17 @@ func NewAppShowCommand(c types.Args, ioStreams cmdutil.IOStreams) *cobra.Command
|
||||
}
|
||||
ctx := context.Background()
|
||||
capabilityName := args[0]
|
||||
if noWebSite {
|
||||
return showReferenceConsole(ctx, c, ioStreams, capabilityName)
|
||||
if webSite {
|
||||
return startReferenceDocsSite(ctx, c, ioStreams, capabilityName)
|
||||
}
|
||||
return startReferenceDocsSite(ctx, c, ioStreams, capabilityName)
|
||||
return showReferenceConsole(ctx, c, ioStreams, capabilityName)
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeStart,
|
||||
},
|
||||
}
|
||||
cmd.Flags().BoolVarP(&noWebSite, "no-website", "", false, "do not start web doc site")
|
||||
|
||||
cmd.Flags().BoolVarP(&webSite, "web", "", false, " start web doc site")
|
||||
cmd.SetOut(ioStreams.Out)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -265,5 +265,5 @@ func SyncDefinitionToLocal(ctx context.Context, c types.Args, localDefinitionDir
|
||||
return &template, nil
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
return nil, fmt.Errorf("%s is not a valid workload type or trait", capabilityName)
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ func setDisplayFormat(format string) {
|
||||
func (ref *MarkdownReference) GenerateReferenceDocs(baseRefPath string) error {
|
||||
caps, err := LoadAllInstalledCapability()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to generate reference docs for all capabilities: %s", err)
|
||||
return fmt.Errorf("failed to generate reference docs for all capabilities: %w", err)
|
||||
}
|
||||
if baseRefPath == "" {
|
||||
baseRefPath = BaseRefPath
|
||||
@@ -221,16 +221,16 @@ func (ref *MarkdownReference) CreateMarkdown(caps []types.Capability, baseRefPat
|
||||
markdownFile := filepath.Join(baseRefPath, capabilityType, fileName)
|
||||
f, err := os.OpenFile(filepath.Clean(markdownFile), os.O_WRONLY|os.O_CREATE, 0600)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open file %s: %s", markdownFile, err)
|
||||
return fmt.Errorf("failed to open file %s: %w", markdownFile, err)
|
||||
}
|
||||
if err = os.Truncate(markdownFile, 0); err != nil {
|
||||
return fmt.Errorf("failed to truncate file %s: %s", markdownFile, err)
|
||||
return fmt.Errorf("failed to truncate file %s: %w", markdownFile, err)
|
||||
}
|
||||
capName := c.Name
|
||||
|
||||
cueValue, err := common.GetCUEParameterValue(c.CueTemplate)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to retrieve `parameters` value from %s with err: %s", c.Name, err)
|
||||
return fmt.Errorf("failed to retrieve `parameters` value from %s with err: %w", c.Name, err)
|
||||
}
|
||||
refContent = ""
|
||||
var defaultDepth = 0
|
||||
@@ -407,7 +407,7 @@ func (ref *ConsoleReference) GenerateCapabilityProperties(capability *types.Capa
|
||||
|
||||
cueValue, err := common.GetCUEParameterValue(capability.CueTemplate)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to retrieve `parameters` value from %s with err: %s", capName, err)
|
||||
return nil, fmt.Errorf("failed to retrieve `parameters` value from %s with err: %w", capName, err)
|
||||
}
|
||||
var defaultDepth = 0
|
||||
recurseDepth = &defaultDepth
|
||||
|
||||
Reference in New Issue
Block a user